LLMs are powerful, but they cannot do anything on their own. Tool calling is the mechanism that changes that — and it is simpler than you think.
Ask an LLM what the weather is in Tokyo right now and it will either make something up or politely tell you it cannot access the internet. Ask it to query your database, send an email, or book a flight — same problem. Large language models generate text. That is all they do natively.
Tool calling is the mechanism that bridges this gap. It lets an LLM say "I need to call a function" instead of guessing, and it is the single capability that makes AI agents possible.
Without tool calling, you have a chatbot. With it, you have software that can act on the world.
The Problem: LLMs Cannot Do Anything
An LLM is a text prediction engine. Given a sequence of tokens, it predicts the next one. This makes it remarkable at writing, summarizing, translating, and reasoning — but fundamentally limited in three ways:
- No access to real-time data. Training data has a cutoff. The model does not know today's stock price, your latest order status, or whether your server is down.
- No ability to take actions. It cannot send a Slack message, create a Jira ticket, or write a row to a database. It can only produce text that describes those actions.
- Hallucination under uncertainty. When it does not know something, it often fills the gap with plausible-sounding fiction rather than admitting ignorance.
The traditional workaround was prompt engineering — stuffing context into the prompt so the model had the information it needed. But that does not scale. You cannot paste your entire database into a prompt, and you definitely cannot send emails by predicting what an email would look like.
Tool calling solves this by giving the LLM a structured way to request that your code executes a function on its behalf.
How Tool Calling Works, Step by Step
The mechanic is straightforward. Here is what happens during a single tool-calling turn:
1. You Describe Available Tools
When you send a request to the LLM API, you include a list of tools the model can use. Each tool is defined with a name, a description, and a JSON Schema specifying its parameters.
{
"name": "get_weather",
"description": "Get the current weather for a given city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city name, e.g. 'Tokyo'"
}
},
"required": ["city"]
}
}
The model reads these descriptions to decide when and how to call each tool. This is why the names and descriptions matter so much — the LLM uses them as its instruction manual.
2. The LLM Decides to Call a Tool
Instead of generating a regular text response, the model returns a structured tool call — a JSON object specifying which function to invoke and with what arguments:
{
"tool_call": {
"name": "get_weather",
"arguments": { "city": "Tokyo" }
}
}
This is the key insight: the LLM never executes anything. It only requests that a function be called. The model's output is structured data, not arbitrary text.
3. Your Code Executes the Function
Your application receives the tool call, runs the actual function (hits a weather API, queries a database, whatever the tool does), and collects the result.
4. The Result Goes Back to the LLM
You send the tool's output back to the model as a new message in the conversation. The LLM reads the result and either generates a final answer or decides to call another tool.
User: "What's the weather in Tokyo?"
→ LLM requests: get_weather(city="Tokyo")
→ Your code returns: { "temp": "12°C", "condition": "Cloudy" }
→ LLM responds: "It's currently 12°C and cloudy in Tokyo."
That is the entire mechanism. Every AI agent framework — LangChain, OpenAI's Agents SDK, Anthropic's tool use — is built on top of this four-step loop.
Tool Calling vs Function Calling: Is There a Difference?
Short answer: no. The terms refer to the same mechanism, but different providers use different names.
| Provider | Term Used | Documentation |
|---|---|---|
| OpenAI | Function Calling | Function Calling Guide |
| Anthropic | Tool Use | Tool Use Overview |
| Function Calling | Gemini Function Calling |
OpenAI originally launched this capability as "function calling" in June 2023 and later expanded the terminology to "tool calling" to encompass broader use cases. The industry has largely settled on tool calling as the umbrella term, but you will see both used interchangeably in documentation and blog posts.
When you see "function calling," "tool use," or "tool calling" — it is the same thing.
What Makes a Good Tool?
The LLM picks which tool to call based entirely on the name, description, and parameter schema you provide. Poorly defined tools lead to wrong calls, missed calls, or hallucinated arguments. Here is what matters:
- Clear, specific names.
search_orders_by_emailbeatssearch. The model needs to distinguish between tools, and vague names make that harder. - Descriptive descriptions. Write them like you are explaining the tool to a new developer. Include when to use it and what it returns. "Searches the orders database by customer email address and returns the 5 most recent orders with status and tracking info" is far better than "Search orders."
- Simple parameter schemas. Flat objects with a few well-typed fields work best. Deeply nested or complex schemas confuse the model and lead to malformed calls.
- Structured return values. Return JSON, not free text. The model can reason more reliably about structured data.
- Narrow scope. One tool should do one thing. A
get_order_statustool and acancel_ordertool are better than amanage_orderstool that does everything.
These are not just best practices — they directly affect how accurately the LLM selects and calls your tools.
From Tool Calling to AI Agents
A single tool call is useful but limited. The real power comes from putting tool calling inside a loop.
Here is the difference:
- Tool calling (single turn): User asks a question → LLM calls one tool → returns an answer. Done.
- Agent loop (multi-turn): User gives a task → LLM calls a tool → reads the result → decides what to do next → calls another tool → reads that result → continues until the task is complete.
This loop is what turns an LLM into an AI agent. The ReAct pattern (Reason + Act) formalized this idea: the model alternates between reasoning about what to do and acting by calling tools, using each tool's output to inform the next step.
A customer support agent, for example, might:
- Call
lookup_customer(email)to find the account - Call
get_recent_orders(customer_id)to check order history - Call
get_order_status(order_id)for the specific order in question - Generate a reply to the customer with real data
Each step depends on the previous one. The agent decides the sequence at runtime based on what it learns. This is what separates agents from static workflows — the control flow is determined by the LLM, not hardcoded by a developer.
For a hands-on walkthrough, see How to Build an AI Agent from Scratch.
Real-World Tool Calling in Action
Tool calling is already everywhere, even if you do not see it:
- Coding assistants like Claude Code and GitHub Copilot use tool calling to read files, run terminal commands, and execute code — not by generating bash scripts, but by calling structured tools that the host application executes safely.
- Customer support bots call tools to look up order statuses, initiate refunds, and update account details in real time.
- Research agents chain web search tools, document retrieval tools, and summarization steps to compile answers from multiple sources — the pattern behind RAG-powered systems.
- MCP servers standardize tool calling across applications. Instead of every app implementing its own tool integration, the Model Context Protocol provides a universal interface that any LLM can use to connect to any external service.
- Multi-agent systems take this further — multiple LLMs calling tools independently, coordinating through shared state, each specialized for a different part of a complex task.
The pattern is always the same: describe the tool, let the model decide when to use it, execute it in your code, feed the result back.
Tool Calling Is the Primitive
Every capability you associate with AI agents — browsing the web, writing code, managing databases, orchestrating workflows — traces back to tool calling. It is not a feature. It is the mechanism.
Understanding this single concept gives you a mental model for everything else in the agent ecosystem: MCP is a protocol for discovering and sharing tools. Agent frameworks are loops that manage tool calls. Guardrails are constraints on which tools can be called and when.
Start here, and the rest clicks into place.
Reach 25,000+ AI enthusiasts every month
Promote your AI tool with featured placement, measurable visibility, and referral traffic.