Lesson 0.2 · 2 of 5 · 6 min read · Reviewed 24 Nov 2026
Give the model one tool
By the end, you can
- Describe a tool with a name, a description and an input schema.
- Explain who runs a tool when the model asks for one.
A model on its own cannot know today’s weather or look up an order. A tool lets it ask your code to do that.
The idea
You describe the tool in the request:
const tools = [{
name: 'get_weather',
description: 'Get the current weather for a city. Use it for any question about weather. Returns temperature in Celsius and conditions.',
input_schema: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] },
}];
When a question needs the tool, the reply has stop_reason: "tool_use" and a block like this:
{ "type": "tool_use", "id": "toolu_01", "name": "get_weather", "input": { "city": "Lisbon" } }
That block is a request. The model is asking you to run get_weather with { city: "Lisbon" }.
How it fails
A vague description such as “weather stuff” makes the model guess between tools, or skip the tool and make something up. Write the description for a new colleague: what it does, when to use it, what it returns. In the Playground’s Tool design lab you can watch the simulator guess when descriptions are vague.
Key points
- A tool is a function you describe to the model: a name, a description of when to use it, and a JSON schema for its input.
- The model never runs your tool. It replies with a tool_use block, and your code runs the function.
- The description matters more than the code: it is all the model sees when choosing.
Describe a tool and catch its request
Write a clear tool definition and see the model ask your code to run it.
You will have: A get_weather tool definition and a script that prints the tool_use block the model returns.
Steps
- Fill in the tools list with a name, a description and an input_schema with a required city.
- Run it and check that stop_reason is tool_use.
- Loop over response.content and print the name and input of each tool_use block.
- Make the description vague ("weather stuff") and rerun to see what changes in the Trace tab.
Done when
- stop_reason prints as tool_use.
- The printed input contains the city Lisbon.
- You can say in one sentence who runs the tool and what goes back.
Open in the Playground No API key needed.
Starter code (Python)
import anthropic
client = anthropic.Anthropic()
# TODO: describe get_weather: a name, a description that says what it does, when to use it
# and what it returns, and an input_schema with a required "city" string.
tools = []
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=300,
tools=tools,
messages=[{"role": "user", "content": "What's the weather in Lisbon right now?"}],
)
print("stop_reason:", response.stop_reason)
# TODO: loop over response.content and print the name and input of any tool_use block
Show a solution
import anthropic
client = anthropic.Anthropic()
tools = [{
"name": "get_weather",
"description": "Get the current weather for one city. Use it whenever the user asks about weather now. Returns the temperature in Celsius and the conditions.",
"input_schema": {
"type": "object",
"properties": {"city": {"type": "string", "description": "City name, for example Lisbon"}},
"required": ["city"],
},
}]
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=300,
tools=tools,
messages=[{"role": "user", "content": "What's the weather in Lisbon right now?"}],
)
print("stop_reason:", response.stop_reason)
for block in response.content:
if block.type == "tool_use":
print("the model asks us to run:", block.name, dict(block.input))
print("who runs it? our code, then we send a tool_result with tool_use_id", block.id[:9] + "...")
Do it Give the model a tool in the Playground in the Playground. No API key needed.