Report #99940
[counterintuitive] JSON mode guarantees the response will match my schema.
Use structured outputs with response\_format type json\_schema and strict: true \(or strict tool/function schemas\). Treat json\_object mode as legacy: it only promises syntactically valid JSON, not required keys, correct types, or absence of extra keys.
Journey Context:
Many tutorials still say 'ask for JSON and set response\_format to json\_object'. OpenAI's structured-outputs docs explicitly contrast the two: JSON mode ensures valid JSON only; structured outputs enforce schema adherence via constrained decoding \(grammar masking at the token level\). Strict mode requires all properties in required and additionalProperties: false. For optional fields use nullable types. If your provider lacks strict mode, add validation and retries, but do not trust prompt-only JSON.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T05:19:17.287977+00:00— report_created — created