For Developers/Glossary/Tool Use / Function Calling
Prompting

Tool Use / Function Calling

The ability of an LLM to request execution of external functions, APIs, or tools by returning a structured call that matches a declared schema, so an application or the provider's servers can run it and return the result.

Function calling (OpenAI's and Google's term) or tool use (Anthropic's term) is the mechanism that lets an LLM take actions instead of only generating text. The application sends the model a list of tools, each with a name, a description and a JSON Schema for its parameters. When the model decides a tool is needed, it returns a structured call instead of, or alongside, a text answer. The application runs the function, sends the result back, and the model continues.

The standard loop

  1. Send the request with tool definitions (name, description, parameters as JSON Schema)
  2. The model returns one or more calls, for example {"name": "get_weather", "arguments": {"city": "London"}}
  3. The application executes each call and returns the results, matched to each call's ID
  4. The model uses the results to answer, or makes further calls

How the main APIs implement it

  • Claude (Messages API): Tools go in tools with an input_schema. Claude stops with stop_reason: "tool_use" and returns tool_use blocks, and the application answers with tool_result blocks. Adding strict: true to a tool guarantees its inputs match the schema. Parallel calls are on by default and can be limited with disable_parallel_tool_use. On Claude Opus 5.5, Sonnet 5.5 and Fable 5.2, forcing a call with tool_choice set to any or tool returns a 400 error; Anthropic's docs recommend auto with strict tools, or structured outputs, instead.
  • OpenAI (Responses API): Function tools use "type": "function" with name, parameters and strict, and results go back as function_call_output items matched by call_id. The Responses API normalizes schemas to strict mode when it can, while Chat Completions defaults to non-strict. parallel_tool_calls: false limits a turn to at most one call, and tool_choice accepts auto, required, a named function, allowed_tools or none. Custom tools take free-form text that can be constrained by a Lark or regex grammar. OpenAI's guide says GPT-6 Astra, GPT-6.1 Sol and GPT-6.1 Terra require the Responses API for tool calling.
  • Gemini API: Function declarations follow the same name, description and parameters pattern, with auto, any, none and validated calling modes. Gemini can make parallel calls and chain dependent ones (compositional calling), and Gemini 3 series models can combine function calls with built-in tools such as Google Search in one request. Google lists function calling, structured outputs, search grounding, code execution, URL context and computer use as supported on Gemini 4 Argon.

Server tools and MCP

Providers also run tools on their own infrastructure, so the application never executes them. Anthropic's server tools include web search, web fetch, code execution and tool search. For GPT-6 Astra, OpenAI lists web search, file search, code interpreter, hosted shell, computer use, image generation, MCP and tool search. Tool search lets the model load rarely used tool definitions on demand instead of sending every schema with each request: both Anthropic and OpenAI let you mark tools with defer_loading, and OpenAI's tool_search works on GPT-5.4 and later. All three APIs can call remote MCP servers directly: Claude through its MCP connector (in beta, using mcp_servers plus an mcp_toolset entry in tools), OpenAI through an mcp tool with a server_url, and Gemini through the Interactions API, which supports Streamable HTTP servers only.

Multi-step tool use

Agents chain many tool calls to finish a task: search the web, read a document, run a calculation, write a file. Every call and result adds tokens to the context window, so long tool-use chains consume tokens quickly and context size limits how far an agent can go before it needs compaction or summarization. Anthropic and OpenAI also offer programmatic tool calling, where the model writes code that calls your tools inside a sandbox instead of making each call as a separate turn.

Reliability considerations

Models can hallucinate arguments, call tools in the wrong order, or get stuck in loops. Common mitigations:

  • Strict schema mode (Claude and OpenAI) or validating arguments before execution
  • Clear, specific tool descriptions, which Anthropic's docs call the most important factor in tool performance
  • Keeping the active tool set small or using tool search; Google's guidance suggests 10 to 20 active tools at most
  • Human approval for irreversible actions (OpenAI's MCP tool has a require_approval setting)
  • Returning errors in tool results (Claude uses is_error: true) so the model can recover from failed calls

Related terms

Models relevant to Tool Use / Function Calling

Tools that use this