wss://api.meshapi.ai/v1/realtime is a WebSocket gateway that proxies OpenAI’s
Realtime API for low-latency, bidirectional speech-to-speech sessions.
rsk_... data-plane token.It’s intended for voice agents, live transcription with response, and any half-duplex / full-duplex audio UX where round-trip latency matters.
Open a WebSocket to wss://api.meshapi.ai/v1/realtime with a model query
parameter, send a session.update, then stream audio chunks via
input_audio_buffer.append events.
Two methods are supported. Both require TLS — ws:// is rejected.
1. Subprotocol header (preferred). Send your key in the Sec-WebSocket-Protocol
header alongside the literal protocol marker:
This matches OpenAI’s upstream auth and keeps the key out of URL logs.
2. Query string fallback. For browsers and tools that can’t customize the
subprotocol cleanly, append ?api_key=<YOUR_RSK_KEY> to the URL. The key is
redacted from server access logs but will appear in client-side history,
so prefer the subprotocol method anywhere you control the runtime.
If both are present, the subprotocol wins.
Mesh is a transparent proxy for OpenAI’s Realtime API. Every event you send and receive is shaped exactly as upstream documents it — Mesh does not rewrite event types, field names, or payloads.
See the OpenAI Realtime API reference for the full event catalog. The most common types you’ll exchange:
The model query parameter is required.
MeshAPI charges OpenAI’s exact rates for realtime models — zero markup, no
surprises. Rates are subject to OpenAI’s pricing changes; consult /v1/models
for the canonical current values.
Per-session usage and cost lands in your existing /v1/usage history and the
dashboard. There is no in-stream cost message on the WebSocket — query
/v1/usage after the session completes.
The /v1/models response indicates which models support realtime and
includes per-million-token rates for text, audio, and cached audio inputs
and outputs. Use these to display estimates in your UI before opening a
session — no need to hard-code rates in the client.
insufficient_quota error.
Top up to reconnect. Partial responses up to the point of disconnect
are still billed.session_token_cap_exceeded error once the cap is reached.Usage events are written to your account’s usage log at session close,
accessible via GET /v1/usage and the dashboard. Sessions that get cut
short (network drop, browser tab close) still bill for the tokens that
were processed. Query /v1/usage for canonical numbers.
session.update ping or keep the audio
buffer flowing.Bearer <key>). If you’re
targeting Safari, use the ?api_key= query fallback or send the key as
Bearer.<key> (dot separator).GET /v1/realtime over plain HTTP returns 426 Upgrade Required.Realtime errors are delivered as a JSON frame
({ "type": "error", "error": { "code", "message" }, "request_id": "..." })
immediately before the WebSocket is closed. Use error.code for
programmatic handling — it is the stable, semantic identifier. The
WebSocket close code that follows is incidental.
error.code referenceIn-band errors during a live session arrive as a regular error event
with the OpenAI-shaped envelope shown above and are not accompanied by a
socket close.
These close codes accompany the JSON error frame on session-terminating
errors. Check error.code for the semantic reason; the close code below
is informational only.