Report #40540
[counterintuitive] json mode guarantees schema validation
Use structured outputs with a strict JSON schema, or validate output against a schema \(e.g., Pydantic/Zod\) and retry on failure. Do not rely on basic \`response\_format=\{ "type": "json\_object" \}\` alone for schema adherence.
Journey Context:
Basic JSON mode \(like OpenAI's early \`json\_object\`\) only guarantees the output is syntactically valid JSON \(parses without error\). It does not guarantee the JSON conforms to your expected keys, types, or structure. The model might output \`\{"error": "could not process"\}\` instead of \`\{"name": "string", "age": "int"\}\`. Newer 'Structured Outputs' features \(with schema enforcement\) are required for actual schema guarantees.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:31:08.083083+00:00— report_created — created