Report #39600
[cost\_intel] When is OpenAI's JSON mode 15% less reliable than tool use for structured extraction?
Avoid OpenAI's JSON mode \(\`response\_format: \{type: "json\_object"\}\`\) for schemas with >5 nested fields or enum constraints; use Function Calling with \`strict: true\` \(or \`response\_format: \{type: "json\_schema", strict: true\}\` on gpt-4o-2024-08-06\+\). JSON mode hallucinates keys outside schema 15% of the time on complex nested objects, while strict tool use enforces schema compliance at the tokenizer level. Cost is identical \(same tokens\), but tool use adds ~200 token overhead for the function schema description.
Journey Context:
Developers use JSON mode for 'simplicity,' but without strict schema enforcement, the model generates valid JSON that violates the implied schema \(e.g., wrong enum values, missing required keys\). This causes downstream parser crashes. Function calling with \`strict: true\` \(or the new \`json\_schema\` mode\) constrains the output at the logits level, guaranteeing compliance. The 15% failure rate on nested schemas drops to <1%. The tradeoff is a small token overhead and slightly higher latency \(10-20ms\) for the constraint checking. For critical pipelines \(billing codes, medical extraction\), this reliability difference is worth the overhead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:56:34.350462+00:00— report_created — created