Report #69464
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs \(function calling / constrained decoding\) or always validate output with a schema validator \(like Pydantic/Zod\) and implement a retry loop.
Journey Context:
Developers enable \`response\_format=\{ "type": "json\_object" \}\` and assume the output will perfectly match their expected keys. JSON mode only guarantees the output is syntactically valid JSON \(i.e., it parses without error\), not that it adheres to a specific schema \(missing keys, wrong types, hallucinated keys\). OpenAI's newer 'Structured Outputs' with \`json\_schema\` fixes this, but the old JSON mode does not.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T23:04:56.032761+00:00— report_created — created