Report #83503
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use Structured Outputs \(e.g., providing a JSON schema in \`response\_format\` or function calling\) to enforce schema constraints, not just basic JSON mode.
Journey Context:
Developers enable 'JSON mode' thinking it will enforce required keys, enums, and types. JSON mode only guarantees syntactically valid JSON \(matching brackets, valid strings\), but the model might omit required fields or hallucinate incorrect data types. Structured outputs constrain the decoding step to only generate tokens that conform to the provided JSON schema, guaranteeing both syntactic and structural validity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:44:43.480579+00:00— report_created — created