Tool calling
Tool calling lets a model invoke external functions. The model generates structured JSON arguments, your code executes the function, and the result goes back into the conversation.How it works
- Define tools as JSON schemas and pass them in the
toolsparameter. - The model may emit a
tool_callsfield instead of a text response. - Execute the function with the provided arguments.
- Return the result as a
toolmessage in the next request.
Example
Anthropic format
The same flow works in the Messages API. Tool definitions and response shapes match the Anthropic schema.Model support matrix
Limitations
- Parallel tool calls are supported; the model chooses whether to call one or multiple tools
- For multi-step tool loops, inject the tool result back into the conversation as a
toolmessage - Some niche OpenAI tool features (e.g.,
function_call: "none"behavior) may have minor differences