Report #87218
[counterintuitive] Does enabling JSON mode in the LLM API guarantee the output matches my specific JSON schema
Use structured outputs or function calling features that enforce schema constraints \(like OpenAI's Structured Outputs or Anthropic's tool use\), or implement Pydantic validation with retries on top of basic JSON mode.
Journey Context:
Developers enable 'JSON mode' assuming it will output the exact keys and types they specified in the prompt. JSON mode only guarantees the output is parseable JSON \(valid syntax\), not that it adheres to a specific schema. The model might omit required keys, add hallucinated keys, or use wrong data types. Recent APIs have introduced true schema-constrained generation to solve this exact limitation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:58:55.988324+00:00— report_created — created