Home › Learn › AI Agents
AI Agents

What is Tool calling?

The mechanism that lets an LLM request an external function — with structured JSON arguments — which your code then executes and returns.

How it works

The model doesn't run code itself. It emits a tool_use block naming a tool and its inputs; your dispatcher runs the real function and sends the result back as a tool_result. This is how an agent touches the world: search, files, APIs, databases.

Example

In practiceYou define a web_search(query) tool; when the agent needs current info it calls it with a query, your code runs the search, and the result goes back into the conversation.

What makes a good tool definition?

A clear name, a precise description the model can reason about, and a strict input schema. Vague tools get called wrong.

Go deeper: Deploy Your First AI Agent

The complete, step-by-step guide — every command, config, and the reasoning behind it.

Get the guide