API
Structured JSON
Request machine-readable JSON and validate it before use.
JSON object mode
Choose a model whose json_mode capability is true. Tell the model what object to return and set response_format.
{
"model": "worker",
"messages": [
{"role": "system", "content": "Return JSON with keys severity and summary."},
{"role": "user", "content": "The health check has failed for six minutes."}
],
"response_format": {"type": "json_object"}
}
JSON schema mode
Clients that support JSON schema can send response_format.type as json_schema with a schema definition. Keep schemas small and explicit. Use required fields and disable additional properties when unexpected keys would be unsafe.
Always parse and validate the returned content in your application. A valid JSON document can still contain an invalid business value. Do not use generated JSON directly in SQL, shell commands, access-control decisions, or financial actions.
