Report #71979
[counterintuitive] Does JSON mode ensure LLM output matches my schema
Use structured outputs \(function calling / schema enforcement\) or external validation \(Pydantic\) instead of relying solely on \`response\_format=\{ 'type': 'json\_object' \}\`.
Journey Context:
Developers enable JSON mode assuming it guarantees the output will conform to their specific schema \(keys, types, structure\). Standard JSON mode only guarantees the output \*parses\* as valid JSON \(no syntax errors\). The model can easily emit \`\{"error": "I don't know"\}\` instead of \`\{"name": "string", "age": int\}\`. To guarantee schema adherence, you must use explicit structured outputs \(like OpenAI's Structured Outputs with Pydantic schema enforcement\) or function calling, which constrains the generation logits to match the schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:23:52.116838+00:00— report_created — created