Reference · API
OpenAI structured outputs
Last updated
Return **JSON matching a schema** — reliable parsing for agents and APIs.
Return **JSON matching a schema** — reliable parsing for agents and APIs.
Endpoint
POST https://api.openai.com/v1/chat/completionsRequest
{
"model": "gpt-4o-mini",
"messages": [{ "role": "user", "content": "Extract order fields from: Order #8821, $42, shipped" }],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "order",
"schema": {
"type": "object",
"properties": {
"order_id": { "type": "string" },
"amount_usd": { "type": "number" },
"status": { "type": "string" }
},
"required": ["order_id", "amount_usd", "status"],
"additionalProperties": false
},
"strict": true
}
}
}