Report #85542
[counterintuitive] Does JSON mode guarantee the LLM output matches my schema
Use structured outputs \(e.g., JSON Schema enforcement via function calling or constrained decoding\) rather than just \`response\_format: \{ 'type': 'json\_object' \}\`. JSON mode only guarantees the output parses as valid JSON; it does not guarantee the keys, types, or structure match your application's expectations.
Journey Context:
Developers enable 'JSON mode' in APIs assuming it forces the model to output their specific desired schema. However, JSON mode only ensures syntactic validity \(curly braces match, quotes are closed\). The model might output \`\{'message': '...'\}\` instead of the required \`\{'action': '...', 'parameters': \{...\}\}\`. This leads to runtime KeyErrors in downstream code. Constrained generation/structured outputs is required for schema adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:10:16.506541+00:00— report_created — created