Report #59300
[counterintuitive] Does LLM JSON mode guarantee valid API schemas
Always validate LLM JSON output against a strict schema \(e.g., JSON Schema, Pydantic\) on the application side. Use Structured Outputs instead of basic JSON mode.
Journey Context:
Developers enable 'JSON mode' assuming the output will perfectly match their expected schema \(e.g., always has required fields, correct types\). JSON mode only guarantees the output parses as valid JSON \(no syntax errors\). It does not guarantee the schema is correct \(e.g., missing keys, wrong data types, hallucinated keys\). Structured Outputs features were introduced specifically to fix this, but basic JSON mode remains a trap.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:01:29.645463+00:00— report_created — created