Skip to Content
Launching the open-source gateway

Realtime

Run voice and text sessions over WebSocket with OpenAI Realtime, OpenAI Live, Gemini Live and Mistral.

Realtime sessions are long-lived WebSocket connections for voice and text, such as wss://gateway.respan.ai/v1/realtime?model=gpt-realtime. The gateway serves four realtime protocols, listed under Protocols, and translates between them. See All API formats.

Quickstart

Python
import asyncio import os from openai import AsyncOpenAI async def main(): client = AsyncOpenAI(base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"]) async with client.realtime.connect(model="gpt-realtime") as connection: await connection.session.update(session={"type": "realtime", "output_modalities": ["text"]}) await connection.conversation.item.create( item={"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Say hello."}]} ) await connection.response.create() async for event in connection: if event.type == "response.output_text.delta": print(event.delta, end="", flush=True) elif event.type == "response.done": break asyncio.run(main())

Respan parameters work here as on chat: see Respan parameters. A WebSocket has no request body, so send them base64-encoded in the x-data-respan-params header when you open the session.

Models and providers

Sessions are routed to OpenAI, Gemini or Mistral. Any protocol can reach any of them, so an OpenAI Realtime client can talk to a Gemini Live model and the other way round. The session’s model is routed like a chat model, trying its attempts in turn.

To pick a model, filter by output type realtime or input type audio on the model catalog , or read Models.

Realtime sessions are not redacted, so an organization with PII redaction on is refused.

Protocols

ProtocolWebSocket URLModel
OpenAI Realtimewss://gateway.respan.ai/v1/realtime?model=...?model=, required
OpenAI Livewss://gateway.respan.ai/v1/live/sessionsgpt-live-1 by default
Gemini Livewss://gateway.respan.ai/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent?model=...?model=, required
Mistral realtime transcriptionwss://gateway.respan.ai/v1/audio/transcriptions/realtime?model=...?model=, required. Transcription only.

?model= is required on every URL except OpenAI Live: the gateway routes the session from it before any message arrives.

Gemini Live

The google-genai SDK names the model only in its setup message, which arrives after the session is routed. Point your client at the full URL with ?model= set.

Gemini fixes its setup when the session starts, so a session.update that changes it closes the session with code 1008. See OSS realtime formats for other translation details.

Mistral realtime transcription

Mistral’s realtime endpoint only transcribes. An OpenAI Realtime transcription session can be answered by a Mistral model, and a Mistral client can transcribe with OpenAI or Gemini models. A conversation session sent to Mistral is refused.

Authentication

Send your Respan API key in any one of these:

WhereForm
Authorization headerBearer YOUR_RESPAN_API_KEY
WebSocket subprotocolopenai-insecure-api-key.YOUR_RESPAN_API_KEY
x-goog-api-key headerYOUR_RESPAN_API_KEY
Query string?key=YOUR_RESPAN_API_KEY

Browsers can’t set headers on a WebSocket, so a browser client uses the subprotocol or the query string. Either exposes the key to the page, so use a key with tight limits.

Session limits

Open sessions are capped at 10 per API key, 50 per organization and 500 per gateway server. A handshake over a cap is refused with 429 realtime_session_limit and writes no row. When a gateway server shuts down, it closes its sessions with code 1001.

Pricing and logs

  • A session is charged and logged once it ends, as one streamed chat row priced from the provider’s usage reports, with audio at the model’s audio rates. Its messages are the conversation.
  • If a response was cut off when the session ended, its usage is estimated and the row is marked is_token_count_estimated.
  • A handshake refused before the session opens (400, 403, 404) writes a failed row.
  • On Respan’s credits, the model must state a token price and both audio rates, or the handshake is refused with 403 model_unpriced. The session passes chat’s checks at the handshake.
  • On Respan’s credits, each response is held before it runs. A response your credits can’t cover closes the session with code 1008 insufficient_credits, and so does spending past the customer’s budget.
  • When your client closes, responses still running are cancelled and their usage is read for up to 3 seconds. A response asked for and never seen is charged an estimate.