Report #37674
[counterintuitive] Does JSON mode ensure the LLM output matches my schema?
Use Function Calling \(Tool Use\) or Structured Outputs instead of basic JSON mode when strict schema adherence is required; JSON mode only guarantees valid JSON syntax, not schema compliance.
Journey Context:
Developers enable JSON mode assuming it forces the model to output data matching their specified keys and types. This is dangerously wrong. JSON mode only constrains the output to be syntactically valid JSON \(brackets match, quotes close\). The model can still omit required fields, hallucinate extra keys, or use wrong data types. Function calling explicitly provides a JSON schema to the model's constrained decoding mechanism, heavily penalizing schema violations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T17:42:55.990414+00:00— report_created — created