boundless-painting-47811
10/23/2025, 9:52 AMtall-airline-16756
10/23/2025, 9:52 AMtall-airline-16756
10/23/2025, 9:53 AM@function_tool decorator and set it up with the Gemini model.
• Using the Google Plugin: If you want a bit more control and access to Google-specific features, this method is great. You’ll configure the Gemini LLM with particular parameters and connect it with your agent.
Both options will need you to set up authentication—either with a Google API key or Google Cloud credentials, depending on your setup. You can also fine-tune how the tools behave, adjust response randomness, and tweak other settings for more advanced needs.
If you’d like, I’m here to walk you through detailed implementation steps or share some code examples. Just let me know!
Sources: AI Agents Framework | livekit/livekit_composite | DeepWiki | Google Gemini LLM plugin guide | LiveKit Docs | Real-time AI Models & Streaming | livekit/livekit_composite | DeepWiki | docs/index.yaml | livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real...boundless-painting-47811
10/23/2025, 9:56 AMtall-airline-16756
10/23/2025, 9:56 AMfrom livekit.plugins.google.beta import RealtimeModel
from google.genai import types
# Configure the real-time Gemini model
model = RealtimeModel(
model="gemini-2.0-flash-live-001",
instructions="You are a helpful assistant with tool access.",
tool_behavior=types.Behavior.BLOCK, # Wait for tool completion
tool_response_scheduling=types.FunctionResponseScheduling.WHEN_IDLE
)
# Example of defining a tool function
def example_tool_function(context, input_data):
"""Example tool function to process input data."""
# Perform some processing
result = f"Processed: {input_data}"
return None, result
# Add the tool to the model
model.add_tool(
name="example_tool",
function=example_tool_function,
description="A tool to process input data."
)
# Start the real-time session
async def start_realtime_session():
session = await model.start_session()
# Interact with the session as needed
response = await session.send_message("Process this data")
print(response)
# Run the session
if __name__ == "__main__":
import asyncio
asyncio.run(start_realtime_session())
This snippet walks you through setting up a real-time Gemini model, creating a tool function, and kicking off a session for real-time interactions. If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!boundless-painting-47811
10/23/2025, 1:42 PMtall-airline-16756
10/23/2025, 1:43 PMFunctionResponseScheduling types you can use in the Gemini real-time tool calling:
• `WHEN_IDLE`: The model patiently waits until it’s idle (meaning it’s not actively generating a response) before it processes the results from function or tool calls. This helps make sure that any ongoing responses aren’t interrupted by incoming tool results.
• `IMMEDIATELY`: Tool responses are handled as soon as they come in, without waiting for the model to become idle. This lets you have dynamic updates to the session state and you can even change this setting on the fly during a session without needing to restart.
The tool_response_scheduling parameter is what controls when the model processes those function call outputs. You can set it up when you initialize the RealtimeModel, or update it anytime during a session using session.update_options().
If you’d like, I’m here to help with more details or examples on how to use these types effectively. Just let me know!
Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Real-time AI Models & Streaming | livekit/livekit_composite | DeepWikiboundless-painting-47811
10/27/2025, 11:37 AMtall-airline-16756
10/27/2025, 11:39 AMRealtimeModel in LiveKit. It doesn’t have an add_tool method, but no worries—you can manage your tools dynamically using the update_tools method during a session. Here’s a friendly guide on how to do it:
1. Define Custom Tools: You can register functions for the model to use with the @function_tool decorator. For example:
from livekit.agents import function_tool
@function_tool()
async def get_weather(location: str) -> str:
return f"The weather in {location} is sunny."
2. Initialize the Agent with Tools: When you create your agent instance, just add your tools like this:
agent = MyAgent(
instructions="You are a helpful assistant.",
tools=[get_weather],
)
3. Dynamically Update Tools: If you want to add or change tools after your agent is up and running, just use update_tools like this:
async def random_number() -> int:
import random
return random.randint(0, 100)
await agent.update_tools([
*agent.tools.values(),
function_tool(random_number, name="random_number", description="Get a random number")
])
4. Enable Built-in Google Tools: You can also specify built-in tools right when you initialize your RealtimeModel by using the _gemini_tools parameter.
If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!
Sources: examples/voice_agents/dynamic_tool_creation.py | Gemini Live API plugin | LiveKit Docs | Docs::Agents | Google Gemini LLM plugin guide | LiveKit Docs | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki