Skip to main content

Live API Real-Time Streaming — Code Execution & Live API

[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Live API Real-Time Streaming

💻 Code Execution & Live API 15m 300 BASE XP⌨ HANDS-ON LAB

Bidirectional Real-Time AI

The Gemini Live API — powered in October 2026 by gemini-3.8-live (plus gemini-3.8-live-extended-thinking, 131,072 input / 65,536 output tokens, 16 kHz PCM audio in / 24 kHz audio out, and optional Live Avatar synchronization) — enables real-time, bidirectional streaming of audio, video, and text over a persistent WebSocket connection (via client.aio.live.connect(model="gemini-3.8-live", ...) in google-genai or direct WebSockets).

Key Capabilities

FeatureDescription
Audio StreamingSend and receive audio in real time for voice conversations
Video StreamingStream camera or screen feeds for live visual analysis
Text StreamingReal-time text generation with token-level streaming
Barge-inUsers can interrupt the model mid-response, and it adapts instantly
70+ LanguagesNative multilingual support for global voice applications

WebSocket Connection

import asyncio
import websockets
import json

async def live_session():
    uri = "wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent"
    async with websockets.connect(uri) as ws:
        # Send setup message
        await ws.send(json.dumps({
            "setup": {
                "model": "models/gemini-3.8-live",
                "generation_config": {
                    "response_modalities": ["AUDIO"],
                    "speech_config": {"voice_config": {"prebuilt_voice_config": {"voice_name": "Puck"}}}
                }
            }
        }))
        # Stream audio chunks bidirectionally
        await ws.send(json.dumps({
            "realtime_input": {"media_chunks": [{"data": audio_b64, "mime_type": "audio/pcm"}]}
        }))
        # Receive streaming response
        response = await ws.recv()
        print(json.loads(response))

asyncio.run(live_session())

Barge-In Support

Barge-in allows users to interrupt the model while it is still generating a response. The model detects the interruption, stops its current output, and immediately processes the new input - creating a natural, conversational experience.

🎯 Use Case Decision: Use the standard Gemini API for request-response workflows. Use the Live API for applications requiring continuous, real-time interaction - voice agents, live video analysis, and collaborative tools.
⌨ HANDS-ON LABConnect to Gemini Bi-directional Live API WebSocket
⭐ +150 XP

Establish an ultra-low latency bi-directional WebSocket session to the Gemini Live API for real-time audio/video streaming.

1Initiate a WebSocket handshake using wscat to the BidiGenerateContent endpoint.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 3
What protocol does the Gemini Live API use for real-time streaming?
REST/HTTP
gRPC
WebSocket for persistent bidirectional communication
MQTT