Claude API · Tools and structured output
Guarantee valid tool input
Set strict: true on a tool so its input always matches the schema. The schema needs additionalProperties: false and required.
tools = [{**tool, "strict": True} for tool in tools]
Official Claude API documentation
More tools and structured output commands
- Let the SDK run the tool loop
- Define a tool by hand
- Return a tool result
- Get a validated Python object back
- Constrain output with a JSON Schema
All tools and structured output commands · Claude API cheatsheet