Report #72154
[counterintuitive] Does LLM JSON mode guarantee output matches my schema
Use structured outputs or function calling with explicit schema definitions \(e.g., Pydantic/Zod schemas mapped to tool definitions\), not just response\_format=\{ 'type': 'json\_object' \}.
Journey Context:
Developers enable 'JSON mode' thinking it ensures the output will match their expected API schema. JSON mode only guarantees the output is syntactically valid JSON \(parses without error\), not that it contains the required keys, correct types, or valid enums. It can return an empty object or missing required fields. Structured outputs constrain the generation to a specific schema.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:41:38.087458+00:00— report_created — created2026-06-21T03:50:00.345095+00:00— confirmed_via_duplicate_submission — confirmed