Tool definition and use
LiveKit docs › Logic & Structure › Tool definition & use › Overview
Overview
/agents/build/tools
LiveKit docs › Logic & Structure › Tool definition & use › Overview
Tool definition and use
Let your agents call external tools and more.
Overview
LiveKit Agents has full support for LLM tool use. This feature allows you to create a custom library of tools to extend your agent's context, create interactive experiences, and overcome LLM limitations.
Within a tool, you can:
- Generate agent speech with
session.say()orsession.generate_reply(). - Call methods on the frontend using RPC.
- Handoff control to another agent as part of a workflow.
- Store and retrieve session data from the
context. - Anything else that a Python function can do.
- Call external APIs or lookup data for RAG.
Tool types
Two types of tools are supported:
- Function tools: Tools that are defined as functions within your agent's code base and can be called by the LLM.
- Provider tools: Tools provided by a specific model provider (e.g. OpenAI, Gemini, etc.) and are executed internally by the provider's model server.
Provider tools
Available in:
- Node.js
- Python
Many LLM providers, including OpenAI, Gemini, and xAI, include built-in server-side tools that are executed entirely within a single API call. Examples include web search, code execution, and file search. These tools, called "provider tools" in LiveKit Agents, can be added to any agent that uses a supported LLM. You can mix and match provider tools with function tools by passing them to the tools parameter on your Agent.
from livekit.plugins import openai # replace with any supported provider
agent = MyAgent(
llm=openai.responses.LLM(model="gpt-4.1"),
tools=[openai.tools.WebSearch()], # replace with any supported tool
)
Refer to the documentation for each model provider for supported tools and usage details:
- OpenAI:
WebSearch,FileSearch,CodeInterpreter. - Gemini:
GoogleSearch,GoogleMaps,URLContext,FileSearch,ToolCodeExecution. - Anthropic:
ComputerUse. - xAI:
WebSearch,XSearch,FileSearch.
Examples
The following additional examples show how to use tools in different ways:
-
Use of enum: Example showing how to annotate arguments with enum.
-
Dynamic tool creation: Complete example with dynamic tool lists.
-
MCP Agent: A voice AI agent with an integrated Model Context Protocol (MCP) client for the LiveKit API.
In this section
Read more about each topic.
| Topic | Description | | Function tool definition | Define function tools with decorators, RunContext, speech in tools, interruptions, dynamic tools, toolsets, and error handling. | | Model Context Protocol (MCP) | Expose tools from MCP servers to your agent (Python only). | | Forwarding to the frontend | Fulfill tool calls via RPC from the client. |
Additional resources
The following articles provide more information about the topics discussed in this guide:
-
RPC: Complete documentation on function calling between LiveKit participants.
-
Agent speech: More information about precise control over agent speech output.
-
Workflows: Read more about handing off control to other agents.
-
External data and RAG: Best practices for adding context and taking external actions.
For the latest version of this document, see https://docs.livekit.io/agents/logic/tools.md.
To explore all LiveKit documentation, see llms.txt.