Tool calling, also called function calling or tool use, is the ability of a language model to answer with a structured request to run a function instead of plain text. The functions are ones that developers or providers make available, such as a database query or an API call. The model does not run the function itself. Your application or the model provider does.
At a glance
- Type
- ability of language models to output structured function calls
- Used in
- OpenAI API, Anthropic API and others
- Flow
- request with tools, tool call, execution by the application, result, answer
Last checked:
How does a tool call work?
OpenAI describes five steps. The application sends the model a request that includes the available tools. The model returns a tool call with arguments. The application runs the code with that input and sends the output back. The model then writes its final answer or makes further tool calls.
Each tool is defined with a name, a description and a JSON schema for its parameters. Anthropic distinguishes client tools, which run in your application, from server tools such as web search, which run on Anthropic’s infrastructure. For a client tool, the response carries stop_reason: "tool_use" and a tool_use block, and the application replies with a tool_result. Tool definitions count as input tokens.
Example
An application defines this tool:
{
"name": "get_weather",
"description": "Get the current weather for a given location.",
"input_schema": {
"type": "object",
"properties": {
"location": { "type": "string" }
},
"required": ["location"]
}
}
A user asks about the weather in San Francisco. The model responds with a tool_use block that names get_weather and the argument San Francisco, CA. The application looks up the weather and returns the result, and the model phrases the answer.
Tool calling and MCP
Tool calling describes how a model expresses a function call. The Model Context Protocol (MCP) describes how an AI application finds and calls tools on external servers. In an MCP setup, the host takes a tool call produced by the model and forwards it to the right MCP server.
Common mistakes
- Vague names and descriptions. OpenAI advises clear, detailed function names, parameter descriptions and instructions.
- Too many tools at once. OpenAI gives fewer than 20 initially available functions as a guideline. Tool definitions also count as input tokens.
- Leaving required inputs open. If a required parameter is missing, the model may infer a plausible value instead of asking, according to Anthropic’s documentation.
FAQ
Does the model run the function? For client tools the application runs it. For server tools the provider does.
Is function calling the same as tool calling? Providers use the terms for the same technique. Anthropic’s documentation calls tool use “also called function calling”.
Sources
- Function calling – OpenAI Developersdevelopers.openai.com
- Tool use with Claude – Anthropicplatform.claude.com
- Architecture overview – modelcontextprotocol.iomodelcontextprotocol.io
Last updated: