Report #86952
[counterintuitive] JSON mode guarantees schema validation
Always pair JSON mode with a strict JSON Schema specification in the prompt and a validation layer \(like Pydantic\) in your code. Better yet, use Structured Outputs \(JSON Schema enforcement\) if the API supports it, but still validate business logic.
Journey Context:
Developers enable \`response\_format=\{ 'type': 'json\_object' \}\` and assume the output will perfectly match their expected schema. This is false. JSON mode only guarantees valid JSON syntax \(i.e., it won't cut off mid-bracket\). The model can still omit required keys, invent new keys, or put strings where integers should be. Structured Outputs is a newer, separate feature that actually enforces the schema, but even then, business logic validation is still required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:32:24.540340+00:00— report_created — created