Tool Calling
In short
Tool calling is an LLM feature in which the model asks the application to run a specific function with structured arguments, then uses the result in its answer.
What is tool calling in AI?
Tool calling, also known as function calling or tool use, lets a language model do more than produce text. The application tells the model which tools are available, such as get_weather, search_orders, or run_sql, and when a request needs one, the model replies with a structured request to call it with specific arguments. The application runs the function and sends the result back, and the model uses it to write its final answer.
Each tool is described with a name, a plain-language description, and a schema for its parameters, usually written in JSON Schema. The model never executes anything itself: it only outputs the tool's name and a JSON object of arguments, and your code decides whether to run it. Models can request several calls in one turn, and an application can keep looping, sending results back, until the model has everything it needs to answer.
An analogy is a manager who fills in a request form and hands it to an assistant: the manager decides what needs doing, but the assistant actually makes the phone call and reports back. Tool calling is how AI assistants fetch live data, look up records, book meetings, run code, and return reliably structured output, and it is the basic mechanism that AI agents are built on.
Tool calling is often confused with an AI agent or with the Model Context Protocol. Tool calling is the model's single capability to request a function call; an agent is a loop that uses many tool calls to pursue a goal, and MCP is a standard way for applications to discover and connect to tools provided by other programs. Because the model chooses the arguments, applications should validate them, give tools only the permissions they need, and ask a person to confirm risky actions.
Key takeaways
- Tool calling lets a model request a function call with structured arguments.
- Tools are described with a name, a description, and a parameter schema.
- The application, not the model, runs the tool and returns the result.
- AI agents are built from repeated tool calls in a loop.
- Validate arguments and limit permissions, because the model chooses the inputs.
Example
// Describe a tool the model may call: name, description, and JSON Schema
const tools = [{
name: "get_weather",
description: "Get the current weather for a city",
parameters: {
type: "object",
properties: { city: { type: "string" } },
required: ["city"],
},
}];
// llm and getWeather are placeholders for a real client and your own function
const reply = await llm.chat("Do I need an umbrella in Oslo?", { tools });
// The model only asks; your code runs the function and sends the result back
if (reply.toolCall) await getWeather(reply.toolCall.arguments.city);Readers ask
Does the model run the function itself?
No. The model only returns the name of the tool and the arguments it wants to use. Your application decides whether to run it, executes the code, and sends the result back to the model.
Is tool calling the same as function calling?
Yes, the terms mean the same thing. Different AI APIs use different names, such as function calling, tool use, or tool calling, but the mechanism is the same.
What is the difference between tool calling and MCP?
Tool calling is the model's ability to request a function call. The Model Context Protocol is a standard for how applications find and connect to tools offered by separate servers, and the model then uses tool calling to invoke them.
See also
- AI AgentAI & Machine Learning, p. 2An AI agent is a system that uses an LLM to plan and carry out multi-step tasks by deciding which tools to call, observing the results, and acting again.
- Model Context ProtocolAI & Machine Learning, p. 29The Model Context Protocol is an open standard that defines how AI applications connect to external tools, data sources, and prompts through a shared interface.
- LLMAI & Machine Learning, p. 25An LLM is a machine learning model trained on huge amounts of text that generates language by repeatedly predicting the next most likely piece of text.
- JSONBackend & APIs, p. 25JSON is a lightweight, text-based format for storing and exchanging structured data as key-value pairs and lists, readable by both humans and machines.
- APIBackend & APIs, p. 2An API is a set of rules that lets one piece of software request data or actions from another in a predictable, documented way.
- PromptAI & Machine Learning, p. 35A prompt is the input text or instructions you give an AI model, such as an LLM, to tell it what task to perform and what kind of answer you want.
Spotted a mistake or something missing on this page?Suggest an edit