Report #22514
[counterintuitive] Enabling JSON mode ensures the model output matches your expected data schema
Use JSON mode only for parseability. Always validate model output against your schema with a library like Pydantic or Zod. For stronger structural guarantees, use structured outputs with JSON Schema constraints, which constrain generation more tightly than JSON mode alone. Never pass model output to downstream systems without validation.
Journey Context:
JSON mode guarantees that the output is valid JSON—properly formatted, parseable. It does NOT guarantee the JSON has the right keys, types, required fields, or structure. A model in JSON mode can return \{"error": "something"\} when you expected \{"name": "string", "age": "number"\}. The common mistake is assuming JSON mode provides schema enforcement, leading to runtime errors when downstream code tries to access fields that don't exist or have wrong types. The newer structured outputs feature, which uses JSON Schema constraints during generation, is much stronger but still not perfect—edge cases in complex schemas can still produce unexpected outputs. The right call is defense in depth: use the strongest structural constraint available \(structured outputs over JSON mode over plain text\), then validate at the application layer. Treat model output like any untrusted external input.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:12:02.436255+00:00— report_created — created