Who this is for
This guide is for developers building voice conversation apps, real-time voice assistants or apps that include camera or screen input, and who already write Python or JavaScript. By the end you should be able to open a Live session with the google-genai SDK, send audio, video and text, and return tool results.
What the Live API and Gemini 4 Live are
The Gemini Live API supports real-time, bidirectional interaction with Gemini models. Inputs can be audio, video and text, and outputs can be native audio[1]. The API uses WebSockets, and the google-genai SDK provides a high-level asynchronous interface for managing these connections[1].
Three concepts matter. A session is a persistent connection to the model. The config sets modalities, voice and system instructions. Real-time input carries audio and video as data blobs[1].
Gemini 4 Live uses the model code gemini-4-live. It is a unified real-time audio model on the Live API[2]. It accepts text, images, audio and video as input, and it outputs text and audio[2]. Its input token limit is 131,072 tokens, and its output token limit is 65,536 tokens[2].
Setting up a session
Connect with an API key. The example below sets api_version to v1beta and sets response_modalities to AUDIO[1]:
import asyncio
from google import genai
client = genai.Client(api_key="YOUR_API_KEY", http_options={"api_version": "v1beta"})
model = "gemini-4-live"
config = {"response_modalities": ["AUDIO"]}
async def main():
async with client.aio.live.connect(model=model, config=config) as session:
print("Session started")
# Send content...
if __name__ == "__main__":
asyncio.run(main())The JavaScript SDK uses ai.live.connect to open a session and sendRealtimeInput to send data[1].
Sending text, audio and video
Send text with send_realtime_input. The JavaScript equivalent is sendRealtimeInput[1]:
await session.send_realtime_input(text="Hello, how are you?")Audio must be raw 16-bit PCM at 16kHz, little-endian. Set the MIME type to audio/pcm;rate=16000[1]:
# Assuming 'chunk' is your raw PCM audio bytes
await session.send_realtime_input(
audio=types.Blob(
data=chunk,
mime_type="audio/pcm;rate=16000"
)
)Video goes in as individual images, such as JPEG or PNG, at a maximum of one frame per second[1]:
# Assuming 'frame' is your JPEG-encoded image bytes
await session.send_realtime_input(
video=types.Blob(
data=frame,
mime_type="image/jpeg"
)
)Receiving audio and transcripts
Audio replies arrive as chunks in the model turn. Read inline_data to process or play them on your server[1]:
async for response in session.receive():
if response.server_content and response.server_content.model_turn:
for part in response.server_content.model_turn.parts:
if part.inline_data:
audio_data = part.inline_data.data
# Process or play the audio dataTranscripts for user input and model output are both in server_content, so you can print them together[1]:
async for response in session.receive():
content = response.server_content
if content:
if content.input_transcription:
print(f"User: {content.input_transcription.text}")
if content.output_transcription:
print(f"Gemini: {content.output_transcription.text}")Handling tool calls
When the model requests a tool call, your code runs the function locally and sends the result back to the session[1]:
async for response in session.receive():
if response.tool_call:
function_responses = []
for fc in response.tool_call.function_calls:
# 1. Execute the function locally
result = my_tool_function(**fc.args)
# 2. Prepare the response
function_responses.append(types.FunctionResponse(
name=fc.name,
id=fc.id,
response={"result": result}
))
# 3. Send the tool response back to the session
await session.send_tool_response(function_responses=function_responses)Choosing a thinking mode
By default, gemini-4-live runs in fast mode. Omit thinking_level, or set it to MINIMAL. Compared with Gemini 3.8 Live, this mode cuts time to first audio by over three times compared with Gemini 3.8 Live[2].
Set thinking_level to LOW, MEDIUM or HIGH for background reasoning on multi-step tasks, while the model speaks updates[2]. This mode requires NON_BLOCKING function declarations and tracking of server_content.interaction_status. It does not support BLOCKING calls or function response scheduling[2].
To migrate from gemini-3.8-live, change the model string to gemini-4-live and omit thinking_level or set it to MINIMAL. The turnComplete lifecycle and function calling behavior stay the same[2]. Migrating from the extended thinking version means thinking_budget and XHIGH are no longer supported[2].
Voices, video and mid-session updates
Gemini 4 Live offers over 2,000 preset voices and supports custom voice replication. Designed voices are not supported[2].
With Proactive Video, the model speaks unprompted when a camera or screen feed changes. Set proactive_video=True in the proactivity config[2].
To change the system instruction or swap tools in an active session, call send_context_update. You do not need to reconnect[2].
Capabilities and pricing
Gemini 4 Live supports function calling, the Live API, Grounding with Google Search and thinking. It does not support code execution, context caching or file search[2].
On the paid tier, text input costs $0.75 per million tokens. Audio input costs $3.00 per million tokens, or $0.005 per minute. Image and video input costs $1.00 per million tokens, or $0.002 per minute. Text output costs $4.50 per million tokens, and audio output costs $12.00 per million tokens, or $0.018 per minute. Output includes thinking tokens. The free tier is free of charge[2].
Common problems
- Audio must be raw PCM. Other formats will not work as-is, so convert before sending[1].
- Video is capped at one frame per second, so fast-changing scenes need sampling decisions on your side[1].
- If you use Google Search grounding, note that it is billed per search query and has a daily cap[2].
Next steps
Read the Live API guides on capabilities, tool use, session management and ephemeral tokens next. For client-to-server apps, ephemeral tokens are the safer option[1].
Prices and limits change, so check the official pricing page before you build[2].
Sources
- 1Get started with Gemini Live API using the Google GenAI SDKGoogle AI for Developers
- 2Gemini 4 LiveGoogle AI for Developers
Cite this page: Getting started with Gemini 4 Live through the Live API. TellWorld, https://www.tellworld.net/practice/practice-gemini-4-live-api. Updated 2026-12-04