Gemini Live API
Gemini Live streams audio in and audio out over a single WebSocket. BeatAPI serves Google’s Gemini Live protocol (BidiGenerateContent) unchanged, so a client written for the Gemini Live API works once it points at BeatAPI and sends a BeatAPI key.
Endpoint
wss://api.beatapi.io/v1/live is the same endpoint; Google’s SDKs use their own path, see Google Gen AI SDK. model is gemini-4-live or gemini-4-live-translate, with or without the models/ prefix. The session runs the model named in the URL: BeatAPI rewrites setup.model to it.
Authorization
Send your BeatAPI API key in one of three ways:
Authorization: Bearer <BEATAPI_API_KEY>x-goog-api-key: <BEATAPI_API_KEY>- the
keyquery parameter:wss://api.beatapi.io/v1beta/live?model=gemini-4-live&key=<BEATAPI_API_KEY>
Browsers cannot set headers on a WebSocket, which is what the query parameter is for. A URL can end up in proxy and browser logs, so keep permanent keys on your server and open sessions from there. An invalid key is refused with HTTP 401 before the WebSocket opens.
Google Gen AI SDK
Google’s own SDKs connect natively: set their base URL to https://api.beatapi.io and pass a BeatAPI key as the API key. Session code written for the Gemini API needs no other change. The SDKs open wss://api.beatapi.io/ws/google.ai.generativelanguage.v1.GenerativeService.BidiGenerateContent (the v1alpha and v1beta forms work too) and name the model in setup; BeatAPI routes on that model. Tested with google-genai 3.7.0 for Python and @google/genai 3.7.0 for Node.js.
Send audio as a stream of small chunks, about 100 ms each, as it is recorded. A whole recording sent as one message can stall the session.
Session flow
Every message is one JSON object in a text frame.
- Connect, then send
setupas the first message. Nothing else is accepted before it. - Wait for
setupComplete. - Stream input with
realtimeInput(audio chunks, video frames, text), or send whole turns withclientContent. Answer function calls withtoolResponse. - Read
serverContent:modelTurncarries audio (inlineData) and text parts,inputTranscriptionandoutputTranscriptioncarry the subtitles, andturnCompleteends an answer. Messages may also carryusageMetadata. - Close the WebSocket when you are done. The session is billed when it closes.
Audio in is 16-bit little-endian PCM, 16 kHz, mono (audio/pcm;rate=16000), base64-encoded. Audio out is 16-bit PCM at 24 kHz.
Voice conversation
Leave out thinkingConfig for the fastest answers. Then send audio as it is recorded, and mark the end of a spoken question:
To ask about a picture, send it first: {"realtimeInput": {"video": {"mimeType": "image/jpeg", "data": "<base64 JPEG>"}}}.
Live translation
targetLanguageCode is the language to speak back, for example zh or en. Then stream speech with realtimeInput.audio. Translation is continuous: it may never send turnComplete, so close the session when the speaker is done.
Python example
The script streams a 16 kHz mono WAV file into the session in 100 ms chunks and prints both subtitles. Install websockets first (pip install websockets).
Pricing
Billed per token on the usage each session reports, at 75% of Google’s list price. Audio is 25 tokens per second.
A session is charged once, when it closes. It cannot outspend your account: when its running cost passes the balance the session started with, BeatAPI closes it with code 1008 and reason insufficient balance; the usage up to that point is billed.
Close codes
Limits
- One WebSocket is one session. Reconnecting starts a new session:
sessionResumptionhandles are passed through but are not guaranteed to resume on another connection. - There is no plain HTTP or SSE form of these models; use the WebSocket.

