OpenAI officially supports WebRTC / WebSocket / SIP transports and offers next-gen realtime models like
gpt-realtime-2 and gpt-realtime-1.5. The OpenPAI gateway currently centers on WebSocket; whether other transports and models are available is subject to the console / announcements.Connect
Create an ephemeral token
client_secret.value in the response is a short-lived token you can safely send to the browser as a subprotocol.
Event protocol
JSON events are sent and received in both directions over the WebSocket. Key events:Minimal example (Node.js)
Audio format
- Input: PCM 16-bit, 24kHz, mono, base64-encoded.
- Output: likewise PCM 16-bit / 24kHz.
webrtc-adapter, MediaRecorder or ffmpeg.
Tool calling
You can declaretools in session.update; during generation the model may produce response.function_call_arguments.delta events.
You need to execute the tool and return the result via conversation.item.create (type: function_call_output).
Billing
- Audio input / output tokens and text tokens are billed separately, at prices higher than ordinary chat.
- No charge while the connection is held open, but if idle for a long time it’s best to close it proactively.