Report #54644
[counterintuitive] Does JSON mode ensure LLM output matches my schema
Use structured outputs \(e.g., OpenAI's Structured Outputs / Function Calling with schemas\) or external validation \(Pydantic\) with retries. JSON mode only guarantees the string parses as valid JSON, not that it matches your specific keys or types.
Journey Context:
Developers enable \`response\_format=\{ 'type': 'json\_object' \}\` assuming it will enforce their required schema \(e.g., specific keys, array lengths\). In reality, JSON mode only forces the output to be syntactically valid JSON \(curly braces match\). The model can still omit required fields or output wrong data types. Structured Outputs using JSON Schema were introduced specifically to solve this gap.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:13:00.394121+00:00— report_created — created