---
name: "openai-realtime-voice-webrtc"
description: "Build ultra-low-latency bidirectional voice agents with OpenAI Realtime API."
metadata:
  author: "OpenAI"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "connect to openai realtime api"
  - "stream audio to realtime api"
  - "handle realtime vad events"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# OpenAI Realtime API WebRTC & Audio Sessions

Implements OpenAI Realtime API (WebSocket / WebRTC): session.update, conversation.item.create, response.create, audio input/output streaming, and voice activity detection (VAD).

## When to Invoke
Invoke this skill whenever you need to:
- connect to openai realtime api
- stream audio to realtime api
- handle realtime vad events

## Execution SOP & Rules
1. Establish ephemeral session tokens via backend server to protect primary OpenAI API keys.
2. Configure audio format as PCM16 (24kHz) for optimal clarity and low transport latency.
3. Listen for input_audio_buffer.speech_started events to instantly cut off model audio playback.
4. Submit function call results promptly to avoid pausing the conversational audio flow.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
