Overview
Google Gemini provides powerful language models with advanced reasoning and multimodal capabilities. With LiveKit's Google plugin and the Agents framework, you can build sophisticated voice AI applications using Vertex AI or Google Gemini API.
Quick reference
This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.
Installation
Install the plugin from PyPI:
pip install "livekit-agents[google]~=1.2"
pnpm add @livekit/agents-plugin-google@1.x
Authentication
The Google plugin requires authentication based on your chosen service:
- For Vertex AI, you must set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to the path of the service account key file. - For Google Gemini API, set the
GOOGLE_API_KEY
environment variable.
Usage
Use Gemini within an AgentSession
or as a standalone LLM service. For example, you can use this LLM in the Voice AI quickstart.
from livekit.plugins import googlesession = AgentSession(llm=google.LLM(model="gemini-2.0-flash-exp",),# ... tts, stt, vad, turn_detection, etc.)
import * as google from '@livekit/agents-plugin-google';const session = new voice.AgentSession({llm: google.LLM(model: "gemini-2.0-flash-exp",),// ... tts, stt, vad, turn_detection, etc.});
Parameters
This section describes some of the available parameters. For a complete reference of all available parameters, see the plugin reference.
ID of the model to use. For a full list, see Gemini models.
API key for Google Gemini API.
Google Cloud project to use (only if using Vertex AI). Required if using Vertex AI and the environment variable isn't set.
Google Cloud location to use (only if using Vertex AI). Required if using Vertex AI and the environment variable isn't set.
List of built-in Google tools, such as Google Search. For more information, see Gemini tools.
Gemini tools
The gemini_tools
parameter allows you to use built-in Google tools with the Gemini model. For example, you can use this feature to implement Grounding with Google Search:
from livekit.plugins import googlefrom google.genai import typessession = AgentSession(llm=google.LLM(model="gemini-2.0-flash-exp",gemini_tools=[types.GoogleSearch()],),# ... tts, stt, vad, turn_detection, etc.)
import * as google from '@livekit/agents-plugin-google';const session = new voice.AgentSession({llm: google.LLM(model: "gemini-2.0-flash-exp",geminiTools: [new google.types.GoogleSearch()],),// ... tts, stt, vad, turn_detection, etc.});
The full list of supported tools, depending on the model, is:
google.genai.types.GoogleSearchRetrieval()
google.genai.types.ToolCodeExecution()
google.genai.types.GoogleSearch()
google.genai.types.UrlContext()
google.genai.types.GoogleMaps()
Additional resources
The following resources provide more information about using Google Gemini with LiveKit Agents.