Skip to main content
Function calling lets your AI agent execute Python functions and access external services during conversations.
Vision Agents uses Stream Video for real-time WebRTC transport by default. External WebRTC transports are supported as well. Most AI providers offer free tiers to get started.
For a conceptual overview of MCP, see Model Context Protocol.

Registering Functions

Use @llm.register_function() to make any Python function callable by the LLM:
Only async functions can be registered. Passing a synchronous function to @register_function() raises a ValueError.
The LLM automatically calls these functions when relevant:

Parameters and Types

Functions support required and optional parameters:

Custom Function Names

Override the function name exposed to the LLM:

MCP Servers

MCP servers provide your agent with access to external tools and services.

Local Servers

Run on your machine via stdio:

Remote Servers

Connect over HTTP:

Connecting to Agent

Pass MCP servers to your agent — tools are automatically discovered and registered:

Multiple Servers

Complete Example

Tool Execution Events

The framework emits events when tools execute:

Multi-round tool calling

All LLM plugins support multiple tool-calling rounds. If the model needs to call more tools after seeing results, you can configure the maximum number of rounds (default 3):

Next Steps

Model Context Protocol

MCP concepts

Create Your Own Plugin

Add function calling to custom LLMs