Report #77265
[counterintuitive] Does LLM JSON mode guarantee valid data schema
Use strict structured output features \(like OpenAI's Structured Outputs with \`strict: true\` or Pydantic-based schemas\) rather than basic JSON mode, and still validate the semantic content of the fields.
Journey Context:
Developers enable 'JSON mode' thinking it guarantees their expected schema. Basic JSON mode only guarantees the output parses as valid JSON; it doesn't guarantee the keys, types, or required fields match your schema. The model might output \`\{"error": "cannot fulfill"\}\` instead of the expected object. Providers had to introduce specific constrained decoding features to actually enforce schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:17:18.684928+00:00— report_created — created