Google Gemini integration guide

A guide to using Google Gemini with LiveKit Agents.

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.0rc"

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 google
session = AgentSession(
llm=google.LLM(
model="gemini-2.0-flash-exp",
temperature=0.8,
),
# ... 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.

modelChatModels | strOptionalDefault: gemini-2.0-flash-001

ID of the model to use. For a full list, see Gemini models.

api_keystrOptionalEnv: GOOGLE_API_KEY

API key for Google Gemini API.

vertexaiboolOptionalDefault: false

True to use Vertex AI; false to use Google AI.

projectstrOptionalEnv: GOOGLE_CLOUD_PROJECT

Google Cloud project to use (only if using Vertex AI). Required if using Vertex AI and the environment variable isn't set.

locationstrOptionalEnv: GOOGLE_CLOUD_LOCATION

Google Cloud location to use (only if using Vertex AI). Required if using Vertex AI and the environment variable isn't set.

temperaturefloatOptionalDefault: 0.8

A measure of randomness in output. A lower value results in more predictable output, while a higher value results in more creative output.

To learn more, see Model parameters.

max_output_tokensintOptional

Maximum number of tokens that can be generated in the response. To learn more, see Model parameters.

tool_choiceToolChoice | Literal['auto', 'required', 'none']OptionalDefault: auto

Specifies whether to use tools during response generation.

Additional resources

The following resources provide more information about using Google Gemini with LiveKit Agents.