red-agent-48266
09/13/2025, 12:09 PMtall-airline-16756
09/13/2025, 12:09 PMtall-airline-16756
09/13/2025, 12:09 PMfrom livekit.plugins import google
session = AgentSession(
llm=google.beta.realtime.RealtimeModel(
model="gemini-2.0-flash-exp",
voice="Puck",
temperature=0.8,
instructions="You are a helpful assistant",
),
)
Here are the steps to set everything up smoothly:
1. First, install the plugin using: pip install "livekit-agents[google]~=1.2"
2. Next, set up authentication by either using the GOOGLE_API_KEY
environment variable or passing it directly in your code.
3. Finally, use the session in your agent entrypoint, just like in the Voice AI quickstart.
If you'd like, I’m here to help with more details on text-based interactions or setting up text-to-speech. Just let me know!
Sources: Google Gemini integration guide | LiveKit Docs | web/src/data/playground-state.ts | Gemini Live API integration guide | LiveKit Docs | Gemini Live API integration guide | LiveKit Docsred-agent-48266
09/13/2025, 12:10 PMtall-airline-16756
09/13/2025, 12:10 PMnpm install @livekit/agents-plugin-google
2. Next, you'll want to authenticate using your Google Gemini API key. You can do this either by setting an environment variable or directly in your code:
3. Then, create and configure the RealtimeModel
like this:
4. Finally, integrate your model into an AgentSession
with the following:
If you’d like, I’m here to help with more details or optional settings like text-only mode or custom TTS—just let me know!
Sources: Gemini Live API integration guide | LiveKit Docs | plugins/google/README.md | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | web/src/components/session-controls.tsxred-agent-48266
09/13/2025, 12:11 PMtall-airline-16756
09/13/2025, 12:12 PMconst session = await agent.start(ctx.room, participant).then((session) => session as openai.realtime.RealtimeSession)
, which is specific to OpenAI's setup and doesn't quite fit with Gemini in LiveKit. No worries though! For Gemini, it's best to use the voice.AgentSession
class along with await
, rather than chaining with .then()
. Here's a friendly example to guide you:
import { voice } from '@livekit/agents';
import * as google from '@livekit/agents-plugin-google';
const session = new voice.AgentSession({
llm: new google.beta.realtime.RealtimeModel({
instructions: 'You are a helpful assistant.',
}),
});
await session.start({
agent: new voice.Agent({}),
room: ctx.room,
});
session.generateReply();
This approach simplifies things by removing the need for .then()
or type assertions, since the session type is set right when you create it. If any part of this feels unclear or you want to dive deeper, please don’t hesitate to ask—I’m here to help!
Sources: packages/sip--make-a-call/src/agent.ts | examples/src/drive-thru/drivethru_agent.ts | src/agent.ts | src/agent.ts