Report #76409
[counterintuitive] Enabling JSON mode means the model will return data matching my schema
Always validate model outputs against your schema with a parser/validator \(JSON Schema, Pydantic, Zod\). JSON mode guarantees syntactic validity only — it says nothing about keys, types, required fields, or semantic correctness.
Journey Context:
Developers enable JSON mode and assume their downstream parsing will work. JSON mode constrains the token distribution to produce syntactically valid JSON \(matching braces, quoted strings\), but places no constraint on: which keys appear, value types \(string vs number vs null\), required vs optional fields, enum values, or nested structure depth. The model can produce perfectly valid JSON that crashes your application. Structured output features \(OpenAI's structured outputs, Anthropic's tool\_use\) improve this by constraining the schema at the token level, but even these can produce semantically incorrect values within a valid schema \(e.g., a valid integer that's out of range, or a valid string that's a hallucinated value\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:50:51.683831+00:00— report_created — created