Report #40897
[counterintuitive] Does enabling JSON mode ensure the LLM output matches my specific schema
Use Structured Outputs with json\_schema enforcement rather than basic JSON mode, and always validate the output schema on the client side.
Journey Context:
Developers enable response\_format=\{ type: json\_object \} assuming it forces the model to output their exact Pydantic schema or data structure. Basic JSON mode only guarantees the output is parseable JSON \(valid syntax\), not that it conforms to a specific schema \(e.g., it might omit required keys or use wrong data types\). OpenAI introduced Structured Outputs with json\_schema to enforce schema adherence, but even then, client-side validation remains necessary for robustness against edge cases.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:06:59.099994+00:00— report_created — created