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.experimental.tools import stop
from strands.vended_tools import notebook
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=[notebook, 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().

GoogleGeminiLiveModel does not produce a message history, so it has limited compatibility with the Strands session manager. For connection restarts, the provider resumes the same server-side session through Gemini’s session resumption handle, carrying context across the restart without replaying history. Resumed sessions persist up to 24 hours; after that, create a new GoogleGeminiLiveModel instance to continue the conversation.

If you encounter the error ModuleNotFoundError: No module named 'google.genai', this means the google-genai dependency hasn’t been properly installed in your environment. To fix this, run 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.