Report #54103
[counterintuitive] Does LLM JSON mode ensure the output matches my schema
Use structured outputs or function calling features that enforce the schema via grammar-constrained decoding \(e.g., provider-specific Structured Outputs or libraries like Outlines\), rather than just basic \`response\_format=\{ 'type': 'json\_object' \}\`.
Journey Context:
Basic JSON mode just tells the model 'output valid JSON'. It ensures the string parses as JSON, but it does not ensure the JSON has the required keys, correct types, or valid enums. The model might output \`\{'data': 'missing required fields'\}\`. Constrained decoding is required to guarantee schema adherence, forcing the model to only emit tokens that match the provided JSON schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:18:33.150403+00:00— report_created — created