function_tool
FunctionToolInfo to the callable, deriving the tool
description from its docstring and a JSON parameters schema from its
signature and type hints. May be used directly (@function_tool) or
with keyword arguments (@function_tool(name=...)).
The callable to decorate. When omitted, a decorator is returned so the function can be applied with arguments.
Tool name to expose. Defaults to the callable’s
__name__.Optional filler text associated with the tool.
Grace period, in seconds, for the filler.
returns
The decorated callable with a
_tool_info attribute when func is provided, otherwise a decorator that applies the same wrapping.is_function_tool
The object to inspect.
True if the object has a _tool_info attribute that is a FunctionToolInfo instance, False otherwise.get_tool_info
A function tool created with
function_tool.The
FunctionToolInfo associated with the tool.FunctionTool
Protocol for callables registered as function tools. A function tool is a callable that carries a_tool_info attribute
describing its metadata, allowing it to be exposed to a model for
function calling.
Constructor
FunctionToolInfo
Metadata describing a function tool.Fields
The tool’s exposed name.
Human-readable description, typically derived from the callable’s docstring.
JSON schema describing the tool’s parameters.
Optional filler text associated with the tool.
Grace period, in seconds, for the filler.
ToolChoice
Strategies controlling whether and how the model calls tools.build_openai_schema
A function tool created with
function_tool.A dictionary describing the tool in OpenAI’s function-calling format, containing the tool name, description, and parameters schema.
build_gemini_schema
additionalProperties, title, and definition blocks.
A function tool created with
function_tool.A dictionary describing the tool with its name, description, and a cleaned parameters schema.
build_nova_sonic_schema
build_openai_schema.
A function tool created with
function_tool.A dictionary describing the tool in OpenAI’s function-calling format.
MCPServerStdio
Configuration for an MCP server launched as a local subprocess. Describes how to start a Model Context Protocol server over standard input/output by running a command with optional arguments and environment variables.Constructor
Executable used to launch the MCP server process.
Command-line arguments passed to the executable. Defaults to an empty list when not provided.
Environment variables for the server process. Defaults to an empty mapping when not provided.
MCPServerHTTP
Configuration for an MCP server reachable over HTTP. Describes how to connect to a Model Context Protocol server at a remote URL, optionally sending custom request headers.Constructor
Endpoint URL of the MCP server.
HTTP headers sent with each request, such as authentication credentials. Defaults to an empty mapping when not provided.
DTMFHandler
Registers and dispatches callbacks for received DTMF input. Maintains handlers for individual digits and for digit sequences, invoking the matching callback as DTMF events arrive. A rolling buffer of recent digits is kept to detect registered sequences.Constructor
on_digit
The single digit to listen for.
Callable invoked with the received digit. May be a regular function or a coroutine function.
on_sequence
The ordered string of digits to match.
Callable invoked with the matched sequence. May be a regular function or a coroutine function.
VoiceMailDetector
Detects whether an outbound call reached voicemail. Configures voicemail classification for outbound calls and tracks detection state, optionally invoking a callback and triggering hangup when voicemail is detected.Constructor
Language model used to classify whether voicemail was reached.
Callable invoked with the detection event payload when voicemail is detected. May be a regular function or a coroutine function.
Detection window in seconds. Defaults to
2.0.Optional prompt overriding the default classifier prompt. Stored as an empty string when not provided.
Whether to automatically hang up once voicemail is detected. Defaults to
False.Confidence threshold for declaring a detection. Defaults to
1.0.Optional maximum detection duration in seconds. When provided, it overrides
duration.