Core concepts
Tool use
Let models call your functions and act on the results.
Models can call tools (functions) you define. You describe the tools, the model decides when to call one and with what arguments, you run it, and you feed the result back for the model to continue.
All text models support tool use.
Define tools
Pass a tools array on a Messages request. Each tool has a name, a description, and a JSON Schema for its input:
The loop
- The model responds with a
tool_usecontent block naming the tool and its input. - You run the tool and send the result back as a
tool_resultblock in a newusermessage. - The model uses the result to produce its final answer.
Use tool_choice to force a specific tool, require any tool ({"type": "any"}), or leave it to the model ({"type": "auto"}, the default).
SDK helpers
The Anthropic SDKs provide helpers that manage the tool loop for you. See SDKs.