Does Structured Output Cost More Tokens?
The Input Token Overhead
When you include a JSON schema in your structured output request, that schema consumes input tokens. The schema is part of the system prompt or request parameters, and the provider's tokenizer counts it like any other input text. The overhead depends on schema complexity:
A simple schema with 3-5 flat fields (like a classification with sentiment, confidence, and reasoning) adds approximately 80-150 input tokens. A medium schema with 10-15 fields including nested objects and arrays adds approximately 200-400 input tokens. A complex schema with 20+ fields, multiple nesting levels, and detailed descriptions adds approximately 400-800 input tokens.
At current pricing for frontier models (approximately $3-15 per million input tokens depending on the provider), these overheads translate to fractions of a cent per request. A 300-token schema overhead on a request that already has 2,000 input tokens is a 15% increase in input tokens, but the absolute cost increase is negligible: about $0.001 per request at typical pricing.
OpenAI caches compiled schemas, which means the first request with a new schema may have slightly higher latency but subsequent requests benefit from the cached compilation. This does not affect token costs, only latency. Anthropic and Gemini handle schema processing differently, but the token cost impact is comparable across providers.
The Output Token Impact
Structured output typically generates slightly more output tokens than a free-text response for the same content, because JSON syntax includes structural characters (braces, brackets, quotes, colons, commas) that do not appear in prose. A free-text response of "The sentiment is positive with high confidence" becomes {"sentiment": "positive", "confidence": 0.95}, which has more syntactic characters but fewer content characters. The net output token count depends on the ratio of structured overhead to content.
For data-heavy responses (extraction, classification), the output token count with structured output is often lower than free-text because the model produces only the required fields instead of wrapping them in explanatory prose. A free-text extraction response might say "The invoice number is INV-2024-0871, dated March 15, 2024, for a total of $1,245.00 from Acme Corp" while the structured version returns only the field values without the connecting prose.
For responses that include a reasoning or explanation field, the output token count is higher than a pure data response but comparable to what the free-text response would have been, since the model generates similar explanatory content either way.
The bottom line: output token costs for structured output are roughly equivalent to free-text for the same content. You are not paying a significant premium for the JSON formatting.
The Retry Savings
This is where the economics favor structured output decisively. Without structured output, a prompt-based approach to JSON generation has a failure rate of 5-15% depending on the model and schema complexity. Each failure requires a retry, which doubles the cost for that request (or triples it if the retry also fails). At scale, these retries add up.
Consider a system processing 100,000 requests per day with a 10% failure rate and one retry per failure. Without structured output, you process 110,000 model calls per day instead of 100,000: a 10% cost increase from retries alone. With structured output, you process exactly 100,000 calls because structural failures never occur. The 100-300 extra input tokens per request from the schema are far cheaper than 10,000 extra full model calls from retries.
The math becomes even more favorable when you consider multi-retry scenarios. Some requests fail twice or three times before producing valid JSON, especially with complex schemas. And some never succeed, requiring human intervention that costs far more than any number of model calls. Structured output eliminates this entire category of failure, which is a cost reduction that does not appear in per-token accounting but shows up clearly in total pipeline cost.
Even with structured output, semantic validation failures (caught by Pydantic or Zod) may require retries. But these failures are much less common than structural failures, typically 1-3% versus 5-15%, and they resolve in one retry much more reliably because the error feedback is specific and actionable. The validation error handling page covers these recovery patterns.
Development and Maintenance Cost
Beyond API costs, structured output reduces development and maintenance costs. Without it, you write and maintain JSON parsing code, validation code, retry logic, error handling, and fallback paths. This code is not trivial: it handles edge cases from dozens of model response variations, it needs tests, and it breaks when model behavior changes. With structured output, most of this code disappears. You define a schema, receive a typed object, and use it directly. The reduction in code complexity reduces bug rates, speeds up development, and lowers the maintenance burden on the team.
This is hard to quantify in token costs, but engineering time is typically the largest cost in an AI integration. A developer spending a week building and debugging JSON parsing logic costs more than years of the schema token overhead at any reasonable request volume. The AI cost optimization pillar covers total cost of ownership for AI systems, including these development costs.
When Structured Output Increases Cost
There are scenarios where structured output genuinely increases total cost. The first is when you add a reasoning field to improve output quality: this field generates additional output tokens that would not exist in a non-structured response. The improvement in quality is usually worth the cost, but it is a real increase that you should account for in your budget.
The second is when your schema is very large relative to your input. If you have a 500-token schema and a 100-token input, the schema overhead is 500% of the input cost. This happens with complex extraction schemas applied to short text inputs. The solution is to simplify the schema or batch multiple short inputs into a single request.
The third is when you use structured output for tasks that do not need it. A conversational chatbot response that is displayed as text does not benefit from structured output, and adding it would add schema overhead with no offsetting benefit. Use structured output when your application consumes the response as data, not when it displays the response as text.
Cost Comparison Summary
For a typical production system processing structured data:
The schema overhead adds 100-500 input tokens per request, costing fractions of a cent. The elimination of structural retries saves 5-15% of total API cost. The elimination of semantic retries saves an additional 1-3%. The reduction in development and maintenance code saves engineering time. The net result is that structured output reduces total cost in nearly every scenario where the application consumes LLM output as data.
The only scenario where structured output increases cost is when you use it for tasks that do not need it, or when you add extensive reasoning fields to small, simple extraction tasks. For everything else, the economics are clearly in favor of structured output.
Structured output adds 100-500 input tokens per request but saves 5-15% in eliminated retries and reduces development costs by removing parsing, validation, and error handling code. The net cost impact is nearly always negative, meaning structured output saves money. Use it for all data-oriented LLM tasks and skip it only for free-text conversational output.