Skip to main content
Connect via WebRTC for browser-native, low-latency voice. A WebRTC proxy bridges your peer connection to the same realtime service used by the WebSocket transport, transcoding OPUS ↔ PCM16 and forwarding events transparently.

Endpoint

Authentication

Pass your Inworld API key as a Bearer token. The proxy forwards it to the realtime service.
Keep the API key server-side. Serve it to the browser via a backend endpoint (see examples below).

Flow

  1. Fetch config from your server (API key + ICE servers)
  2. Create RTCPeerConnection with ICE servers
  3. Create data channel oai-events + add microphone track
  4. Create SDP offer → POST it with optional initial session config to /v1/realtime/calls → set SDP answer
  5. Data channel opens → send any later session.update patches → start conversation
Audio flows via RTP tracks (no manual encode/decode). Events flow via data channel using the same JSON schema as WebSocket.

Session config

You can configure the session during signaling or through the data channel:
  • During signaling: include the session object in a JSON or multipart /v1/realtime/calls request. The proxy sends it upstream as an initial session.update before returning the SDP answer. It requires a successful send but does not wait for session.updated.
  • After connection: send session.update through the data channel. Partial updates patch the initial configuration.
For example, a JSON signaling request can opt into OpenAI-style tool continuation:
You can also send the same session fields later as a WebSocket-compatible session.update through the data channel. See Configuring Models for the full breakdown of STT, LLM, and TTS configuration.
providerData carries Inworld-specific extensions to the OpenAI-compatible session shape — STT tuning, TTS segmentation/steering, automatic memory, and more. Most providerData fields are hot-swappable via partial session.update, but a few are read only at session open and ignored afterwards (notably providerData.tts.conversational and providerData.tts.user_turn_mode). See Inworld Realtime API Extensions for the field-by-field reference.

Audio

Unlike WebSocket (manual base64 PCM), WebRTC handles audio natively:
  • Input: browser captures mic and sends OPUS over RTP automatically
  • Output: proxy sends AI audio back as an RTP track — attach to <audio> to play
response.output_audio.delta events are not sent through the data channel — audio is delivered via the RTP track instead.

Text & Responses

Same as WebSocket, but sent through the data channel:

Events

Same event types as WebSocket, received on the data channel.

Option 1: Direct WebRTC

Server — serves the page and a /api/config endpoint that fetches ICE servers and keeps the API key hidden:
Client — full WebRTC flow in the browser:

Option 2: OpenAI Agents SDK

The OpenAI Agents SDK manages the full WebRTC lifecycle — peer connection, SDP exchange, mic, and audio playback:
The server-side /api/config endpoint is identical to Option 1.

WebSocket vs WebRTC

API reference for full event schemas.