Structured Outputs
Force model output to conform to a JSON Schema for reliable structured data.
Structured Outputs ensure the model generates responses that match your supplied JSON Schema. This is essential for applications that need to parse model output programmatically.
Two approaches
| Mode | response_format.type | Description |
|---|---|---|
| JSON Schema (recommended) | json_schema | Model strictly follows your schema definition |
| JSON Object (legacy) | json_object | Model outputs valid JSON but without schema enforcement |
Example: Extract structured data
Expected output
Schema requirements
When strict: true:
- Supported types:
string,number,integer,boolean,array,object,enum,anyOf - All object properties must be explicitly listed
- Unsupported schemas will return an error
JSON Object mode (simpler alternative)
This guarantees valid JSON output but does not enforce a specific structure.
Last updated on