Realtime API
OpenAI Realtime over WebSocket (ADR 0104).
POST /v1/realtime/client_secrets
Section titled “POST /v1/realtime/client_secrets”POST /v1/realtime/client_secrets · operation createRealtimeClientSecret
Requires realtime_client_secrets and route:realtime (ADR 0114). Issues a short-lived gateway token bound to one realtime model and to the calling key, for a browser to open /v1/realtime: send it in Sec-WebSocket-Protocol as openai-insecure-api-key.<value> together with realtime. Unlike OpenAI’s client secret it is accepted only by this gateway, so the session keeps metering, quotas, logs and panic, and revoking the key invalidates it. Session settings (instructions, voice) are sent by the client with session.update after connecting. A JWT caller or an ephemeral token cannot issue one.
Authentication: bearerAuth
Request body (required)
application/json: objectexpires_after(object)anchor(string, one of"created_at")seconds(integer, default600, min 10, max 7200)
session(object, required)type(string, one of"realtime")model(string, required)
Responses
| Status | Description | Body |
|---|---|---|
200 |
Ephemeral token | application/json: object |
400 |
session.model missing or expires_after out of range | — |
401 |
Missing or invalid key | — |
403 |
Scope forbidden, or an ephemeral token tried to issue another | — |
404 |
Feature disabled or unknown realtime model for this key | — |
422 |
JWT callers cannot issue client secrets | — |
Response 200 fields:
application/json: objectvalue(string, required) — ek_gw1.…expires_at(integer, required)session(object, required)
GET /v1/realtime
Section titled “GET /v1/realtime”GET /v1/realtime · operation realtimeSession
WebSocket upgrade (OpenAI Realtime; the official SDK client.realtime.connect works with base_url pointing here). Requires the realtime flag, route:realtime, a model the key may use with the realtime capability, and an OpenAI-compatible provider (OpenAI, Azure OpenAI v1). Key, RPM, alias, capability, quota storage and the key’s concurrent session limit (realtime.max_sessions_per_key, shared by every replica through a PostgreSQL lease) are checked before the upgrade; the caller’s Authorization, cookies, subprotocols and compression offer are removed and the provider credential is set by the gateway. After the upgrade every message is relayed whole, and each response is admitted on its own like an HTTP request: RPM, then the budget/TPM reservation, then the durable receipt, on the client’s response.create (a refusal drops it and sends an error event with code budget_exceeded, tpm_exceeded, tpd_exceeded, rate_limit_exceeded, quota_unavailable or session_closing; the session stays open) or on response.created for a response the provider starts itself (a refusal sends response.cancel upstream). response.done settles the reservation with the reported usage, text and audio priced separately; a response in flight when the session ends keeps its reservation and its receipt becomes indeterminate. With a limit in force, frames the gateway cannot read close the session with 1011. With realtime_client_secrets, a browser authenticates with an ephemeral token in Sec-WebSocket-Protocol (openai-insecure-api-key.<token>) and the gateway selects the realtime subprotocol; a long-lived key is never accepted there. No fallback after the upgrade; sessions end after realtime.max_session (30 minutes by default) or on drain with 1001, after the response in flight finishes or a 5 s grace.
Authentication: bearerAuth
Parameters
| Name | In | Type | Description |
|---|---|---|---|
model |
query | string, required |
Responses
| Status | Description | Body |
|---|---|---|
101 |
Switching Protocols; WebSocket session with the provider | — |
400 |
Not a WebSocket upgrade, or model missing | — |
401 |
Missing or invalid key | — |
403 |
scope_forbidden or model_forbidden | — |
404 |
Feature disabled or unknown model | — |
422 |
capability_unsupported (model without the realtime capability or provider not OpenAI-compatible), or quota_profile_unsupported (a budget applies and the model’s approved rate has no audio prices) | — |
429 |
rate_limit_exceeded (the key’s RPM; the upgrade counts once) or realtime_session_limit (the key holds its maximum of concurrent sessions); Retry-After in seconds | — |
502 |
Provider unavailable | — |
503 |
overloaded (no inference slot), quota_unavailable, durable_usage_unavailable or realtime_session_limit_unavailable; the provider was not called | — |