visibian.HQ

Function calling: how a model uses tools

A model can only write text. Function calling lets it ask a program to do what it cannot, such as checking today's weather, and then use the result. Scroll to follow one real exchange, in the format of Anthropic's documentation.

Step 1 of 6

You ask a question.

You type into an app built on a model. The app is the go-between for everything that follows.

Step 2 of 6

The app sends the question and the tools on offer.

Each tool has a name, a sentence saying what it does, and a schema of the input it needs. The model reads the descriptions; it never sees the tool's code.

Step 3 of 6

The model asks for a tool instead of answering.

Its reply names the tool and the input, and ends with stop_reason "tool_use". That is the moment the model decides it needs something it does not know.

Step 4 of 6

The app runs the tool.

The app, not the model, calls the weather service. The model has no hands of its own.

Step 5 of 6

The result goes back to the model.

The app sends the answer back as a "tool_result", tied to the request it answers.

Step 6 of 6

The model answers in plain words.

With the result in hand it writes the reply. Web search works the same way, with search as the tool: see How assistants pick answers.

A language model can only produce text. Function calling lets it ask a program to do something it cannot, such as search the web or check today's weather, and then use the result in its answer.

The short version

The developer tells the model which tools exist, what each one does and what information it needs. When a question calls for a tool, the model replies with a structured request instead of an answer. The application runs the tool, sends back the result, and the model writes its reply from it.

Step through a real exchange

Figure 1A weather question, from the question to the answer
You
App
Model
Tool

Step 3 of 6. The model asks for the tool instead of answering

{
  "stop_reason": "tool_use",
  "content": [{
    "type": "tool_use",
    "name": "get_weather",
    "input": { "location": "London, UK" }
  }]
}
3 / 6
  1. You to app: You ask a question.
  2. App to model: The app sends the question and the tools it offers.
  3. Model to app: The model asks for the tool instead of answering.
  4. App to tool: The app runs the tool.
  5. Tool to model: The result goes back to the model.
  6. Model to you: The model answers in plain words.
The message format of Anthropic's Messages API, from its tool use documentation, read on 27 October 2026; the weather value is the documentation's own example. Other providers use different field names for the same steps.Source 1.

What a tool looks like to a model

A tool is described in three parts: a name, a sentence saying what it does, and a schema listing the information it needs, written in a standard format called JSON Schema. The model never sees the tool's code. It reads the description and decides. Anthropic's documentation says Claude "determines when to call a tool based on the user's request and the tool's description".[1]

So the description carries a lot of weight. A vague one can lead to a tool being used at the wrong moment, or not at all.

Who runs the tool

Usually the developer's own application runs the tool and sends back the result, as in Figure 1. Some tools run on the provider's side instead. Anthropic, for example, runs its web search tool on its own infrastructure and returns the results, with citations, in the same response.[1]

A short history

In February 2023, researchers at Meta showed with Toolformer that a model could teach itself when to call simple tools such as a calculator or a search engine.[2] OpenAI added function calling to its API on 13 June 2023: developers describe functions, and the model returns the arguments to call them with, as structured data.[3] In November 2024 Anthropic introduced the Model Context Protocol, an open standard for connecting AI tools to the systems where data lives, so that a connection written once can work with many assistants.[4]

Web search is a tool too

When an assistant searches the web before it answers, it is calling a search tool. The results come back as text, the model reads them, and they shape what it writes and which sources it cites. That is the step where a company's own pages can enter an answer, and How assistants pick answers follows it from there.

From Visibian, which measures what seven AI assistants say about a brand. See what Visibian does.

Sources

  1. Anthropic, Tool use with Claude, documentation read on 27 October 2026.
  2. Schick et al., Meta AI Research, Toolformer: Language Models Can Teach Themselves to Use Tools, arXiv:2302.04761, February 2023.
  3. OpenAI, Function calling and other API updates, 13 June 2023.
  4. Anthropic, Introducing the Model Context Protocol, 25 November 2024.