Claude API · Tools and structured output

Define a tool by hand

A tool has a name, a description and a JSON Schema for its input. Claude replies with a tool_use block when it wants to call it.

tools = [{
    "name": "get_weather",
    "description": "Get the current weather for a city.",
    "input_schema": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"],
    },
}]

Official Claude API documentation

More tools and structured output commands

All tools and structured output commands · Claude API cheatsheet

Was this page helpful?