Google’s Gemini Live API lets your app hold a real-time voice or video conversation with Gemini over a single WebSocket. On 2 December 2026 Google released Gemini 4 Live, which starts speaking in about 0.39 seconds and gives you over 2,000 preset voices.
In this tutorial I walk you through the current Live models, working Python code with the google-genai SDK, voices, session limits, ephemeral tokens, tool use, prices and the errors you are most likely to hit.
- Model to use:
gemini-4-live(preview, released 2 Dec 2026).gemini-3.8-liveis the stable fallback. - SDK:
pip install google-genai(I checked version 3.7.0, released 2 Dec 2026), thenclient.aio.live.connect(). - Audio: send 16-bit PCM at 16 kHz, receive 16-bit PCM at 24 kHz.
- Limits: 15 minutes for audio-only sessions, 2 minutes with video, and about 10 minutes per connection unless you turn on compression and resumption.
- Price: $0.005 per minute of audio in and $0.018 per minute of audio out on the paid tier. The free tier is free of charge.
- Browsers and phones: never ship your API key. Mint a short-lived ephemeral token on your server instead.
What the Gemini Live API Is (and When to Use It)
The normal Gemini API works like a letter: you send a request and wait for the full reply. The Live API works like a phone call. It keeps a stateful WebSocket (WSS) connection open, so audio, video frames and text flow both ways at the same time.
Because the model hears and speaks natively, you do not need to glue a speech-to-text model, an LLM and a text-to-speech model together. Users can also cut the model off mid-sentence, which Google calls barge-in.
Good fits for the Live API
- Voice agents: customer support lines, booking bots and in-app assistants.
- Tutors and coaches: language practice, interview practice, homework help.
- Camera or screen helpers: the model can watch frames (up to 1 per second) and talk about what it sees.
- Live transcription and translation: dedicated Live Translate and Transcribe Live models exist for these jobs.
When the normal API is better
- Batch jobs: summarising files or long documents. See my Gemini API Python tutorial.
- One-off narration: a plain text-to-speech model is simpler when nobody talks back.
- Strict JSON output: native audio Live models only return the AUDIO modality. You get text through transcription, not as the main output.
Note: If you already use OpenAI’s version of this, my OpenAI Realtime API guide covers the same idea. The concepts carry over, but field names differ.
Current Live Models (December 2026)
Google’s docs and pricing page list these Live API models as of 3 December 2026. Gemini 4 Live is the newest, and the docs now use it in every code sample.
| Model ID | Status | Best for | Thinking |
|---|---|---|---|
gemini-4-live |
Preview (2 Dec 2026) | New voice agents, fastest first reply, 2,000+ voices, proactive video | thinking_level: MINIMAL (default), LOW, MEDIUM, HIGH |
gemini-3.8-live |
Stable | Production apps that need a non-preview model | Built in. Do not send thinking_level |
gemini-3.8-live-extended-thinking |
Stable | Harder reasoning in voice chats | low, medium, high |
gemini-4-live-translate |
New (2 Dec 2026) | Speech-to-speech translation in 70+ languages | n/a |
gemini-3.5-transcribe-live |
Stable | Low-latency speech-to-text | n/a |
gemini-3.1-flash-live-preview |
Legacy preview | Old projects only. Google recommends moving off it | minimal, low, medium, high |
The Gemini 4 audio model card lists a 128K token context window, a 64K output limit and a January 2025 knowledge cutoff. Google says Gemini 4 Live answers in 0.39 seconds, against over one second for Gemini 3.8 Live.
gemini-4-live. If you need a model that is not in preview for a launch, use gemini-3.8-live. Both cost the same per token.Prerequisites and Setup
You need very little to get going. The Live API is part of the regular Gemini Developer API, so the same key works.
- Python 3.11 or newer: google-genai 3.7.0 requires it, and every Live call uses the async client.
- A Gemini API key: free from Google AI Studio.
- Headphones: if you play audio live from speakers, the mic can pick up the model’s own voice and interrupt it.
- Create an API key. Open Google AI Studio, click Get API key, and create a key in a new or existing project.
- Store the key in an environment variable. On macOS or Linux run
export GEMINI_API_KEY="your-key". On Windows PowerShell run$env:GEMINI_API_KEY="your-key". - Create a virtual environment. Run
python -m venv .venv, then activate it. - Install the SDK. Run
pip install -U google-genai. This tutorial was checked against version 3.7.0. - Try the voice in the browser first. Open aistudio.google.com/live, pick Gemini 4 Live and talk to it. This confirms your account and region work before you write code.
- Run Example 1 below. If you hear a reply in
reply.wav, your setup is done.
Tip: The SDK reads GOOGLE_API_KEY first and GEMINI_API_KEY second. If both are set to different keys, you may be billed on the wrong project, so keep only one.
Example 1: Text In, Spoken Audio Out
This first script opens a session, sends one text message, and saves the spoken reply as a WAV file. It also prints a live transcript of what the model says.
import asyncio
import wave
from google import genai
from google.genai import types
# Reads GEMINI_API_KEY from the environment. Never hard-code keys.
client = genai.Client(http_options={"api_version": "v1beta"})
MODEL = "gemini-4-live"
config = types.LiveConnectConfig(
response_modalities=["AUDIO"],
system_instruction="You are a friendly tutor. Keep answers short.",
speech_config=types.SpeechConfig(
voice_config=types.VoiceConfig(
prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name="Kore")
)
),
output_audio_transcription=types.AudioTranscriptionConfig(),
)
async def main():
async with client.aio.live.connect(model=MODEL, config=config) as session:
await session.send_realtime_input(text="Explain WebSockets in two sentences.")
with wave.open("reply.wav", "wb") as wf:
wf.setnchannels(1) # mono
wf.setsampwidth(2) # 16-bit samples
wf.setframerate(24000) # Live API output is 24 kHz
# receive() yields messages until the model's turn is complete
async for msg in session.receive():
sc = msg.server_content
if not sc:
continue
if sc.model_turn:
for part in sc.model_turn.parts:
if part.inline_data and part.inline_data.data:
wf.writeframes(part.inline_data.data)
if sc.output_transcription and sc.output_transcription.text:
print(sc.output_transcription.text, end="", flush=True)
print("\nSaved reply.wav")
asyncio.run(main())
What each part does
api_version: v1beta: the docs use v1beta for the Live API, and ephemeral tokens only work on v1beta.response_modalities=["AUDIO"]: native audio models only support audio output. Ask for transcription if you also want text.send_realtime_input(text=...): sends text into the live stream. Usesend_client_contentinstead when you want to seed earlier turns as history.- One server event, many parts: on Gemini 4 Live a single message can hold audio and transcript parts together, so loop over every part.
Example 2: Send Audio and Get Transcripts
Now let’s send speech instead of text. The Live API expects raw 16-bit little-endian PCM. 16 kHz is the native rate, but the API resamples other rates if you label them in the MIME type.
This script reads a 16 kHz mono WAV file, streams it in small chunks like a microphone would, and prints both transcripts.
import asyncio
import wave
from google import genai
from google.genai import types
client = genai.Client(http_options={"api_version": "v1beta"})
MODEL = "gemini-4-live"
config = types.LiveConnectConfig(
response_modalities=["AUDIO"],
input_audio_transcription=types.AudioTranscriptionConfig(),
output_audio_transcription=types.AudioTranscriptionConfig(),
)
CHUNK_FRAMES = 1600 # 100 ms of audio at 16 kHz
async def main():
async with client.aio.live.connect(model=MODEL, config=config) as session:
with wave.open("question_16k_mono.wav", "rb") as wf:
rate = wf.getframerate()
while True:
chunk = wf.readframes(CHUNK_FRAMES)
if not chunk:
break
await session.send_realtime_input(
audio=types.Blob(data=chunk, mime_type=f"audio/pcm;rate={rate}")
)
await asyncio.sleep(0.1) # pace it like a real mic
# Tell the server the stream paused so it flushes buffered audio
await session.send_realtime_input(audio_stream_end=True)
async for msg in session.receive():
sc = msg.server_content
if not sc:
continue
if sc.input_transcription and sc.input_transcription.text:
print("You said:", sc.input_transcription.text)
if sc.output_transcription and sc.output_transcription.text:
print("Gemini:", sc.output_transcription.text)
if sc.interrupted:
print("(user interrupted, stop playback here)")
asyncio.run(main())
For a real microphone, read frames from a library such as PyAudio or sounddevice and push each buffer through the same send_realtime_input(audio=...) call. Run sending and receiving as two asyncio tasks so the user can talk while the model speaks.
Turn detection (VAD) settings
By default the server detects when the user starts and stops talking. You can tune it under realtime_input_config.automatic_activity_detection.
silence_duration_ms: Google recommends 500 to 800 ms. The server default is about 800 ms. Very low values split sentences into fragments.prefix_padding_ms: audio kept from just before speech starts, so the first syllable is not clipped.start_of_speech_sensitivity/end_of_speech_sensitivity: LOW or HIGH sensitivity values.disabled: True: you then sendactivity_startandactivity_endyourself.
Voices, Languages and Thinking Levels
Gemini 4 Live uses Google’s extended voice library with over 2,000 preset voices. The older 3.8 and 3.1 Live models offer 30 preset voices.
- Pick a voice: set
speech_config.voice_config.prebuilt_voice_config.voice_name, for example"Kore". - List voices in code: the docs show
client.voices.list(type_=["prebuilt"]), or audition them in AI Studio. - Custom cloned voices: only for Tier 3 projects, with verbal consent checks. Designed voices are not supported on Gemini 4 Live.
- Language or accent: set
speech_config.language_codealongside a voice ongemini-4-liveandgemini-3.8-live. The docs list 99 supported languages.
Thinking on Gemini 4 Live
Gemini 4 Live has one endpoint with a dial. Leave thinking_level out (or use MINIMAL) for the fastest replies. Set LOW, MEDIUM or HIGH for background reasoning on multi-step tasks.
config = types.LiveConnectConfig(
response_modalities=["AUDIO"],
thinking_config=types.ThinkingConfig(
thinking_level="MEDIUM",
include_thoughts=True, # optional thought summaries
),
)
Warning: With LOW, MEDIUM or HIGH thinking, turn_complete no longer means the session is idle. Check server_content.interaction_status for IN_PROGRESS or IDLE. Thinking tokens are also billed at the output rate.
Features that changed in the new models
- Affective dialog: removed on Gemini 4 Live and 3.8 Live. Google says to leave
enable_affective_dialogout of your config. - Proactive audio: always on for Gemini 4 Live and 3.8 Live. Sending
proactive_audio: falsereturns an error. - Proactive video: new on Gemini 4 Live and off by default. Turn it on with
proactivity=types.ProactivityConfig(proactive_audio=True, proactive_video=True).
Example 3: Tool Use and Function Calling
The Live API supports function calling and Google Search. Google Maps, code execution and URL context are not supported on any Live model, according to the tools page.

Unlike the normal API, the Live SDK does not run your Python functions for you. You read msg.tool_call, run the function yourself, and send back a FunctionResponse.
import asyncio
from google import genai
from google.genai import types
client = genai.Client(http_options={"api_version": "v1beta"})
MODEL = "gemini-4-live"
get_order_status = types.FunctionDeclaration(
name="get_order_status",
description="Look up the delivery status of an order by its ID.",
parameters={
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
behavior="BLOCKING", # wait for the result (default on 4 Live is NON_BLOCKING)
)
config = types.LiveConnectConfig(
response_modalities=["AUDIO"],
output_audio_transcription=types.AudioTranscriptionConfig(),
tools=[
types.Tool(function_declarations=[get_order_status]),
types.Tool(google_search=types.GoogleSearch()),
],
)
def lookup(order_id):
# Replace with a real database call
return {"order_id": order_id, "status": "out for delivery", "eta": "today 6 pm"}
async def main():
async with client.aio.live.connect(model=MODEL, config=config) as session:
await session.send_realtime_input(text="Where is my order A-1042?")
# One loop handles the tool call and then the spoken answer.
# receive() stops when the model's turn is complete.
async for msg in session.receive():
if msg.tool_call:
responses = []
for fc in msg.tool_call.function_calls:
result = lookup(**fc.args)
responses.append(
types.FunctionResponse(id=fc.id, name=fc.name, response=result)
)
await session.send_tool_response(function_responses=responses)
continue
sc = msg.server_content
if sc and sc.output_transcription and sc.output_transcription.text:
print(sc.output_transcription.text, end="", flush=True)
asyncio.run(main())
Blocking vs non-blocking calls
- NON_BLOCKING (default on 4 Live and 3.8 Live): the model keeps talking while your function runs.
- BLOCKING: the conversation pauses until you reply. On Gemini 4 Live this only works with default or MINIMAL thinking.
- Scheduling for non-blocking replies: set
schedulingon theFunctionResponseto INTERRUPT, WHEN_IDLE or SILENT. - Extended thinking model:
gemini-3.8-live-extended-thinkingonly supports non-blocking calls.
If the user interrupts, the server drops pending calls and sends a tool_call_cancellation with the cancelled IDs. For more patterns, see my Gemini function calling tutorial.
Session Limits, Compression and Resumption
Live sessions have hard time limits. If you plan for them early, users never notice a drop.
| Limit | Value | How to get around it |
|---|---|---|
| Audio-only session | 15 minutes | Context window compression |
| Audio + video session | 2 minutes | Context window compression |
| One WebSocket connection | About 10 minutes | Session resumption on a new connection |
| Resumption handle | Valid 2 hours after the session ends | Store the latest handle |
| Context window | 128K tokens (native audio models) | Sliding window compression |
| Video input | Max 1 frame per second, JPEG or PNG | Lower media_resolution to save tokens |
Here is a config that turns on both fixes. Before a connection closes, the server sends a go_away message with time_left, so you can reconnect with the saved handle.
from google.genai import types
latest_handle = None # save this somewhere durable in a real app
config = types.LiveConnectConfig(
response_modalities=["AUDIO"],
context_window_compression=types.ContextWindowCompressionConfig(
sliding_window=types.SlidingWindow(),
),
session_resumption=types.SessionResumptionConfig(handle=latest_handle),
)
# Inside your receive loop:
# if msg.session_resumption_update and msg.session_resumption_update.resumable:
# latest_handle = msg.session_resumption_update.new_handle
# if msg.go_away:
# print("Reconnect soon, time left:", msg.go_away.time_left)
Tip: Pass handle=None on the very first connection. On every reconnect, pass the newest new_handle you received and the conversation carries on where it stopped.
Example 4: Ephemeral Tokens for Browser and Mobile Apps
If a web or mobile app connects straight to the Live API, anything you ship to the device can be extracted. Ephemeral tokens fix this. Your server mints a token that dies quickly, and the client uses it like an API key.
How the flow works
- The user signs in to your backend. Your own auth is still the real gatekeeper.
- Your backend calls
client.auth_tokens.create(). It uses your real API key, which never leaves the server. - Your backend returns
token.nameto the client. - The client connects with the token as its
apiKey. Audio then flows straight from the device to Gemini, with no proxy hop.
import datetime
from google import genai
client = genai.Client(http_options={"api_version": "v1beta"})
def mint_live_token():
now = datetime.datetime.now(tz=datetime.timezone.utc)
token = client.auth_tokens.create(
config={
"uses": 1, # can start one session
"expire_time": now + datetime.timedelta(minutes=30),
"new_session_expire_time": now + datetime.timedelta(minutes=1),
# Lock the model and config so the client cannot change them
"live_connect_constraints": {
"model": "gemini-4-live",
"config": {
"session_resumption": {},
"response_modalities": ["AUDIO"],
"system_instruction": "You are the support agent for my shop.",
},
},
}
)
return token.name # send this string to the browser or app
if __name__ == "__main__":
print(mint_live_token())
The defaults are 1 minute to start a session and 30 minutes to send messages. With uses: 1 you can still reconnect every 10 minutes through session resumption using the same token.
The same call with curl
This is handy for testing from a terminal. It calls the REST endpoint behind auth_tokens.create.
curl -X POST "https://generativelanguage.googleapis.com/v1beta/auth_tokens" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"uses": 1}'
The JSON reply contains a name field that starts with auth_tokens/. That value is the token. Without the SDK, pass it in an access_token query parameter or an Authorization: Token ... header.
Note: Ephemeral tokens only work with the Live API and only on v1beta. Do not use them for server-to-server calls, where your normal key is already safe.
Live API Pricing With a Worked Example
Google’s pricing page lists the same paid rates for Gemini 4 Live, 3.8 Live, 3.8 Live Extended Thinking and 3.1 Flash Live. The free tier is free of charge, but Google may use free-tier content to improve its products.

| Model | Input (paid, per 1M tokens) | Output (paid, per 1M tokens) |
|---|---|---|
gemini-4-live, gemini-3.8-live, gemini-3.8-live-extended-thinking, gemini-3.1-flash-live-preview |
Text $0.75 Audio $3.00 (about $0.005/min) Image/video $1.00 (about $0.002/min) |
Text $4.50 Audio $12.00 (about $0.018/min), thinking tokens included |
gemini-4-live-translate |
Audio $3.50 (about $0.0053/min) | Audio $21.00 (about $0.0315/min) |
| Google Search grounding (Live models) | 5,000 free requests a month shared across Gemini 3 and newer models, then $14 per 1,000 | |
The 1 December 2026 price change hit Gemini 4 Argon (input doubled to $4.00 and output to $20.00 per 1M tokens). The Live model rows did not change. Some Flash and TTS prices also double on 1 January 2027, so check my Gemini API pricing guide before you budget.
Worked example: a support voice bot
Say each support call lasts 6 minutes. The caller’s mic streams for all 6 minutes, and the bot speaks for about 2.5 minutes of that time.
- Audio in: 6 min x $0.005 = $0.030
- Audio out: 2.5 min x $0.018 = $0.045
- Cost per call: about $0.075
- 1,000 calls a day for 30 days: 30,000 x $0.075 = about $2,250 a month
Add a camera feed and the image/video input adds roughly $0.002 per minute. Higher thinking levels add output tokens on top.
Warning: The per-minute figures are Google’s rounded guides. Your real bill follows token counts, so log msg.usage_metadata from every session and set a budget alert in your Google Cloud billing account.
Rate Limits by Tier
The rate limits page lists tokens per minute (TPM) for gemini-4-live. Requests per minute and per day are not set for this model.
| Tier | How you qualify | gemini-4-live TPM |
|---|---|---|
| Free | Active project or free trial | 65,000 |
| Tier 1 | Linked billing account | 250,000 |
| Tier 2 | $100 paid and 3 days since first payment | 600,000 |
| Tier 3 | $1,000 paid and 30 days since first payment | 15,000,000 |
TPM is shared across all open sessions in a project. If many users talk at once on the free tier, you will hit the cap fast.
Troubleshooting: Common Errors and Fixes
Live API errors usually arrive as a WebSocket close code with a short reason. These are the ones developers report most on Google’s AI forum, with the usual cause.
| Error you see | Likely cause | Fix |
|---|---|---|
1008 “models/… is not found for API version … or is not supported for bidiGenerateContent” |
Typo in the model ID, or a non-Live model such as a Flash model | Use an exact Live ID like gemini-4-live with api_version v1beta |
1008 “Operation is not implemented, or supported, or enabled” |
A feature the model does not support, or the API is not available to your project | Remove unsupported fields (affective dialog, Maps, code execution). Test the model in AI Studio Live |
1007 “Request contains an invalid argument” |
Bad setup: wrong audio MIME type, thinking_level on gemini-3.8-live, or proactive_audio: false |
Send audio/pcm;rate=16000, and only send fields the chosen model supports |
1011 “Internal error” or “The service is currently unavailable” |
Server-side failure or overload, common in new previews | Retry with backoff and session resumption. Fall back to gemini-3.8-live |
1011 mentioning quota or resource exhausted |
TPM cap reached for your tier | Lower concurrency or move up a tier |
| Session ends at 2 or 15 minutes | Session length limit without compression | Add context_window_compression |
| Disconnect after about 10 minutes | Connection lifetime limit | Handle go_away and reconnect with the resumption handle |
| Robotic, too fast or chipmunk audio | Playing 24 kHz output at 16 kHz, or the other way around | Play and save output at 24,000 Hz, mono, 16-bit |
| Model keeps interrupting itself | Speaker audio leaks into the mic | Use headphones or echo cancellation |
ExperimentalWarning about ephemeral tokens being v1alpha only |
An older SDK warning message | Follow the docs: tokens work on v1beta. The warning does not stop the call |
For general Gemini API errors such as 429 and 503 on normal requests, see my Gemini API errors fix guide.
FAQ
Is the Gemini Live API free?
Yes, on the free tier input and output are free of charge, within the free tier’s 65,000 tokens per minute for Gemini 4 Live. Google may use free-tier content to improve its products, so use the paid tier for private data.
What is the model ID for Gemini 4 Live?
Use gemini-4-live. It is in preview since 2 December 2026. The stable alternative is gemini-3.8-live.
Can I get text instead of audio from the Live API?
Native audio Live models only return audio. Turn on output_audio_transcription to get a text transcript of everything the model says.
How long can a Live session last?
Without compression, audio-only sessions last 15 minutes and audio-video sessions 2 minutes. Each connection lasts about 10 minutes, but compression plus session resumption let a conversation run with no fixed end.
Can I use the Live API directly from a browser?
Yes, but use an ephemeral token from your server rather than your API key. Tokens expire quickly (30 minutes by default) and can be locked to one model and config.
Does the Live API support Google Search?
Yes. Google Search grounding and function calling work on all current Live conversation models. Search gets 5,000 free requests a month, then costs $14 per 1,000.
How much does a one-minute voice chat cost?
On the paid tier, one minute of user audio is about $0.005 and one minute of model audio is about $0.018. A minute where both talk about half the time costs roughly a cent or two.
Does the Live API work on Vertex AI?
The Live API also exists on Google Cloud’s Gemini Enterprise Agent Platform (formerly Vertex AI) with the same SDK. Google’s 2 December post only lists AI Studio, Antigravity and the Gemini API for Gemini 4 Live, with business access coming soon.
Sources
- Google blog: Gemini 4 Live and Gemini 4 Live Translate (2 Dec 2026)
- Gemini API docs: Live API capabilities guide
- Gemini API docs: Tool use with Live API
- Gemini API docs: Session management with Live API
- Gemini API docs: Ephemeral tokens
- Gemini Developer API pricing
- Gemini API rate limits
- Google DeepMind: Gemini 4 Audio model card
- google-genai on PyPI (version 3.7.0)
- Google AI Developers Forum: Live API 1008 error thread




