Claude API · Tools and structured output

Constrain output with a JSON Schema

Use output_config.format when you want raw JSON that follows your schema.

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    messages=[{"role": "user", "content": "Extract the name from: John Smith wants the Enterprise plan."}],
    output_config={"format": {"type": "json_schema", "schema": {
        "type": "object",
        "properties": {"name": {"type": "string"}},
        "required": ["name"],
        "additionalProperties": False,
    }}},
)

Official Claude API documentation

More tools and structured output commands

All tools and structured output commands · Claude API cheatsheet

Was this page helpful?