Report #100197
[research] How do I get reliable JSON/structured output from LLM APIs?
Use provider-native strict structured outputs \(response\_format json\_schema with strict: true on OpenAI, strict tool schemas on Anthropic, response\_schema on Gemini\) instead of legacy JSON mode or prompt-only schemas. Always add your own semantic validation after parsing because schema compliance does not guarantee correctness.
Journey Context:
JSON mode only promises valid JSON, not that fields or types match. Strict structured outputs use constrained decoding \(CFG/grammar\) so the model cannot emit a token that violates the schema, eliminating parse failures and missing required fields. First call per schema may incur a small compilation delay; reuse schemas. Each provider supports a slightly different JSON Schema subset, so test your schema and never trust structure alone for business-critical values.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T04:49:06.833269+00:00— report_created — created