Report #93258
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs \(JSON Schema enforcement\) or external Pydantic validation, not just \`response\_format: \{ "type": "json\_object" \}\`.
Journey Context:
Early JSON mode implementations only guarantee the output is parsable JSON \(valid syntax\), not that it conforms to a specific schema \(e.g., required fields, correct types\). The model might return an empty object \`\{\}\` or omit required keys while maintaining valid syntax. To guarantee schema adherence, you must use API features that enforce JSON Schema constraints or validate and retry externally.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:07:05.388110+00:00— report_created — created