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:

curl https://api.spoofzone.com/v1/messages \
-H "x-api-key: $SPOOF_API_KEY" \
-H "content-type: application/json" \
-d '{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "tools": [
    {
      "name": "get_weather",
      "description": "Get the current weather for a city.",
      "input_schema": {
        "type": "object",
        "properties": { "city": { "type": "string" } },
        "required": ["city"]
      }
    }
  ],
  "messages": [{ "role": "user", "content": "What is the weather in Tokyo?" }]
}'

The loop

  1. The model responds with a tool_use content block naming the tool and its input.
  2. You run the tool and send the result back as a tool_result block in a new user message.
  3. 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.

Tool use | Spoof