Notebooks
G
Google Gemini
LiveAPI Streaming In Colab

LiveAPI Streaming In Colab

quickstartsgemini-cookbookgemini-apigeminiwebsockets
Copyright 2025 Google LLC.
[ ]

Gemini Live - Multimodal live API: Streaming in Colab

This notebook uses the Multimodel Live API to stream bidirectional audio in Colab. This notebook is much more a demo than a tutorial. This code demonstrates that it is possible to stream audio with interruptions in Colab. It takes a few hacks to make it work.

Set up

To run the following cell, your API key must be stored in a Colab Secret named GOOGLE_API_KEY. If you don't already have an API key, or you're not sure how to create a Colab Secret, see Authentication for an example.

[1]

Now to run it just run all the cells.

Important: On first try it will typically throw an error and ask for permission to record audio, if that happens allow audio, and run it again.

[2]
[3]
[4]

Run the client

[ ]
HOST
MODEL
INITIAL_REQUEST_TEXT
<connected>
unhandled message: {'setupComplete': {}}
<end of turn>

Important: On first try it will typically throw an error and ask for permission to record audio, if that happens allow audio, and run it again.