Card book

Tool calling

In the kitchen: The toolbox and scales

The AI writes a note naming a tool and what to give it; your program runs the tool and hands the result back.

What it is

A model on its own can only write. It can't weigh, calculate or look things up. Tool calling gives it a list of tools, each with a name, what it does and what to give it. When the model decides it needs one, it writes "use this tool, with these inputs". Your program really runs it and hands the result back, and the model carries on with its answer.

In the AI Kitchen

In the AI kitchen, the chef never touches the scales. It hands out a note, "scales: weigh the fish", the kitchen weighs it and hands back the reading, and the chef tells the customer the weight and the price. The labels on the tool rack are the tool list. Which tool to use, and when, is the chef's own call.

In real life

With the Claude API you describe your tools in the request (name, description, input format). Claude replies with a tool_use, your code runs it and sends the result back as a tool_result. Weather lookups, web search, databases, email and computer use all plug in this way.

Where to try it

Related concepts