Skip to main content

Structured outputs

Structured outputs guarantee that the model response conforms to a JSON schema you define. Use this for typed API responses, database records, configuration objects or any case where free text is not acceptable.

JSON mode

Set response_format: {type: "json_object"} to receive valid JSON.

JSON schema

For stricter validation, supply a JSON schema using json_schema mode:

Anthropic format

Structured outputs work in the Messages API using the same response_format parameter.

Limitations

Complex nested schemas with recursive references or union types may not be fully supported. Test your schema on a representative sample before deploying to production.