Tool calling is a way for a language model to request that a function run, instead of only producing text. The application tells the model which tools exist, the model replies with a structured call (a tool name plus arguments), the application runs it, and the output goes back to the model. OpenAI’s function calling guide says “Function calling (also known as tool calling)” lets its models “interface with external systems and access data outside their training data.”
The loop
OpenAI describes a five-step flow:
- Make a request to the model with tools it could call.
- Receive a tool call from the model.
- Execute code on the application side with input from the tool call.
- Make a second request to the model with the tool output.
- Receive a final response from the model, or more tool calls.
The Gemini docs give the same sequence in four steps and state who does the work: “The model doesn’t execute the function itself. Extract the name and args and execute in your application.” They add that the process “can be repeated over multiple turns.”
Function calling and tool calling
The names overlap. Anthropic writes “Tool use (also called function calling)”, and OpenAI uses both terms for the same feature. OpenAI also draws a distinction inside its platform: “A function is a specific kind of tool, defined by a JSON schema.” Other kinds are custom tools that “work with free text inputs and outputs”, and built-in tools that “search the web, run code, access the functionality of an MCP server, and more.”
Who runs the tool
| Provider | Term in docs | Where function code runs | Provider-run tools |
|---|---|---|---|
| OpenAI | Function calling, tool calling | Your application | Built-in tools such as web search and code execution |
| Anthropic | Tool use | Your application (client tools) | Server tools such as web_search, web_fetch and code_execution |
| Gemini API | Function calling | Your application | Built-in tools such as google_search can be combined with function calling in the same request |
Anthropic’s rule is “Tools differ primarily by where the code runs.” For client tools the model responds with stop_reason: "tool_use", and the application returns a tool_result block. For server tools, results appear in the response without the application handling execution.
What a tool definition contains
Each provider asks for a name, a description and a JSON-schema style parameter definition. Anthropic’s client tool uses name, description and input_schema. Anthropic says Claude “determines when to call a tool based on the user’s request and the tool’s description”, so the description steers selection. Gemini’s best practices say to be “clear and specific” in function and parameter descriptions, use “specific types (integer, string, enum)”, and “Validate function calls before executing.”
Controlling when tools are called
All three providers expose a tool_choice setting.
| Behavior | OpenAI | Gemini |
|---|---|---|
| Model decides (default) | auto: zero, one or multiple functions | auto: “Model decides whether to call a function or respond directly.” |
| Must call a tool | required: one or more functions | any: “Model is constrained to always predict a function call.” |
| Must not call a tool | none | none: “Model is prohibited from making function calls.” |
| Restrict to named tools | A named function forces exactly one specific function; allowed tools restrict to a subset | allowed_tools with mode and a tools list |
Anthropic’s documentation lists the same idea as auto, none, any and tool in its token-count table, and shows tool_choice={"type": "auto", "disable_parallel_tool_use": True} to ask “for at most one tool call in each turn.” OpenAI has the equivalent switch, parallel_tool_calls set to false, which “ensures exactly zero or one tool is called.”
Parallel and repeated calls
A model can request several calls in one turn when they are independent. Gemini calls this parallel function calling and calls running them in sequence compositional function calling. OpenAI notes that on supported models beginning with GPT-5, functions can be called in parallel when built-in tools are also available, but built-in tools cannot be included in a parallel function-call batch.
Schema adherence
By default the arguments a model produces are generated text and can drift from the schema. OpenAI’s strict option addresses this: “Setting strict to true will ensure function calls reliably adhere to the function schema, instead of being best effort. We recommend always enabling strict mode.” Gemini offers a validated mode described as “Model ensures function schema adherence.” Application code should still check arguments before acting on them, as the Gemini best practices advise.
Tool calling and MCP
Tool calling defines how a model asks for an action in one API. The Model Context Protocol standardizes how an application discovers and connects to servers that offer tools, so tools can be offered to different hosts through one protocol. The two work together: OpenAI lists MCP server access among its built-in tools, and the Gemini guide has a section on remote MCP. The MCP spec says tools are “Functions for the AI model to execute” and warns they represent “arbitrary code execution and must be treated with appropriate caution.”
Practical limits
- Every tool definition costs input tokens. Anthropic states that its tool use system prompt tokens “are added to your normal input and output tokens.”
- Large tool sets hurt selection. Gemini’s best practices say to keep the active set to “10-20 tools maximum”, and its guide suggests tool retrieval once you pass roughly 20 to 30 tools, and both OpenAI and Gemini describe tool search for loading rarely used tools on demand.
- Tools that change state need controls outside the model, such as consent and authentication.
For how tool results and instructions fit into what the model sees, see What is context engineering?.