Tool calling (function calling)
Also called function calling, tool use.
A way for a language model to ask your application to run a defined function and give it the result.
Last updated
What it is.
You describe each tool to the model: its name, what it does and the inputs it takes, usually as a JSON schema. When the model decides a tool would help, it replies with a tool call, the tool name plus arguments, instead of plain text. Your code runs the function and sends the result back, and the model continues.
The model never runs anything itself. Your application decides whether to run each call, with what permissions, and what to send back. That is where security and business rules belong.
Why it matters
Tool calling is how an LLM gets live data and takes actions: checking stock, booking a slot, creating a ticket. It is the base layer of every AI agent. Done well, it keeps the model on facts from your systems instead of guesses, which cuts down on hallucinations.
Common mistakes.
- 01
Trusting the model's arguments. Validate every input as you would user input.
- 02
Exposing too many similar tools. The model picks better from a short, clearly named list.
- 03
Letting write actions run without confirmation or limits.
Work it out with a tool.
Related terms.
- AI agentSoftware where a language model decides which steps to take and which tools to call, in a loop, to reach a goal.
- Structured outputGetting a language model to reply in a fixed, machine-readable format, such as JSON that matches a schema you define.
- Guardrails (AI)Checks placed around an AI model that block, fix or flag unsafe, off-topic or incorrect inputs and outputs.
- LLM (large language model)An AI model trained on very large amounts of text that predicts the next piece of text, which lets it read, write and reason in language.
Guides and pages
Browse the full glossary or read answers to common questions.