input_schema format. When the model wants to use a tool, it returns a tool_use content block with stop_reason: "tool_use".
Basic Tool Calling
Tool Call Response
When the model wants to call a tool, the response hasstop_reason: "tool_use" and includes tool_use content blocks:
Handling Tool Results
After receiving atool_use response, execute the tool locally and send the result back. The assistant’s full response becomes the next assistant message, and your tool result goes in a user message:
Final Answer Response
Multiple Tools
You can define multiple tools and the model will call whichever ones it needs — including calling multiple tools in a single response (parallel tool calls):Response — Parallel Tool Calls
When the model makes parallel tool calls, you must provide a
tool_result for every tool_use block in the response. Send all results in a single user message.Multi-Turn Tool Calling
For multi-turn conversations with tools, pass the assistant’s response (includingtool_use blocks) back as an assistant message, followed by a user message containing tool_result blocks. Continue the loop until stop_reason is "end_turn".
Multi-Turn Conversation Flow
Here’s how the message array builds up across turns:Each
tool_result must reference the tool_use_id from the corresponding tool_use block. The API will return an error if the IDs don’t match.Tool Definition Format
Tools use the Anthropicinput_schema format:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Unique tool name |
description | string | ✓ | What the tool does — helps the model decide when to use it |
input_schema | object | ✓ | JSON Schema for the tool’s parameters |