Introduction

Tool calling (also called function calling) is a capability that lets a language model request the execution of external functions or APIs — rather than generating a free-form text response, the model outputs a structured, machine-readable request specifying which tool to call and with what arguments, which your application then actually executes on the model's behalf. This transforms an LLM from a system that can only talk about the world into one that can actually act on it — checking a live weather API, querying a database, running a calculation, or triggering a real action in another system.

Tool calling is a specialized application of the structured output concepts covered earlier in this section, since the model's tool call itself is returned as a structured, predictable format (typically JSON) that an application can reliably parse and execute, rather than free text that would need to be interpreted.

Why Does Tool Calling Matter?

Tool calling helps to:

  • Let models access real-time or private information beyond their training data
  • Enable models to perform precise calculations rather than error-prone mental math (as covered in the Reasoning Limitations topic)
  • Allow models to trigger real actions — sending emails, updating records, booking appointments
  • Overcome the knowledge cutoff limitation by retrieving current, up-to-date information
  • Reduce hallucination risk for factual, retrievable information by grounding answers in actual tool results
  • Form the foundation for agentic AI systems that can plan and execute multi-step tasks

How Tool Calling Works

Whiteboard
Whiteboard diagram

A Simple Illustration

User: "What's the weather like in Tokyo right now?"

The model has no real-time data access on its own, but it has
been given access to a "get_weather" tool. Rather than guessing
or hallucinating an answer, it responds with a structured
tool call:

{
  "tool": "get_weather",
  "arguments": { "location": "Tokyo" }
}

The application executes the actual weather API call, gets
back: { "temperature": 18, "condition": "cloudy" }

This result is sent back to the model, which then generates
a natural response: "It's currently 18°C and cloudy in Tokyo."

Defining a Tool for the Model

This is the same structured schema approach covered in the
Structured Outputs topic — defining a clear "shape" the model
should follow. Here, instead of describing a desired response
format, the schema describes an available ACTION: its name,
what it does (so the model knows when to use it), and exactly
what arguments it requires.

The Full Tool Calling Request-Response Cycle

Multi-Step (Chained) Tool Calling
Some tasks require multiple tool calls in sequence, where each
result informs the next step:

User: "Book a table for 4 at a highly-rated Italian restaurant
near my hotel."

1. Call get_hotel_location() → returns coordinates
2. Call search_restaurants(location, cuisine="Italian",
   min_rating=4.5) → returns a list of options
3. Call book_table(restaurant_id, party_size=4) → confirms booking

The model can reason about which tools to call, in what order,
based on the results of previous calls — this chaining
capability is central to how AI "agents" accomplish multi-step
tasks, going beyond a single request-response exchange.

Parallel vs Sequential Tool Calls

AspectParallel Tool CallsSequential Tool Calls
DescriptionMultiple independent tools called at onceEach tool call depends on the result of the previous one
ExampleChecking weather in 3 different cities simultaneouslyLooking up a hotel's location, then searching nearby restaurants
EfficiencyFaster — no need to wait for one before starting anotherSlower — each step must complete before the next begins
Model SupportIncreasingly supported by modern modelsUniversally supported, the standard tool-use pattern

Tool Calling vs Plain Structured Output

AspectPlain Structured OutputTool Calling
PurposeFormatting the model's own final answer consistentlyRequesting an external action or data retrieval
Who Acts on the Output?The application simply parses and displays itThe application must execute a real function/API call
Typical ContentThe model's own generated content, structuredA tool name and arguments, not the model's final answer
Follow-Up Needed?No — the structured output IS the answerYes — the tool result is fed back for a final response

Key Properties of Tool Calling

  • Tool calling lets a model request execution of external functions rather than only generating text.
  • Each tool is defined with a name, description, and a structured schema for its expected arguments.
  • The model decides when a tool is needed and outputs a structured call; the application executes it.
  • Tool results are fed back to the model, which then generates a final, natural-language response.
  • Multi-step tasks often involve chaining several tool calls together, forming the basis of agentic AI behavior.

Where Is Tool Calling Used?

FieldApplication
AI AssistantsChecking real-time information like weather, stock prices, or news
Customer Support BotsLooking up order status or account details from internal systems
Coding AssistantsExecuting code, running tests, or searching documentation
Enterprise AutomationTriggering actions like sending emails or updating CRM records
Agentic AI SystemsChaining multiple tool calls to accomplish complex, multi-step tasks

Advantages

  • Grounds model responses in real, current data rather than relying solely on training data
  • Enables genuine actions, not just information retrieval or text generation
  • Reduces hallucination risk for factual, retrievable information
  • Supports complex, multi-step task automation through chained tool calls
  • Extends a model's capabilities far beyond what's possible through text generation alone

Limitations

  • Requires building and maintaining the actual tools/functions the model can call
  • The model can occasionally choose the wrong tool or provide incorrect arguments
  • Adds architectural complexity — application code must handle the request-execute-respond cycle
  • Tool execution introduces additional latency compared to a single text generation step
  • Security and permission considerations are critical, since tools can trigger real actions

Real-World Examples

ApplicationTool Calling Use
AI Travel AssistantsCalling flight search, hotel booking, and weather APIs
Customer Support SystemsLooking up order status or processing a return via internal tools
Coding AgentsExecuting code, running tests, and searching a codebase
Financial AssistantsRetrieving real-time stock prices or account balances
Smart Home AssistantsTriggering real actions like adjusting a thermostat or locking a door

Best Practices

  • Write clear, specific tool descriptions so the model reliably knows when and how to use each one.
  • Validate and sanitize tool arguments before executing any real action, especially for sensitive operations.
  • Design tools with clear, well-scoped responsibilities rather than overly broad, ambiguous functions.
  • Handle tool execution errors gracefully, feeding meaningful error information back to the model when needed.
  • Apply appropriate permission and safety checks before allowing a model to trigger consequential real-world actions.

Interview Tip

A common interview question is:

"What is tool calling, and how does it help address LLM limitations like hallucination and outdated knowledge?"

A strong answer is:

Tool calling lets a model request the execution of external functions or APIs by outputting a structured request — specifying which tool to call and with what arguments — rather than generating a free-form answer. This directly helps with hallucination and outdated knowledge because, instead of trying to recall or guess factual information from its training data, the model can retrieve real, current data from an actual source, like a weather API or a database, and ground its final response in that real result rather than a potentially incorrect internal guess.

Explicitly connecting tool calling back to hallucination and knowledge cutoff limitations makes your answer stronger.

Conclusion

Tool calling extends language models beyond text generation into genuine action-taking and real-time information retrieval, using the same structured output principles covered earlier in this section to reliably request external function execution. As a foundational capability behind modern agentic AI systems, tool calling represents one of the most practically important techniques for building LLM applications that go beyond conversation into real-world usefulness.