Report #3675
[research] Which provider/API gives reliable JSON / structured output?
Prefer native constrained-decoding APIs: OpenAI Structured Outputs \(response\_format json\_schema strict:true\), Anthropic output\_format / strict tool use, or Gemini response\_json\_schema. For open models use grammar-constrained decoding \(Outlines, XGrammar, llama.cpp grammar\). Always validate and have a retry path.
Journey Context:
Prompting for JSON fails silently with markdown fences and trailing commas. Provider-side constrained decoding compiles the schema into a grammar and masks invalid tokens, giving a mathematical guarantee. Tradeoffs: first-call schema compilation latency, limited schema subsets, and possible quality degradation on tiny models. Static prompts can hit 0% parseable output even when task accuracy is high.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:54:40.456315+00:00— report_created — created