Report #83719
[counterintuitive] Does LLM JSON mode guarantee valid data schemas
Use Structured Outputs \(JSON Schema enforcement\) or external Pydantic validation, because basic JSON mode only guarantees valid JSON syntax, not adherence to your specific keys or types.
Journey Context:
Developers enable JSON mode thinking it means the output will match their desired schema. It only guarantees the output parses as JSON without syntax errors. The model can still omit required fields, hallucinate extra fields, or use wrong data types \(e.g., string instead of integer\). OpenAI introduced Structured Outputs specifically to enforce the schema via constrained decoding, which basic JSON mode does not do.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:06:35.418454+00:00— report_created — created