Skip to content
Zabio is in beta: models, prices and features can change. Tell us what breaks at hello@zabio.ai.

Realtime voice

/v1/realtime is a WebSocket for voice sessions: your application streams a user’s speech, the model answers in speech, and either side can interrupt. It speaks OpenAI’s Realtime API, so OpenAI’s SDKs and anything written for wss://api.openai.com/v1/realtime work by changing the address and the key.

wss://api.zabio.ai/v1/realtime?model=gpt-realtime-2.1-mini

Events go through as OpenAI defines them (session.update, input_audio_buffer.append, response.create, response.done and the rest). Zabio changes four things on the way:

  • The model is fixed at the handshake. A session.update that names another model is answered with an error event, code model_change_not_allowed. Open a new session for another model.
  • Only sessions of type realtime. A session.update with type transcription is refused (unsupported_value).
  • A vendor’s error reaches you in Zabio’s words. Error events and failed responses carry a type and a code you can act on, never the vendor’s own text.
  • One event of Zabio’s own, zabio.session.ending, tells you a session is about to end and why. See When a session ends.

The handshake’s answer carries x-zabio-session-id (an id starting with rts_, the one to quote to support) and x-zabio-vendor.

Realtime models are always named: there is no auto for realtime, and a session never falls back to another model. The key needs the chat scope, which keys have by default.

OpenAI’s models, billed per token (USD per million tokens), processed in the United States:

Model Text in Cached in Text out Audio in Audio out
gpt-realtime-2.1 4.00 0.40 24.00 32.00 64.00
gpt-realtime-2.1-mini 0.60 0.06 2.40 10.00 20.00
gpt-realtime-2 4.00 0.40 24.00 32.00 64.00
gpt-realtime-1.5 4.00 0.40 16.00 32.00 64.00
gpt-realtime (retires 2027-01-20) 4.00 0.40 16.00 32.00 64.00
gpt-realtime-mini (retires 2027-01-20) 0.60 0.06 2.40 10.00 20.00

Image input is 5.00 on the large models and 0.80 on the mini models.

xAI’s Grok voice, billed per minute, with no guaranteed processing location:

Model Price (USD per minute)
grok-voice-3.0 0.08
grok-voice-latest 0.08
grok-voice-2.0 0.08

GET /v1/models lists them with zabio.kind set to realtime. xAI serves its voice models on its global endpoint, which commits to no location (see the privacy page).

Send your API key in the Authorization header, as on every other endpoint. With OpenAI’s Python SDK (install it with its realtime extra, pip install 'openai[realtime]'):

from openai import OpenAI
client = OpenAI(api_key="insert your zabio.ai key here", base_url="https://api.zabio.ai/v1")
with client.realtime.connect(model="gpt-realtime-2.1-mini") as conn:
conn.session.update(session={"type": "realtime", "output_modalities": ["text"]})
conn.conversation.item.create(item={
"type": "message",
"role": "user",
"content": [{"type": "input_text", "text": "Say hello in five words."}],
})
conn.response.create()
for event in conn:
if event.type == "response.done":
print(event.response.status, event.response.usage)
break

Without an SDK, open the WebSocket with the header Authorization: Bearer <your key> and exchange the same events as JSON text messages.

A browser cannot keep an API key safe, and it cannot set a header on a WebSocket. So your server mints a short-lived client secret with its API key, hands it to the page, and the page opens the session with the secret.

1. Your server mints a secret.

Terminal window
curl https://api.zabio.ai/v1/realtime/client_secrets \
-H "Authorization: Bearer insert your zabio.ai key here" \
-H "Content-Type: application/json" \
-d '{
"expires_after": {"anchor": "created_at", "seconds": 600},
"session": {
"type": "realtime",
"model": "gpt-realtime-2.1-mini",
"instructions": "You are a friendly assistant for a bakery."
}
}'
{
"value": "zb_ek_...",
"expires_at": 1795000000,
"session": {"type": "realtime", "model": "gpt-realtime-2.1-mini", "instructions": "You are a friendly assistant for a bakery."}
}
Field Type Required Notes
session object yes the session’s settings, as in a session.update. session.model is required and names a realtime model
expires_after.seconds integer no how long the secret can open sessions: 10 to 7,200 seconds, 600 when absent
expires_after.anchor string no only created_at

2. The page opens the session with it. The secret goes in the WebSocket subprotocol, the way OpenAI’s SDK sends it from a browser:

const ws = new WebSocket("wss://api.zabio.ai/v1/realtime", [
"realtime",
"openai-insecure-api-key." + secret,
]);

What a client secret is:

  • It stands in for the key that minted it, for one model. The session is that key’s: its organization pays, and its rate limit, spend limits, concurrent sessions and IP rules apply. The model is the one in session.model; the page does not need ?model=, and naming another is refused (model_mismatch).
  • The settings your server registered come first. The model receives them before anything the page sends. The page can still send its own session.update, so do not treat the registered instructions as a lock on what a user can ask.
  • It opens sessions until it expires, and a session outlives it: a secret that expires in 60 seconds can start a session that runs for an hour.
  • It cannot be revoked on its own. It ends when it expires, or when the key that minted it is revoked. Keep its life short.
  • It works on /v1/realtime only. No other endpoint takes it.
  • An API key in the subprotocol is refused with 401. Never put an API key in a page.

A client that can set a header (a mobile app’s backend, a server-side SDK) may also send the secret as Authorization: Bearer zb_ek_....

Prices are provider list prices; the plan fee applies on top (see Billing).

OpenAI’s models are billed per response. Each time a response ends (response.done), Zabio bills the tokens it used, by kind: text in, audio in, image in, cached input, text out and audio out, each at the model’s price for it. A response you interrupt is billed for what was generated before the interruption. If you turn on input transcription (audio.input.transcription in the session), each transcript is billed on its own line at the transcription model’s price; a transcription model without a price on Zabio is refused when you name it. A transcript the vendor is still finishing when the session closes is billed too: Zabio waits up to 3 seconds for it before it closes the vendor’s side.

xAI’s Grok voice is billed per minute, 0.08 USD a minute. A Grok voice session is billed per second from the moment it opens until it closes, whether or not anything is said: close a session you are not using.

Each billed line is a call in your usage, so a session of ten responses shows ten calls that add up to its cost.

Credit is set aside as the session runs. When a session opens, Zabio holds enough credit for about five minutes of it at the model’s prices, and keeps the hold at that level as the session is billed. The hold is not a charge: what is not used returns when the session ends. If your balance cannot cover the first five minutes, the handshake answers 402 insufficient_credits. If it runs out during a session, see below.

On your own vendor key, a session on a model whose vendor you hold a key for runs on that key and is not billed by Zabio (see Your own vendor keys).

Limit Value What you get past it
Sessions open at once, per API key 10 429 concurrent_sessions_limit at the handshake
Longest session 60 minutes an error event with code session_expired, then the close
One event 21 MiB the session is closed
Requests per minute your key’s limit; opening a session and minting a secret each count as one request 429 rate_limit_exceeded

Your key’s and your organization’s spend limits apply during a session, not only when it opens.

A session ends when you close it, when the model’s vendor closes it, or for one of the reasons below. Before Zabio closes a session it sends an error event in OpenAI’s shape with the code, then closes the WebSocket with the close code and the same word as its reason.

Code Close code Why
insufficient_credits 1008 your balance does not cover more of the session
quota_exceeded 1008 a spend limit of the key, its member or the organization was reached
session_expired 1008 the session reached 60 minutes
invalid_api_key 1008 the key was revoked or expired during the session
upstream_error 1011 the model’s vendor dropped the session
server_shutdown 1012 the server is restarting; connect again
realtime_unavailable 1012 realtime sessions were turned off

When Zabio knows in advance, it tells you first:

{"type": "zabio.session.ending", "reason": "insufficient_credits", "seconds_left": 42}

reason is insufficient_credits (the balance covers only seconds_left more seconds at the session’s recent rate; a session that spends faster ends sooner) or shutdown (the server stops in seconds_left seconds). Finish the turn, tell the user, and open a new session when you can.

Releases do not cut sessions. When Zabio deploys a new version, sessions that are open stay on the version they started on until they end. Only new sessions go to the new version.

Nothing of a session’s content: no audio, no transcript, no instructions and no tool call, whether or not your key has body logging on. Zabio keeps what it needs to bill and to show your usage: the session’s id, its model, when it opened and closed and why, and each billed line’s token counts, seconds and cost.

The session settings a server registers with a client secret are kept encrypted for that secret’s life (at most 2 hours) and then deleted, and nothing else.

The model’s vendor, OpenAI or xAI, receives the audio to answer it; where each processes it is on the privacy page.

  • WebRTC and SIP. The WebSocket is the only transport.
  • Sessions of type transcription.
  • Google’s Gemini Live and OpenAI’s GPT-Live models.
  • auto: a session always names its model.
  • Stored conversations: a realtime session cannot continue a /v1/responses conversation, and nothing of it is kept to continue later.