Tool Use: How LLMs Call Tools
Tool use (function calling) lets an LLM do more than write text โ it can call real functions. This is the foundation of every AI agent.
The basic problem
On its own, an LLM can only generate text. It can't save a file, query a database, or send an email. Tool use (also called function calling) solves this: you describe available "tools" to the model โ for example a function "send_email" or "get_weather" โ together with a schema describing what input they need.
How the cycle works
When the model decides a tool is needed, it doesn't reply with normal text. It replies with a structured "tool_use" block: the tool's name plus input parameters as JSON. Your application reads this block, performs the actual action (the API call, the database query), and sends the result back to the model as a "tool_result". The model uses that result to keep working or to write a final answer.
Why this is the foundation of every agent
An agent is essentially an LLM that calls tools in a loop: ask, use a tool, read the result, pick the next tool, repeat until the task is done. Without tool use, a model stays a pure text generator with no effect on the real world.
One important property
The model never executes code itself. It only decides when to call a tool and with which arguments. The actual execution โ and with it, control over risk โ stays with your application.
EXAMPLE
A weather tool is defined as { name: 'get_weather', input_schema: {location: string} }. The user asks: 'What's the weather in Berlin?' Claude replies with a tool_use block: { name: 'get_weather', input: {location: 'Berlin'} }. Your app calls the real weather API and sends the result back as a tool_result. Only then does Claude turn it into a worded answer.
๐ ๏ธ EXERCISE โ TRY IT YOURSELF
Define a simple tool schema for a task of your choice (e.g. 'search_product') and have an LLM generate the matching tool_use call.
- Write a JSON schema with a name, description, and 1-2 input parameters for your tool.
- Write a user question that clearly requires this tool, and give it to a model together with the schema.
- Check the response: did a correct tool_use block come back with sensible arguments?
โ SELF-CHECK
- โ Did the model pick the right tool (instead of, say, just guessing an answer directly)?
- โ Were the arguments in the tool_use block correctly extracted from the user's question?
- โ What would happen if the tool description were vague โ did you test that?
QUICK QUIZ
What happens when Claude wants to call a tool?
SOURCES
- Anthropic Docs: Tool Use Overview โ platform.claude.com
- Anthropic Docs: How Tool Use Works โ platform.claude.com
- OpenAI Docs: Function Calling โ developers.openai.com