Docs / Features
Structured outputs
Force a model to return JSON matching a schema you define, instead of free-form text.
How to use it
Pass response_format with a JSON Schema. Models that support structured outputs constrain generation to match the schema; unsupported models ignore the field.
JSON
{
"model": "openai/gpt-5.5-pro",
"messages": [{"role": "user", "content": "Extract the invoice total"}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "invoice",
"schema": {
"type": "object",
"properties": { "total": { "type": "number" } },
"required": ["total"]
}
}
}
}Tips
Keep schemas shallow, name fields clearly, and add a system message describing the task. Strict schemas with deep nesting reduce reliability on smaller models.