Report #68353
[counterintuitive] Using JSON mode to guarantee output schema adherence
Use Structured Outputs with a defined JSON Schema \(e.g., Pydantic model\) which guarantees 100% schema adherence at the token level.
Journey Context:
Old JSON mode only guaranteed the output was valid JSON, not that it contained the right keys or types. Developers wrote complex regex or retry logic to handle missing keys. Structured Outputs constrain the decoding to follow the schema exactly, making parsing failures and schema validation errors a thing of the past.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:13:04.184585+00:00— report_created — created