latentbrief
← Back to concepts

Concept

Tool Calling / Function Calling

The mechanism that lets AI models request to run external tools - searching the web, executing code, querying databases - and incorporate the results into their responses.

Added May 18, 2026

A language model on its own can only draw on knowledge from its training. It cannot search the web, run code, query a database, check the weather, or send an email. Tool calling - also called function calling - is the protocol that extends a model's reach to external systems, giving it the ability to take actions and retrieve real-time information.

The mechanism works through a defined protocol. The model is given a list of available tools, each described with its name, purpose, and parameters. During generation, when the model determines that a tool would be useful, it outputs a structured call - a JSON object specifying which tool to invoke and with what arguments - rather than a natural language response. An external system intercepts this structured call, executes the tool, and returns the result to the model. The model then continues generating its response, now informed by the tool's output.

For example, a model asked "what is the current stock price of Apple?" cannot answer from training data. With tool calling, it generates a structured call to a stock price API with the symbol "AAPL". The API returns the current price, and the model incorporates this into its answer: "Apple's current stock price is $X."

OpenAI standardised the function calling interface in 2023, and it has since been widely adopted. Anthropic's tool use API follows a similar pattern. These standardised interfaces allow developers to define tool schemas in JSON and let the model determine when and how to invoke them without explicit programming of every possible situation.

Tool calling is the foundational mechanism for agentic AI. An agent is, at its core, a language model with tool calling in a loop: generate a response or tool call, execute tool calls, observe results, generate the next response or tool call, and repeat until the task is complete. Without reliable tool calling, agents cannot take actions in the world.

Analogy

A manager who, instead of memorising every fact they might need, knows which experts to call for which questions. When a question comes up that requires specialist knowledge, the manager picks up the phone, gets the answer, and incorporates it into their response. Tool calling gives AI models this same ability to reach out to the right resource for each specific need.

Real-world example

ChatGPT's code interpreter plugin uses tool calling: when a user asks a mathematical or data analysis question, the model writes Python code, calls the code execution tool, receives the computed result, and presents it to the user. The model determines when calculation is needed, generates the code, and incorporates the results - all through the tool calling mechanism.

Why it matters

Tool calling is what transforms language models from knowledgeable conversationalists into capable agents that can act in the world. The ability to search, compute, query, and communicate through structured tool interfaces is what makes AI useful for tasks that require access to current information, precise calculation, or interaction with external systems.

In the news

Related concepts