指南
What is Tool Calling in LLMs?
How tool calling / function calling works, when to use it, and which models support it best.
Tool calling (also known as function calling) is the API contract that lets an LLM declare "I want to call function X with these arguments" rather than emit free-form text for you to parse. The model returns a structured JSON object — function name plus arguments — that your runtime executes; the result is fed back as a tool message and the model continues. Without tool calling, building agents requires brittle regex parsing of model output.
The lifecycle of a tool call
A typical multi-step interaction looks like this:
- Caller passes a tool catalog (JSON Schema for each function's signature) plus the user message.
- Model decides: answer directly, OR emit a tool_call object specifying function + arguments.
- Caller's runtime executes the function (search, SQL, shell, custom API) and returns the result.
- Model receives the result, optionally calls more tools, and finally returns a natural-language answer.
What separates a great tool-calling model
Three quality signals matter in production:
- Argument fidelity — does the model fill in correct types and required fields, or hallucinate plausible-but-wrong arguments?
- Tool selection — given 30 candidate tools, does the model pick the right one? This is where most models falter at scale.
- Parallel tool calls — modern models (GPT-5, Claude Sonnet 4.5) emit multiple tool calls in one turn, dramatically reducing latency for multi-source queries.
When you don't need tool calling
If your output is a single fixed schema (e.g., always extract one Invoice JSON object), structured output / JSON mode is simpler and cheaper than tool calling. Use tool calling when the model needs to choose among multiple actions or call external systems.
Frequently asked questions
What's the difference between tool calling and function calling?
They're the same concept, with different vendor branding. Anthropic uses 'tool use', OpenAI uses 'function calling' / 'tools', Google uses 'function calling'. The wire format and behaviour are equivalent.
Can a model with structured output replace tool calling?
Partially. Structured output guarantees JSON shape, but doesn't model the multi-step request/response loop tool calling implies. For real agents you usually want both.
Are tools called by the model or by my code?
Your code. The model only emits a JSON request to call a tool — your runtime executes it and feeds the result back as a tool message. The model never directly hits your databases or shells.