Study FAQ
When should I use JSON outputs or strict tool use in the Claude API?
Also asked as 2
- What is the difference between output_config.format and strict tool use in the Claude API?
- Should I constrain Claude’s final JSON response, its tool arguments, or both?
Answer
Use output_config.format with type json_schema to constrain Claude’s response text to a JSON Schema. Set strict: true on a tool when the model-generated inputs to that tool need schema constraints. On a supported Claude Messages API configuration, you can use both in one request when an application needs reliable tool arguments and a typed final response.
Both mechanisms use a supported subset of JSON Schema. For example, object schemas require additionalProperties: false, and recursive schemas are unsupported. Check the model and deployment availability before making either feature mandatory. Enabling the API’s interleaved citations together with output_config.format produces a request error. You can still define a field for application-owned evidence IDs and verify those IDs yourself.
Check the completion state and validate accepted output. The application owns whether a value is supported by evidence and whether an operation is permitted.
Full explanation
Structured Outputs, Validation, Retry, and Batch Patterns
Study guide · CCAR-F
Read the full explanation