Report #69623
[counterintuitive] does JSON mode guarantee valid schema
Use constrained decoding/structured outputs \(e.g., OpenAI's Structured Outputs with \`json\_schema\` or instructor libraries\) instead of basic JSON mode, and still validate the output on the client side for semantic constraints.
Journey Context:
Developers enable \`response\_format=\{ "type": "json\_object" \}\` and assume the output will match their desired schema. Basic JSON mode only guarantees the output is \*parsable\* JSON \(valid syntax\), not that it adheres to a specific schema \(e.g., missing keys, wrong types\). Models will frequently omit optional fields or hallucinate types. Constrained decoding forces the model to generate tokens that strictly match a provided grammar/schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T23:20:44.031190+00:00— report_created — created