What Breaks in Structured Output: Prerequisites, Token Overhead, and Schema Enforcement Limits

ELI5
Structured output prompting constrains what a language model can generate to match a specific schema. The schema is compiled into a grammar before generation begins — which is why it reliably works and why certain patterns break it silently.
The pipeline looks clean: schema in, valid JSON out. The failure arrives quietly — a regex pattern silently ignored, a recursive reference that never compiled, a union type that exceeded the provider’s hard limit without a warning. Understanding Structured Output Prompting means understanding what the enforcement engine actually runs, not what the documentation implies it runs.
The gap between those two things is where production failures accumulate.
The Grammar That Compiles Before Your Request Arrives
Not a post-processing filter. Constrained Decoding compiles your JSON Schema into a finite-state machine or context-free grammar before inference begins — something closer to a type-checker for token sequences than a validator that rejects bad output after the fact. The model cannot sample tokens that violate the structure because those tokens become unreachable in the grammar state machine. Compiled grammars make violations structurally impossible — for the features the grammar engine actually supports.
The distinction between “for supported features” and “always” is where most production assumptions break.
What do you need to know before using structured output prompting with LLMs?
The first prerequisite is understanding which enforcement layer your stack uses, because the supported feature sets differ significantly between them.
API-side enforcement — where the provider compiles the schema on their infrastructure — is available on OpenAI (GPT-4o, GPT-5.x) and Anthropic (Opus 4.8/4.7/4.6, Sonnet 4.6/4.5, Haiku 4.5, per Anthropic Docs). Both providers cache compiled grammars for 24 hours; changing the schema invalidates the cache and triggers recompilation on the next request. OpenAI strict mode requires that all fields appear in required and every object sets additionalProperties: false — hard structural requirements, not configuration options (OpenAI Docs).
Self-hosted enforcement runs on your infrastructure via XGrammar or Outlines (v1.3.0, after significant API breaking changes introduced in v1.0.0). XGrammar-2 became the default structured generation backend for vLLM, SGLang, and TensorRT-LLM as of March 2026 (MLC Blog). Schema compilation now takes 5.37 ms on average — down from 534 ms in XGrammar v1 — with per-token generation overhead below 40 μs (MLC Blog). At serving scale, that overhead is near-zero.
The prerequisite that most documentation skips: not all JSON Schema features are supported on any platform.
OpenAI strict mode does not support oneOf at the root or array item level, the format keyword, default values, recursive $ref references, or root-level anyOf (OpenAI Docs). Anthropic does not support recursive schemas, minimum/maximum/multipleOf numeric constraints, minLength/maxLength, minItems values above one, or regex patterns with backreferences or lookahead assertions (Anthropic Docs). The Anthropic platform also imposes a 180-second compilation timeout on schemas that approach its complexity ceiling; schemas that exceed it fail to compile. Hard limits on both platforms cap strict tools at 20 per request, optional parameters at 24 total, and union-type parameters at 16.
Across all constrained-decoding engines, if/then/else conditionals, unevaluatedProperties, and recursive $ref remain unsupported — no current framework handles all 45 JSON Schema feature categories, according to a Jan 2025 benchmark study (JSONSchemaBench arxiv; directional data, framework versions have evolved since).
Tooling above the provider level adds its own constraints. The
Instructor library wraps provider APIs with retry logic, but its Mode.FUNCTIONS is being deprecated — users should migrate to Mode.TOOLS_STRICT or Mode.RESPONSES_TOOLS (instructor Docs).
BAML’s Schema-Aligned Parsing takes a different approach entirely: rather than enforcing grammar at decode time, SAP parses schema-conforming content out of broken JSON, markdown-wrapped responses, or chain-of-thought preambles after the model has already generated them.
One pattern that worked reliably a year ago has stopped working. Anthropic’s April 2026 model updates removed the prefill trick — starting the model’s response with {" to force
Structured Output — from current models (Anthropic Docs). Applications relying on prefill need to migrate to native structured output via output_config.format.
Breaking changes & deprecations:
- Anthropic prefill (April 2026): Prefill with
{"to force JSON output is no longer supported in current Anthropic models. Migrate to nativeoutput_config.formatstructured output.- instructor
Mode.FUNCTIONS: Pending deprecation. Migrate toMode.TOOLS_STRICTorMode.RESPONSES_TOOLS.- outlines v1.0.0: Model loaders renamed (
transformers()→from_transformers());generatemodule replaced byGeneratorconstructor. Current stable version: v1.3.0.
Where Schema Complexity Turns Into Budget and Latency
Structured output changes what the model generates. It also changes how many tokens that generation consumes, how long each request takes to return, and — less obviously — whether complex reasoning chains survive the format constraint intact.
These costs scale with schema complexity. The scaling is not linear, and it compounds.
What are the technical limitations of structured output prompting?
Token overhead is the first cost to account for. A 3-field schema adds roughly 50 tokens per request; a 20-field schema adds roughly 500; a deeply nested schema with many objects and arrays can add roughly 2,000 tokens per request. These figures are approximate, derived from third-party measurement without primary benchmark backing, so treat them as directional order-of-magnitude guidance. The compounding effect is output verbosity: JSON token count runs approximately 40% higher than an equivalent natural-language answer for simple outputs, and fully populated structured responses can consume two to three times more tokens than unstructured equivalents. Latency follows — constrained decoding requests run approximately 10–30% slower per request in the uncached case; grammar caching softens this on repeat requests, but every new schema (and every cache expiry after 24 hours) pays the full compilation cost.
Format constraints measurably degrade reasoning. An EMNLP 2024 study found that stricter format constraints led to greater degradation of reasoning performance on GSM8K and similar tasks (“Let Me Speak Freely?” paper). The mechanism is not definitively settled — whether format constraints occupy attention that reasoning needs, or narrow the sampling distribution in ways that disadvantage multi-step logic. The degradation is reproducible and scales with constraint strictness.
Coverage gaps are where enforcement fails most visibly. The Jan 2025 JSONSchemaBench study evaluated six constrained-decoding frameworks against roughly 10,000 real-world schemas from production sources (JSONSchemaBench arxiv). On GitHub-Hard schemas — the complex end of the distribution — Guidance reached 41% coverage, Llamacpp 39%, XGrammar 28%, Outlines 3%, OpenAI 9%. On Kubernetes configuration schemas, XGrammar reached 7%. These are directional data from a specific point in time; framework versions will have improved. The pattern they reveal — complex schemas fail at high rates across all frameworks — is structural, not incidental.
Silent failures compound the coverage problem. During that same evaluation, XGrammar emitted 38 outputs that violated schema constraints but were reported as successful; the engine was under-constrained, produced structurally-invalid content, and reported it as valid (JSONSchemaBench arxiv). That failure mode is harder to catch than a parse error: the output passes JSON.parse() but violates your constraints without signaling failure. You only discover it when something downstream rejects data that should never have arrived.

What the Enforcement Ceiling Predicts
The mechanism makes certain failure modes predictable before you encounter them.
If your schema uses oneOf at the root level, OpenAI strict mode will not enforce it. No error. No warning. Unconstrained output with valid JSON wrapping. If you are building recursive structures — trees, graphs, nested object chains with self-referential types — expect compilation failure across all major providers; recursive $ref appears in every provider’s exclusion list. If the task is reasoning-heavy — multi-step extraction, structured analysis with conditions, nested scoring logic — the format constraint will compete with the reasoning chain; expect degradation, particularly at smaller model scales.
If you use the format keyword for string validation ("format": "date-time", "format": "email"), OpenAI strict mode silently ignores it. The field parses. The constraint does not apply. The strings that come back will parse as JSON but may fail your downstream validator.
Fewer fields mean sharper reasoning. The EMNLP 2024 finding translates into a design principle: schema minimalism has two simultaneous benefits — it reduces token overhead and it preserves more of the model’s effective reasoning capacity per request. A lean schema that captures what the application actually needs will out-reason a sprawling one that attempts to capture everything in one pass.
The asymmetry worth noting: some unsupported features are rejected loudly (recursive $ref typically fails compilation), while others are silently dropped (format values, default specifications). There is no consistent failure mode — the engine’s behavior on unsupported features depends on which feature and which engine, which means you cannot rely on errors to discover what is not being enforced.
Rule of thumb: Design schemas against the provider’s documented exclusion list, not the JSON Schema specification. The spec is larger than what any provider or library actually enforces; treat the documented exclusions as hard architectural constraints, not aspirational limits.
When it breaks: Silent under-constrained failures — where the engine produces schema-violating output without signaling failure — are both the hardest failure mode to catch and the most common on complex schemas. Build downstream schema validation even when using constrained decoding; the enforcement guarantee only holds for features the grammar engine actually supports.
The Data Says
Constrained decoding prevents generation of tokens that violate the schema for the features it supports — the mechanism is sound. The gaps are in coverage: no current framework handles the full JSON Schema specification, every provider maintains its own exclusion list, and silent failures occur when engines are under-constrained rather than fail-loud. Token overhead and latency scale with schema complexity, and format constraints measurably degrade reasoning on complex tasks. The practical implication is that schema minimalism is not a style preference — it is the design decision with the most direct impact on cost, latency, and reasoning quality simultaneously.
AI-assisted content, human-reviewed. Images AI-generated. Editorial Standards · Our Editors