---
title: "Realtime and WebSocket"
description: "Open voice and text sessions over WebSocket on wss://gateway.respan.ai: OpenAI Realtime, Gemini Live, and Responses WebSocket mode."
---

Realtime sessions are long-lived WebSocket connections, so they have no request and response schema to document as an operation. The gateway serves these protocols on `wss://gateway.respan.ai` and translates between them, so any protocol can reach any realtime model in the catalog.

## Endpoints

| Protocol | WebSocket URL | Model |
| --- | --- | --- |
| OpenAI Realtime | `wss://gateway.respan.ai/v1/realtime?model={model}` | `?model=`, required |
| OpenAI Live | `wss://gateway.respan.ai/v1/live/sessions` | `gpt-live-1` by default |
| Gemini Live | `wss://gateway.respan.ai/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent?model={model}` | `?model=`, required |
| Mistral realtime transcription | `wss://gateway.respan.ai/v1/audio/transcriptions/realtime?model={model}` | `?model=`, required. Transcription only. |
| Responses WebSocket mode | `wss://gateway.respan.ai/v1/responses` | Set per `response.create` |

The gateway routes a session from `?model=` before any message arrives. Sessions are routed to OpenAI, Gemini, StepFun, EmpirioLabs or xAI, and transcription sessions to Mistral too.

## OpenAI Realtime

Point the OpenAI SDK at `https://gateway.respan.ai` and call `client.realtime.connect(model="gpt-realtime")`. Events are OpenAI's Realtime events, such as `session.update`, `conversation.item.create`, `response.create` and `response.output_text.delta`, whichever provider answers.

## Gemini Live

The google-genai SDK names the model only in its setup message, which arrives after the session is routed, so point it at the full URL with `?model=` set. Gemini fixes its setup when the session starts: a `session.update` that changes it closes the session with code `1008`.

## Responses WebSocket mode

OpenAI's Responses WebSocket mode works on `wss://gateway.respan.ai/v1/responses`. Each `response.create` you send runs as an ordinary streamed Responses request, so every turn is routed, logged and billed on its own, on any provider, and its events come back as text frames. Every turn needs a valid key, read from the upgrade's headers; a turn without one, or a failed turn, gets an `error` event and the socket stays open. A socket lasts at most 60 minutes.

## Authentication

Send your Respan API key in any one of these:

| Where | Form |
| --- | --- |
| `Authorization` header | `Bearer YOUR_RESPAN_API_KEY` |
| WebSocket subprotocol | `openai-insecure-api-key.YOUR_RESPAN_API_KEY` |
| `x-goog-api-key` header | `YOUR_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](/docs/ai-gateway/routing/limits). Respan parameters go base64-encoded in the `x-data-respan-params` header when you open the session.

## Limits and billing

- 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`.
- A session is logged and charged once it ends, as one streamed `chat` row priced from the provider's usage, with audio at the model's audio rates.
- On Respan's credits, a model without a token price and both audio rates is refused at the handshake with `403 model_unpriced`, and a response your credits can't cover closes the session with code `1008 insufficient_credits`.
- Realtime sessions are not redacted, so an organization with PII redaction on is refused.

See [Realtime](/docs/ai-gateway/modalities/realtime) for full examples.
