This repository contains a complete, self-contained template for running a Gemini Live Agent with an Avatar Configuration Plugin and a beautiful, glassmorphic Web Client (avatar_client.html). It is built using Google's Agent Development Kit (ADK) and the Gemini Live API.
This demo enables real-time bidirectional audio and video streaming of a Gemini digital avatar (e.g., "Kai").
live-avatar-agent-demo/
├── README.md # This documentation file
├── .gitignore # Standard Python gitignore rules
├── requirements.txt # Python dependency specifications
└── live_avatar_agent/ # The agent application package
├── __init__.py
├── agent.py # The main ADK agent definitions
└── avatar_client.html # Real-time WebSocket/MediaSource web client
Before getting started, make sure you have the following installed and configured:
- Python 3.11+
- Google Cloud SDK (
gcloud) - Google Cloud Project: You need an active Google Cloud Project with the Vertex AI API enabled.
- Google Cloud Credentials: Authenticate your terminal using:
gcloud auth application-default login
Follow these steps to set up and run the demo locally:
Clone or download this folder, navigate into it, and create a Python virtual environment:
# Create virtual environment
python3 -m venv .venv
# Activate virtual environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows:
# .venv\Scripts\activateInstall the dependencies:
pip install -r requirements.txtLaunch the ADK web server pointing to the current directory:
# Set your active Google Cloud Project ID
export GCP_PROJECT="your-google-cloud-project-id"
# (Optional) Set your Vertex AI Search Engine/App ID if you want to test website search
export VERTEXAI_ENGINE_ID="your-search-engine-id"
# Run the ADK server
adk web .You should see output similar to this:
+-----------------------------------------------------------------------------+
| ADK Web Server started |
| |
| For local testing, access at http://127.0.0.1:8000. |
+-----------------------------------------------------------------------------+
Since the client communicates directly with localhost:8000 via WebSockets, you can open the HTML client directly in any browser:
- Double-click the file avatar_client.html or run:
# On macOS: open live_avatar_agent/avatar_client.html # On Linux: xdg-open live_avatar_agent/avatar_client.html
Once opened, you will see the glassmorphic Gemini Avatar Client interface.
- It will automatically connect to the ADK backend server.
- Click the Microphone icon at the bottom of the page to start speaking, or type a text message in the chat input.
- The avatar will respond in real-time with bidirectional video and audio streaming!
The agent is configured to use the DiscoveryEngineSearchTool (Vertex AI Search) for answering internal queries.
- If you have an active website data store, configure
VERTEXAI_ENGINE_IDinside agent.py or set it via environment variables before launching. - If you don't need search, you can remove the
DiscoveryEngineSearchToolimport and tool from thetools=[...]list inside agent.py.
The agent uses the AvatarConfigPlugin to request the avatar modality.
- Currently, options include
'Kai'and'Cora'. - You can change
avatar_name = 'Kai'in thebefore_run_callbackmethod of theAvatarConfigPluginclass in agent.py.
To share this demo with other engineers or customers:
-
Initialize the local Git repository:
git init git add . git commit -m "Initial commit for Live Avatar Agent Demo"
-
Create a new repository on GitHub (e.g., named
live-avatar-agent-demo). -
Push the local repository to GitHub:
git remote add origin https://github.com/<your-github-username>/live-avatar-agent-demo.git git branch -M main git push -u origin main