delightful-microphone-72472
11/27/2025, 12:55 PMtall-airline-16756
11/27/2025, 12:56 PMtall-airline-16756
11/27/2025, 12:56 PMmodels/gemini-2.5-flash-native-audio-preview-09-2025 in LiveKit via the Gemini Live API plugin.
It’s supported as a realtime speech-to-speech model for LiveKit Agents. Example usage:
Python
from livekit.plugins import google
session = AgentSession(
llm=google.realtime.RealtimeModel(
model="gemini-2.5-flash-native-audio-preview-09-2025",
voice="Puck",
),
)
Node.js
import * as google from '@livekit/agents-plugin-google';
const session = new voice.AgentSession({
llm: new google.realtime.RealtimeModel({
model: "gemini-2.5-flash-native-audio-preview-09-2025",
voice: "Puck",
}),
});
The model supports features like thinking mode via thinking_config for low-latency two-way voice interactions. Would you like an example showing thinking_config or guidance on voice/encoding settings?
Sources: Gemini Live API plugin | LiveKit docsdelightful-microphone-72472
11/27/2025, 12:56 PMtall-airline-16756
11/27/2025, 12:57 PMGOOGLE_API_KEY to your AI Studio API key.
2. Ensure vertexai is false (or omit it).
3. Configure your AgentSession to use the Gemini model (for example gemini-2.5-flash-native-audio-preview-09-2025).
Example (Python):
from livekit.plugins import google
session = AgentSession(
llm=google.realtime.RealtimeModel(
model="gemini-2.5-flash-native-audio-preview-09-2025",
voice="Puck",
),
)
This works for realtime speech-to-speech models and the same approach applies for google.LLM (non-realtime) usage. Would you like a sample showing thinking_config, or help setting the GOOGLE_API_KEY and auth flow for your environment?
Sources: Google Gemini LLM plugin guide | LiveKit Docs | Gemini Live API plugin | LiveKit docs | Google AI and LiveKit | LiveKit Docsdelightful-microphone-72472
11/27/2025, 12:57 PMGOOGLE_API_KEY and auth flow for your environmenttall-airline-16756
11/27/2025, 12:58 PMGOOGLE_API_KEY and the auth flow to use Gemini from AI Studio with LiveKit. Below are concise steps and examples.
1) Obtain an API key from AI Studio
• Generate an API key in AI Studio (Gemini API) and copy the key.
2) Set GOOGLE_API_KEY in your environment
• Local development (macOS/Linux):
◦ Run: export GOOGLE_API_KEY="YOUR_API_KEY"
• Local development (Windows PowerShell):
◦ Run: $Env:GOOGLE_API_KEY = "YOUR_API_KEY"
• In a container or deployment:
◦ Add GOOGLE_API_KEY to your container environment variables, deployment manifest, or secret store used by your platform.
3) Configure LiveKit Google plugin to use Gemini API
• Do not enable Vertex AI (leave vertexai false or omit it). With GOOGLE_API_KEY set, the plugin will call the Gemini API (AI Studio).
• Example (Python realtime model):
from livekit.plugins import google
session = AgentSession(
llm=google.realtime.RealtimeModel(
model="gemini-2.5-flash-native-audio-preview-09-2025",
voice="Puck",
),
)
4) Auth flow and deployment notes
• The API key in GOOGLE_API_KEY authenticates requests to the Gemini API (AI Studio). Ensure the key has the necessary Gemini API access enabled in your Google account/project.
• Keep the API key secret:
◦ Store it in your cloud provider’s secret manager or environment-specific secret store.
◦ Do not commit the key to source control.
• For production, use a secrets manager and restrict key usage (IP, referrer, or service restrictions) per your security needs.
Would you like a short example showing how to load GOOGLE_API_KEY from a secrets manager for a specific platform (AWS, GCP Secret Manager, or Kubernetes)?delightful-microphone-72472
11/27/2025, 1:12 PMtall-airline-16756
11/27/2025, 1:12 PMdelightful-microphone-72472
11/27/2025, 1:12 PMtall-airline-16756
11/27/2025, 1:13 PMGOOGLE_API_KEY to your AI Studio API key and ensure vertexai is false or omitted.
• Pass tool instances to the LLM:
◦ Python (realtime):
from livekit.plugins import google
from google.genai import types
session = AgentSession(
llm=google.realtime.RealtimeModel(
model="gemini-2.5-flash-native-audio-preview-09-2025",
_gemini_tools=[types.GoogleSearch(), types.ToolCodeExecution()],
),
)
• Node.js (realtime):
import * as google from '@livekit/agents-plugin-google';
const session = new voice.AgentSession({
llm: new google.realtime.RealtimeModel({
model: "gemini-2.5-flash-native-audio-preview-09-2025",
geminiTools: [new google.types.GoogleSearch(), new google.types.ToolCodeExecution()],
}),
});
• Supported built-in tools include GoogleSearch, GoogleSearchRetrieval, ToolCodeExecution, UrlContext, GoogleMaps.
• You can also enable these for non-realtime google.LLM via gemini_tools.
2) Dynamically load tools from an MCP server (Python only)
• Install MCP extras: uv add livekit-agents[mcp]~=1.2
• Provide MCP server(s) to your session; tools are fetched automatically:
from livekit.agents import mcp, AgentSession
session = AgentSession(
mcp_servers=[mcp.MCPServerHTTP("https://your-mcp-server.com")],
# llm, stt, tts...
)
• MCP integration is available in Python only; tools returned by the MCP server become available to the agent at runtime.
3) Forward tool calls to client/frontend via RPC
• Implement a tool that calls perform_rpc() from the agent to the participant, then register an RPC handler on the client.
◦ Backend tool (Python example):
from livekit.agents import function_tool, get_job_context, RunContext, ToolError
import json
@function_tool()
async def get_user_location(context: RunContext, high_accuracy: bool = False):
try:
room = get_job_context().room
participant = next(iter(room.remote_participants.values()))
response = await room.local_participant.perform_rpc(
destination_identity=participant.identity,
method="getUserLocation",
payload=json.dumps({"highAccuracy": high_accuracy}),
response_timeout=10.0,
)
return response
except Exception:
raise ToolError("Could not retrieve user location")
• Client (browser) RPC handler:
room.localParticipant.registerRpcMethod('getUserLocation', async (data) => {
const { highAccuracy, responseTimeout } = JSON.parse(data.payload);
const pos = await new Promise((res, rej) =>
navigator.geolocation.getCurrentPosition(res, rej, { enableHighAccuracy: highAccuracy, timeout: responseTimeout })
);
return JSON.stringify({ latitude: pos.coords.latitude, longitude: pos.coords.longitude });
});
• Key points: serialize payloads, handle timeouts, and select the correct destination participant identity.
4) Auth notes (quick)
• AI Studio / Gemini API: set GOOGLE_API_KEY env var or pass api_key to the LLM.
• Vertex AI: set GOOGLE_APPLICATION_CREDENTIALS to your service account JSON and use vertexai=True.
If you want, I can:
• Provide a full working Python or Node example that combines Gemini tools + MCP + an RPC tool, or
• Show how to secure GOOGLE_API_KEY using a specific secrets manager (Kubernetes, GCP Secret Manager, or AWS Secrets Manager). Which would you like? Sources: Google Gemini LLM plugin guide | LiveKit Docs | Gemini Live API plugin | LiveKit docs | Tool definition and use | LiveKit docs