openai-realtime
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.
Best use case
openai-realtime is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using openai-realtime should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/openai-realtime/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How openai-realtime Compares
| Feature / Agent | openai-realtime | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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
```typescript
// 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
```python
# 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:
1. Check system requirements and prerequisites
2. Install or configure openai-realtime
3. Set up initial project structure
4. 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:
1. Scaffold the component or configuration
2. Connect to the appropriate data source
3. Implement the requested feature
4. Test and validate the output
## Guidelines
1. **Server VAD for simplicity** — Use `server_vad` turn detection; OpenAI handles speech detection, silence, and interruptions
2. **PCM16 format** — Use 16-bit PCM at 24kHz for both input and output; minimal encoding overhead
3. **Short instructions** — Keep system instructions concise; the model processes them with every turn
4. **Function calls for actions** — Use tools for bookings, lookups, and transfers; the model speaks the result naturally
5. **Input transcription** — Enable `input_audio_transcription` for logging and analytics; small additional cost
6. **Silence threshold tuning** — 500ms silence_duration for responsive agents; 1000ms for dictation (avoids mid-sentence cuts)
7. **Voice selection** — `nova` for friendly female, `onyx` for authoritative male, `alloy` for neutral; test with your use case
8. **Cost awareness** — Realtime API costs ~$0.06/min input + $0.24/min output audio; use for high-value interactions (sales, support), not bulk processingRelated Skills
realtime-database
When the user needs to design database schemas and queries optimized for real-time applications. Use when the user mentions "chat database," "message storage," "real-time sync," "message history," "unread count," "cursor pagination," "event sourcing," or "live data." Handles schema design for messaging, activity feeds, notifications, and collaborative apps with efficient pagination and sync. For WebSocket transport, see websocket-builder.
realtime-analytics
Build real-time analytics pipelines from scratch. Use when someone asks to "set up analytics", "build a dashboard", "track events in real time", "ClickHouse analytics", "event ingestion pipeline", or "live metrics". Covers event schema design, ingestion services with batching, ClickHouse table optimization, aggregation queries, and dashboard wiring.
openai-sdk
Integrate OpenAI APIs into applications. Use when a user asks to add GPT or ChatGPT to an app, generate text with OpenAI, build a chatbot, use GPT-4 or o1 models, generate embeddings, use function calling, stream chat completions, build AI features, moderate content, generate images with DALL-E, transcribe audio with Whisper API, or integrate any OpenAI model. Covers Chat Completions, Assistants API, function calling, embeddings, streaming, vision, DALL-E, Whisper, and moderation.
openai-codex-cli
You are an expert in OpenAI's Codex CLI, the open-source terminal-based coding agent that reads your codebase, generates and edits code, runs shell commands, and applies changes — all within your terminal. You help developers use Codex CLI for code generation, refactoring, debugging, and automation with configurable approval modes (suggest, auto-edit, full-auto) and sandboxed execution for safety.
openai-agents
You are an expert in the OpenAI Agents SDK (formerly Swarm), the official framework for building multi-agent systems. You help developers create agents with tool calling, guardrails, agent handoffs, streaming, tracing, and MCP integration — building production-grade AI agents that coordinate, delegate tasks, and execute tools with built-in safety controls.
azure-openai
Azure OpenAI Service — OpenAI models (GPT-4o, DALL-E 3, Whisper) on Azure infrastructure. Use when deploying OpenAI models with enterprise compliance (GDPR, HIPAA, SOC2), Azure-native auth via Managed Identity, content filtering, or VNET-isolated deployments. Same OpenAI API, hosted on Azure.
zustand
You are an expert in Zustand, the small, fast, and scalable state management library for React. You help developers manage global state without boilerplate using Zustand's hook-based stores, selectors for performance, middleware (persist, devtools, immer), computed values, and async actions — replacing Redux complexity with a simple, un-opinionated API in under 1KB.
zoho
Integrate and automate Zoho products. Use when a user asks to work with Zoho CRM, Zoho Books, Zoho Desk, Zoho Projects, Zoho Mail, or Zoho Creator, build custom integrations via Zoho APIs, automate workflows with Deluge scripting, sync data between Zoho apps and external systems, manage leads and deals, automate invoicing, build custom Zoho Creator apps, set up webhooks, or manage Zoho organization settings. Covers Zoho CRM, Books, Desk, Projects, Creator, and cross-product integrations.
zod
You are an expert in Zod, the TypeScript-first schema declaration and validation library. You help developers define schemas that validate data at runtime AND infer TypeScript types at compile time — eliminating the need to write types and validators separately. Used for API input validation, form validation, environment variables, config files, and any data boundary.
zipkin
Deploy and configure Zipkin for distributed tracing and request flow visualization. Use when a user needs to set up trace collection, instrument Java/Spring or other services with Zipkin, analyze service dependencies, or configure storage backends for trace data.
zig
Expert guidance for Zig, the systems programming language focused on performance, safety, and readability. Helps developers write high-performance code with compile-time evaluation, seamless C interop, no hidden control flow, and no garbage collector. Zig is used for game engines, operating systems, networking, and as a C/C++ replacement.
zed
Expert guidance for Zed, the high-performance code editor built in Rust with native collaboration, AI integration, and GPU-accelerated rendering. Helps developers configure Zed, create custom extensions, set up collaborative editing sessions, and integrate AI assistants for productive coding.