stale-vase-84095
11/18/2025, 3:22 PMtall-airline-16756
11/18/2025, 3:22 PMtall-airline-16756
11/18/2025, 3:23 PMfunction_tool. Here’s a friendly guide to help you through the process:
1. Define Tools: Start by using the @function_tool decorator to mark your functions for LLM access. Make sure the function name, docstring, and arguments are clearly laid out so everything is easy to understand.
2. Register Tools: When you initialize your RealtimeModel, pass your tools through the tools parameter. This step is key to making sure everything works smoothly with the Gemini API.
3. Control Tool Behavior: The tool_choice parameter is your friend here! Use it to decide when and how tools get called — options like auto, required, or none give you flexibility.
4. Handle Tool Responses: To keep the conversation flowing, use get_tool_results_for_realtime() to format and send the tool outputs back to the model.
5. Set Response Scheduling: You can configure tool_response_scheduling to control when the tool results are delivered, whether that’s WHEN_IDLE or IMMEDIATELY.
6. Update Tools Dynamically: Need to change tools during a session? No problem! Use update_tools() to update the available tools on the fly.
7. Fine-Tune Execution Flow: Lastly, tweak the tool_behavior parameter to decide how tool results are processed — options like BLOCK or STREAM let you customize the flow.
Following these steps should help your tools work perfectly within your Gemini realtime model. If you have any questions or want to dive deeper into any part, just let me know — I’m here to help!
Sources: Tool definition and use | LiveKit docs | agent/main.py | examples/voice_agents/README.md | plugins/google/src/llm.ts | Real-time AI Models & Streaming | livekit/livekit_composite | DeepWiki