Principle:Googleapis Python genai Live Streaming
| Knowledge Sources | |
|---|---|
| Domains | Real_Time_AI, Streaming, WebSocket |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Architecture pattern for real-time, bidirectional streaming communication between a client and a generative AI model over persistent connections.
Description
Live Streaming establishes a persistent bidirectional channel (typically WebSocket) between client and server, enabling continuous exchange of multimodal data (text, audio, video) in real time. Unlike request-response APIs, live streaming maintains session state across turns, supports interruptible generation, and handles real-time input (microphone audio, camera video) alongside text. The model produces incremental responses as server-sent events.
Usage
Use this principle when building applications requiring sub-second response latency, continuous input processing, or multimodal real-time interactions such as voice assistants, live captioning, interactive tutoring, or real-time translation.
Theoretical Basis
Live streaming follows the Full-Duplex Communication pattern:
# Pseudo-code for live streaming session
session = connect(model, config)
# Client can send and receive concurrently
send_text(session, "Hello")
send_audio(session, audio_chunk)
for message in receive(session):
process_server_response(message)
close(session)
Key properties:
- Bidirectional: Client and server send data independently
- Stateful: Session maintains conversation context across turns
- Multimodal: Supports text, audio, video, and tool calls in the same session
- Interruptible: Client can send new input while model is generating