Report #58743
[counterintuitive] Does LLM JSON mode guarantee the output matches my schema
Use structured outputs / function calling with strict schema enforcement \(like OpenAI's Structured Outputs or instructor/guidance libraries\) rather than just \`response\_format=\{ "type": "json\_object" \}\`.
Journey Context:
Basic JSON mode ensures the output parses as valid JSON, but it does not guarantee the keys, types, or required fields match your expected schema \(e.g., it might omit required fields or use wrong types\). Structured outputs constrain the generation at the token level to adhere strictly to a provided JSON schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:05:17.248612+00:00— report_created — created