Skip to content
AI Dev Toolkit.
Esc
  • AI Token CounterCount tokens for GPT, Claude, Gemini, DeepSeek, Qwen and more.Tool
  • LLM API Cost CalculatorEstimate per-request, daily and monthly API costs.Tool
  • AI Model ComparisonCompare prices, context windows and features across models.Tool
  • AI Model Pricing PagesSpecs, real costs and cheaper alternatives for popular models.Tool
  • Context Window CheckerSee whether your text fits each model’s context window.Tool
  • Subscription vs API CalculatorFind out whether a chat plan or the API is cheaper for you.Tool
  • GPU / VRAM CalculatorCheck how much VRAM a local model needs and which GPUs fit.Tool
  • Prompt Caching CalculatorEstimate savings from prompt caching.Tool

AI glossary · Agents and tools

What is function calling (tool use)?

Also called: tool use, tool calling, tool calls

Definition

Function calling, also called tool use, is an LLM API feature in which the model replies with a structured request to run a function you described, with JSON arguments, which your code executes before sending the result back.

Explained

How it works

You send the model a list of tools, each with a name, a description and a JSON Schema for its arguments (parameters at OpenAI, input_schema at Anthropic). When a tool would help, the model returns a tool call instead of prose. OpenAI documents five steps: send a request with tools, receive a tool call, run the code, send the output back in a second request, and receive the final answer or more tool calls.

The model never executes anything. On Anthropic’s API the response has stop_reason: "tool_use" and a tool_use block; you run the function and reply with a tool_result block that quotes the call’s id. Arguments follow your schema on a best-effort basis unless you set strict: true on the tool. Repeating the round trip until the model stops asking is what makes an AI agent.

Example

One tool definition, and what it adds to every request

The definition below, serialised without spaces, is 68 tokens on o200k_base. OpenAI and Anthropic both bill tool definitions as input tokens, on every request that includes them, so an agent loop pays for them on every turn.

Anthropic also adds a tool-use system prompt whenever you pass tools: 286 tokens for Claude Sonnet 5.5 with tool_choice set to auto, from its pricing table. 20 tools of this size would come to about 1,646 tokens before the conversation starts. Claude’s tokenizer counts differently from o200k_base, so the definition’s share is an estimate.

Fixed tool overhead per request
PartTokensSource
This tool definition68Measured, o200k_base
Anthropic tool-use system prompt (Claude Sonnet 5.5, auto)286Anthropic docs
20 definitions of this size plus that prompt1,646Computed
A client tool in Anthropic’s format
{
  "name": "get_order_status",
  "description": "Look up the shipping status of one customer order by its ID. Use when the user asks where an order is.",
  "input_schema": {
    "type": "object",
    "properties": {
      "order_id": {
        "type": "string",
        "description": "The order ID, for example ORD-10482"
      }
    },
    "required": ["order_id"]
  }
}

Cost and quality

Why it matters

Tool definitions are a fixed cost on every request, so a long list of rarely used tools costs money and leaves less room in the context window. Keep descriptions short but specific: the model picks a tool by its name and description.

Treat arguments as untrusted input. Validate them before running anything with side effects, and return errors as tool results so the model can correct itself.

Don’t mix up

Common confusions

Function calling vs MCP
Function calling is how one model asks for one tool in one API. MCP is a protocol for an app to discover and run tools from external servers; the app still hands those tools to the model through function calling.
Function calling vs structured outputs
OpenAI’s guidance: use function calling when the model should act through your tools, and structured outputs when you want the reply itself shaped to a schema.

Go deeper

Try it and read more

Related

All 40 terms in the AI glossary

Written by Tahir Nazir. Checked .

How this was checked: Tool definition measured with gpt-tokenizer 4.0.0 (o200k_base). The five-step flow and input-token billing checked against OpenAI’s function calling guide; tool_use, tool_result, strict and the 286-token tool-use system prompt against Anthropic’s tool use docs, on 2026-10-11.