Is there a way to have the real-time mode use tool...
# ask-ai
c
Is there a way to have the real-time mode use tools?
t
Thanks for reaching out, Antoine. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely! LiveKit warmly supports the use of tools in real-time mode through its
RealtimeModel
plugins for providers like OpenAI, AWS Bedrock, Google Gemini, and Ultravox. This wonderful feature lets voice agents perform helpful actions such as retrieving data or booking appointments seamlessly during live audio conversations. To get started with configuring tools, you can define functions using the
@function_tool
decorator and then pass them to the
Agent
instance. Here’s a simple example to guide you:
Copy code
from livekit.agents import function_tool, Agent, AgentSession
from livekit.plugins.ultravox.realtime import RealtimeModel

@function_tool
async def get_weather(location: str) -> str:
    return f"The weather in {location} is sunny and 72°F"

session: AgentSession = AgentSession(
    allow_interruptions=True,
    llm=RealtimeModel(model_id="fixie-ai/ultravox"),
)

await session.start(
    agent=Agent(
        instructions="You are a helpful assistant with access to weather tools.",
        tools=[get_weather],
    ),
)
Also, if you ever need to update tools dynamically during a session, you can easily do so using the
update_tools()
method. If you’d like, I’m here to help with any further details or walk you through the implementation—just let me know! Sources: Realtime model integrations | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py | plugins/google/src/beta/realtime/realtime_api.ts