Skip to content

Google Gemini Live

The Gemini Live API lets developers create natural conversations by enabling a two-way WebSocket connection with the Gemini models. The Live API processes data streams in real time. Users can interrupt the AI’s responses with new input, similar to a real conversation. Key features include:

  • Multimodal Streaming: The API supports streaming of text, audio, and video data.
  • Bidirectional Interaction: The user and the model can provide input and output at the same time.
  • Interruptibility: Users can interrupt the model’s response, and the model adjusts its response.
  • Tool Use and Function Calling: The API can use external tools to perform actions and get context while maintaining a real-time connection.
  • Session Management: Supports managing long conversations through sessions, providing context and continuity.
  • Secure Authentication: Uses tokens for secure client-side authentication.

The Google Gemini Live provider is configured as an optional dependency in Strands Agents.

To install it, run:

Terminal window
pip install 'strands-agents[bidi-google,bidi-io,bidi-pyaudio]'

Or to install all bidirectional streaming providers at once:

Terminal window
pip install 'strands-agents[bidi-all,bidi-pyaudio]'

After installing the Gemini Live and local audio extras, create a voice agent:

import asyncio
from strands.experimental.bidi.agent import BidiAgent
from strands.experimental.bidi.io import BidiAudioIO
from strands.experimental.bidi.models import GoogleGeminiLiveModel
from strands_tools import calculator, stop
async def main() -> None:
model = GoogleGeminiLiveModel(
model_id="gemini-2.5-flash-native-audio-preview-09-2025",
voice="Kore",
client_args={"api_key": "<GOOGLE_API_KEY>"},
)
# stop tool allows user to verbally stop agent execution.
agent = BidiAgent(model=model, tools=[calculator, stop])
audio_io = BidiAudioIO()
await agent.run(inputs=[audio_io.input()], outputs=[audio_io.output()])
if __name__ == "__main__":
asyncio.run(main())

Pass Google GenAI client options through client_args. For the supported fields, see the Google GenAI client reference.

ParameterDescriptionExampleOptions
model_idGemini Live model identifier."gemini-2.5-flash-native-audio-preview-09-2025"Gemini models
audioInput audio options.{"input": {"sample_rate": 48000}}reference
voicePrebuilt output voice name. Uses the provider default when omitted."Kore"Voices and languages
paramsGemini Live session parameters.{"temperature": 0.7}LiveConnectConfig
connectionReconnect timing overrides.{"auto_reconnect": false}reference

Use direct options such as voice for common settings. For additional Google GenAI options, pass params using snake_case field names.

from strands.experimental.bidi.models import GoogleGeminiLiveModel
model = GoogleGeminiLiveModel(
client_args={"api_key": "<GOOGLE_API_KEY>"},
voice="Kore",
params={"temperature": 0.7, "speech_config": {"language_code": "en-US"}},
)

Nested dictionaries in params merge with the existing configuration, preserving unspecified fields. If a setting overlaps with a default or direct option, params takes precedence.

Calling update_config(params=...) replaces the entire params dictionary. The new values take effect on the next start() or restart().

Currently, GoogleGeminiLiveModel does not produce a message history and so has limited compatibility with the Strands session manager. However, the provider does utilize Gemini’s Session Resumption as part of the connection restart workflow. This allows Gemini Live connections to persist up to 24 hours. After this time limit, a new GoogleGeminiLiveModel instance must be created to continue conversations.

The error ModuleNotFoundError: No module named 'google.genai' means the google-genai dependency is missing. Install it with pip install 'strands-agents[bidi-google]'.

Set your Google AI API key through client_args or the GOOGLE_API_KEY environment variable. You can obtain an API key from Google AI Studio.