Skip to main content

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:

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

Provider tools are implemented and executed internally by a specific model provider (e.g., OpenAI, Gemini). They function similarly to function tools within the framework, but are vendor-specific and only compatible with the corresponding provider's models.

For example, you can use xAI's XSearch tool to query X for real-time information.

from livekit.plugins import xai
agent = MyAgent(
llm=xai.realtime.RealtimeModel(),
tools=[xai.realtime.XSearch()],
)

Currently we support provider tools for the following providers:

Examples

The following additional examples show how to use tools in different ways:

In this section

Read more about each topic.

TopicDescription
Function tool definitionDefine 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 frontendFulfill tool calls via RPC from the client.

Additional resources

The following articles provide more information about the topics discussed in this guide: