AI glossary
What is Function calling?
Also called Tool calling, Tool use ·
Function calling (also called tool calling or tool use) is the ability of a language model to return a structured request to run a function you defined, with arguments in JSON, so your code can execute it and pass the result back.
How it works
You send the model a list of tools alongside the conversation. Each tool has a name, a plain-language description of what it does and when to use it, and a JSON Schema for its parameters. The model never runs anything itself. When it decides a tool would help, it stops generating normal text and returns a tool call: the tool name plus arguments that match the schema.
Your application then:
- Validates the arguments.
- Runs the real function (an API call, a database query, a calculation).
- Sends the result back to the model as a tool result message.
- Lets the model continue, either answering the user or calling another tool.
That loop of "model proposes, code executes, model reads the result" is the core of every AI agent.
Why it matters
Function calling turns a model that can only write text into one that can look things up and take actions. It also makes outputs reliable to parse: instead of scraping a date out of a paragraph, you get {"date": "2026-10-18"} in a known shape.
A few practical points matter more than the model choice:
- Descriptions are prompts. A vague description leads to the wrong tool or wrong arguments.
- Validate everything. Models can produce arguments that are well-formed but wrong, so check them before any write action.
- Keep the tool list short. Dozens of overlapping tools confuse models and cost tokens on every request.
The Model Context Protocol builds on the same idea: an MCP server publishes tools with names, descriptions and schemas, and the host turns them into function definitions for the model.
Example
A support assistant is given a tool get_order_status(order_id: string). A customer writes "where is order 48213?". The model returns a call to get_order_status with {"order_id": "48213"}. The application queries the order system, gets "shipped, arriving Tuesday", sends that back, and the model replies to the customer in natural language with the real status.
Related terms
Sources
- Function calling, OpenAI
- Tool use with Claude, Anthropic
Go deeper
AI AgentsHow to Build an AI Agent: A Step-by-Step Guide With Python and No-CodeHow to build an AI agent in 7 steps: pick a task, define tools, write instructions, add limits and approvals. Working Python code, a free local option and n8n. · 10 min read
MCP and IntegrationsMCP vs API: What's the Difference and When to Use EachAn API is a service's own interface; MCP is one protocol AI apps use to discover and call tools. Side-by-side table, examples and when to use each. · 7 min read