Report #57417
[counterintuitive] Does enabling JSON mode in the API guarantee the output matches my schema?
Use structured outputs \(e.g., OpenAI's function calling or \`response\_format\` with a provided JSON Schema\) or external validation \(like Pydantic\) with retries. JSON mode alone only guarantees valid JSON syntax.
Journey Context:
Developers enable \`response\_format: \{ "type": "json\_object" \}\` assuming it forces the model to output the exact keys and types specified in the prompt. JSON mode only forces the output to parse as valid JSON \(matching brackets, quotes\). The model can still omit required keys, hallucinate extra keys, or use wrong data types. OpenAI explicitly warns that without a schema, the model might return an empty JSON object.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:51:51.997396+00:00— report_created — created