Skip to main content
The OpenAI Realtime API provides bidirectional, low-latency voice / text streams, for scenarios like voice assistants and live meeting summarization.
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

Pass authentication during the handshake via a subprotocol or a header:
The browser-subprotocol method puts the key on the client — for demos only. In production, create a short-lived token through your own backend.

Create an ephemeral token

The 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.
You can convert using tools like webrtc-adapter, MediaRecorder or ffmpeg.

Tool calling

You can declare tools 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.
See Model pricing for details.