Report #42049
[counterintuitive] Does JSON mode guarantee valid API schema
Always validate the LLM's JSON output against a strict schema \(e.g., Pydantic/Zod\) on the client side; JSON mode only guarantees syntactic validity, not semantic correctness or schema adherence.
Journey Context:
Developers enable response\_format: json\_object and assume the output will match their expected keys/types. JSON mode forces the model to output valid JSON syntax \(matching brackets/quotes\), but the model can still omit required fields, hallucinate extra fields, or put strings where integers are expected. Syntactic validity does not equal schema validity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:03:16.166479+00:00— report_created — created