Describe why structured-output mode quietly raises the per-call token bill
Switching from free-text completions to strict-JSON or structured-output mode usually raises the realized cost per useful answer by 10-40%, even when the underlying information returned is identical. Name the three mechanisms responsible and explain how each adds tokens or wall-clock time.
Structured-output mode adds 10-40% to output cost via three axes: constrained-decoding mask hurts speculation acceptance, JSON syntax adds envelope tokens, and parse failures cause retries.
Imagine asking someone for an answer in two ways. First, just tell me. Second, fill out this fixed form with labeled boxes (name, age, address). The second response always takes more words because of the labels, the brackets, and the formal structure, even when the underlying information is the same. On top of that, the person has to slow down while writing to make sure every label is spelled right and every bracket matches; rules force corrections. And occasionally they hand back a form that has a typo and you ask them to redo it, doubling the work for that one. That is what JSON mode does to an LLM: more words for the envelope, slower per word because of the rules, and the occasional do-over.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: three cost axes + constrained sampling and speculation drop + envelope overhead + retry tax + schema design tips + grammar-aware speculation.
Real products, models, and research that use this idea.
- Outlines and llguidance are the production-grade grammar-aware sampling libraries used by vLLM, TGI, and Together AI to enforce JSON Schema during decoding.
- OpenAI Structured Outputs (introduced 2024) uses a constrained sampler and documents that strict schema mode can be slightly slower per request than free-text completion.
- Anthropic Claude Opus 4.7 and Sonnet 4.6 support tool use with JSON Schema; their documentation recommends compact field names to minimize the envelope token tax.
- Together AI published benchmarks in 2026 showing speculative-decoding acceptance dropping from 0.72 to 0.48 under JSON Schema constraints on Llama 4 Maverick.
- Production teams at Stripe and Notion have documented 20-30% output token cost increases when migrating routes from free-text to structured outputs, citing all three axes.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does grammar-aware speculative decoding restore some of the lost acceptance rate?
QWhat is the right schema-design philosophy for low cost under structured output?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing JSON mode is free because the model already produces structured-looking text. Constrained decoding actively masks tokens, lowering speculative-decoding acceptance, and the schema envelope tokens are real billed output.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.