openai-realtime
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "openai-realtime" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-f63d247a75cc8cb8a66a10cb33f6d89b94bb8672461bbfbe94cbe49336d1d841. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Build voice-enabled AI applications using the OpenAI Realtime API, suitable for implementing real-time voice conversations, streaming audio over WebSocket, creating voice assistants, or integrating OpenAI audio capabilities.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: openai-realtime
description: >-
Build voice-enabled AI applications with the OpenAI Realtime API. Use when a user asks to implement real-time voice conversations, stream audio with WebSockets, build voice assistants, or integrate OpenAI audio capabilities.
license: Apache-2.0
compatibility: "No special requirements"
metadata:
author: terminal-skills
version: "1.0.0"
category: data-ai
tags: ["openai", "realtime", "voice", "websocket", "multimodal"]OpenAI Realtime API — Voice-Native AI Conversations
Overview
You are an expert in the OpenAI Realtime API, the WebSocket-based interface for building voice-native AI applications. You help developers build conversational voice agents that process audio input directly (no separate STT step), generate spoken responses with natural intonation, handle interruptions, and use function calling — all in a single streaming connection with sub-second latency.
Instructions
WebSocket Connection
// Connect to OpenAI Realtime API
import WebSocket from "ws";
const ws = new WebSocket("wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview", {
headers: {
"Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
"OpenAI-Beta": "realtime=v1",
},
});
ws.on("open", () => {
// Configure the session
ws.send(JSON.stringify({
type: "session.update",
session: {
modalities: ["text", "audio"],
voice: "alloy", // alloy, echo, fable, onyx, nova, shimmer
instructions: `You are a helpful dental clinic receptionist named Ava.
Be warm, professional, and concise. Use short sentences appropriate for phone calls.
If asked about medical advice, say you'll transfer to the dentist.`,
input_audio_format: "pcm16", // 16-bit PCM, 24kHz
output_audio_format: "pcm16",
input_audio_transcription: {
model: "whisper-1", // Also transcribe for logging
},
turn_detection: {
type: "server_vad", // Server-side voice activity detection
threshold: 0.5, // Sensitivity (0-1)
prefix_padding_ms: 300, // Include 300ms before speech start
silence_duration_ms: 500, // 500ms silence = end of turn
},
tools: [ // Function calling tools
{
type: "function",
name: "check_availability",
description: "Check available appointment slots",
parameters: {
type: "object",
properties: {
date: { type: "string", description: "Date in YYYY-MM-DD format" },
procedure: { type: "string", enum: ["cleaning", "filling", "crown", "consultation"] },
},
required: ["date", "procedure"],
},
},
{
type: "function",
name: "book_appointment",
description: "Book an appointment for a patient",
parameters: {
type: "object",
properties: {
patient_name: { type: "string" },
phone: { type: "string" },
date: { type: "string" },
time: { type: "string" },
procedure: { type: "string" },
},
required: ["patient_name", "date", "time", "procedure"],
},
},
],
},
}));
});
// Handle events from OpenAI
ws.on("message", (data) => {
const event = JSON.parse(data.toString());
switch (event.type) {
case "response.audio.delta":
// Stream audio chunks to speaker/WebRTC
const audioChunk = Buffer.from(event.delta, "base64");
sendToSpeaker(audioChunk);
break;
case "response.audio_transcript.delta":
// Real-time transcript of AI's response
process.stdout.write(event.delta);
break;
case "conversation.item.input_audio_transcription.completed":
// User's speech transcribed
console.log(`\nUser said: ${event.transcript}`);
break;
case "response.function_call_arguments.done":
// AI wants to call a function
handleFunctionCall(event.name, JSON.parse(event.arguments));
break;
case "input_audio_buffer.speech_started":
// User started speaking — interrupt AI if it's talking
console.log("[User interruption detected]");
break;
}
});
// Send microphone audio
function sendAudio(pcmBuffer: Buffer) {
ws.send(JSON.stringify({
type: "input_audio_buffer.append",
audio: pcmBuffer.toString("base64"),
}));
}
// Handle function calls
async function handleFunctionCall(name: string, args: any) {
let result: string;
if (name === "check_availability") {
const slots = await checkClinicSlots(args.date, args.procedure);
result = JSON.stringify(slots);
} else if (name === "book_appointment") {
const booking = await createAppointment(args);
result = JSON.stringify(booking);
}
// Send function result back — AI will speak the response
ws.send(JSON.stringify({
type: "conversation.item.create",
item: {
type: "function_call_output",
call_id: event.call_id,
output: result,
},
}));
// Trigger AI to respond with the function result
ws.send(JSON.stringify({ type: "response.create" }));
}
Python SDK
# Using OpenAI Python SDK
from openai import AsyncOpenAI
client = AsyncOpenAI()
async def run_voice_agent():
async with client.beta.realtime.connect(
model="gpt-4o-realtime-preview"
) as connection:
await connection.session.update(session={
"modalities": ["text", "audio"],
"voice": "nova",
"instructions": "You are a helpful assistant.",
"turn_detection": {"type": "server_vad"},
})
# Send audio from microphone
await connection.input_audio_buffer.append(audio=base64_audio)
# Process events
async for event in connection:
if event.type == "response.audio.delta":
play_audio(event.delta)
elif event.type == "response.done":
print("AI finished speaking")
Key Concepts
- Audio-native — The model processes audio directly, understanding tone, emotion, and emphasis (not just text transcription)
- Server VAD — OpenAI's server detects when the user starts/stops speaking; no client-side VAD needed
- Interruptions — When the user speaks while AI is talking, the response is automatically interrupted
- Function calling — Same as Chat Completions function calling, but in real-time during voice conversation
Examples
Example 1: User asks to set up openai-realtime
User: "Help me set up openai-realtime for my project"
The agent should:
- Check system requirements and prerequisites
- Install or configure openai-realtime
- Set up initial project structure
- Verify the setup works correctly
Example 2: User asks to build a feature with openai-realtime
User: "Create a dashboard using openai-realtime"
The agent should:
- Scaffold the component or configuration
- Connect to the appropriate data source
- Implement the requested feature
- Test and validate the output
Guidelines
- Server VAD for simplicity — Use
server_vadturn detection; OpenAI handles speech detection, silence, and interruptions - PCM16 format — Use 16-bit PCM at 24kHz for both input and output; minimal encoding overhead
- Short instructions — Keep system instructions concise; the model processes them with every turn
- Function calls for actions — Use tools for bookings, lookups, and transfers; the model speaks the result naturally
- Input transcription — Enable
input_audio_transcriptionfor logging and analytics; small additional cost - Silence threshold tuning — 500ms silence_duration for responsive agents; 1000ms for dictation (avoids mid-sentence cuts)
- Voice selection —
novafor friendly female,onyxfor authoritative male,alloyfor neutral; test with your use case - Cost awareness — Realtime API costs ~$0.06/min input + $0.24/min output audio; use for high-value interactions (sales, support), not bulk processing
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 OpenAI Realtime API 的完整开发指南,具有明确的技术实用价值
- 面向开发者构建语音助手、实时对话等实际应用场景
- 包含 WebSocket 和 Python SDK 两种实现方式,适用性广泛
Highlights
- description 明确描述适用场景,触发词覆盖完整
- 边界清晰,准确描述实时语音对话、WebSocket 音频流等核心功能
Highlights
- 结构清晰完整,包含 Overview、Instructions、Key Concepts、Examples、Guidelines
- frontmatter 完整,包含必要的元数据信息
- 提供详细的代码示例和最佳实践指南
Highlights
- 提供完整的 WebSocket 连接和事件处理示例
- 包含函数调用处理机制和结果返回逻辑
- 工具和参数定义清晰,执行流程完整
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.