POST
Tool Use

Overview

Tool use lets developers define functions that Claude can call when it needs information it does not have or actions it cannot perform itself. Claude does not execute the function — it tells your application which function to run and with what arguments. Your application runs it, passes the result back, and Claude continues. This is how AI applications connect to the real world — payment systems, databases, live APIs, internal tools.

The Tool Use Lifecycle

Tool use takes two requests to complete:

Request 1 — Define the Tool

Pass your tool definitions in the tools array alongside the user message:

Tool Definition Fields

Each tool in the tools array requires three fields:
The description field is the most important part of your tool definition. Claude decides whether and how to call a tool based entirely on this description. A vague or incomplete description leads to missed or incorrect tool calls. Write it as if explaining the function to a junior developer.

Response 1 — The Tool Use Block

When Claude decides a tool is needed it returns a tool_use content block instead of a text response:
Three critical fields to note: Claude read “What is the current price of Bitcoin?” and correctly identified the right tool and the right argument — based purely on your tool description.
Copy the content[0].id value from this response. You need it exactly in Request 2 — both in the assistant message and in the tool result. The IDs must match or the request will fail.

Request 2 — Return the Tool Result

Pass the full conversation history including Claude’s tool call response and your tool result:

Response 2 — Final Text Response

Claude reads the tool result and generates a natural language response:
stop_reason returns to end_turn — the tool use cycle is complete.

Token Cost of Tool Use

Tool definitions are included in input tokens on every request — whether Claude uses the tool or not: Tool use is significantly more token-intensive than standard messaging. For cost-sensitive applications, keep tool definitions concise and only include tools that are relevant to the current context.

Multiple Tools

You can define multiple tools in a single request. Claude selects the right one based on the user’s message and each tool’s description:
If the user’s message requires multiple tools, Claude can return multiple tool_use blocks in a single response.

Controlling Tool Use Behavior

You can control when and how Claude uses tools with the tool_choice parameter:

Further Reading

Messages

How tool results fit into the messages array structure

Tokens

Why tool definitions are the biggest driver of input token costs

Streaming

Combine streaming and tool use for real-time agent applications

Error Handling

Handle tool use errors and failed tool calls gracefully

Authorizations

x-api-key
string
header
required

Headers

anthropic-version
string
required
Example:

"2023-06-01"

Body

application/json
model
enum<string>
required

The Claude model to use.

Available options:
claude-sonnet-4-6,
claude-opus-4-6,
claude-haiku-4-5
Example:

"claude-sonnet-4-6"

max_tokens
integer
required

Maximum number of output tokens to generate.

Required range: x >= 1
Example:

1024

messages
object[]
required
tools
object[]

List of tools Claude can call during the response.

Response

Successful response — may contain tool_use content block

id
string
Example:

"msg_01XFDUDYJgAACzvnptvVoYEL"

type
string
Example:

"message"

role
string
Example:

"assistant"

content
object[]
model
string
Example:

"claude-sonnet-4-6"

stop_reason
enum<string>
Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use
Example:

"end_turn"

stop_details
object | null
usage
object