Report #75837
[counterintuitive] json mode guarantees schema validation
Use Structured Outputs with a specific JSON schema or an external validation library \(like Pydantic\) to catch missing keys or wrong types; basic JSON mode only guarantees valid JSON syntax.
Journey Context:
Developers enable response\_format: \{ 'type': 'json\_object' \} and assume the output will match their expected keys and data types. Basic JSON mode only ensures the string parses as JSON without syntax errors; it does not enforce schema adherence. The model can return empty objects, missing required keys, or incorrect data types \(e.g., a string instead of an integer\). To guarantee schemas, you must use constrained decoding \(Structured Outputs\) or validate externally.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:53:35.597368+00:00— report_created — created