Overview
Structured Outputs force the model’s response to strictly follow a JSON Schema you define, ensuring the return value can be parsed directly by your program without regex or post-processing. Unlike asking the model to “please return JSON” in the prompt, Structured Outputs rely on Constrained Decoding: the upstream provider compiles the JSON Schema into grammar rules and constrains generation token-by-token during inference, making it impossible for the model to produce output that violates the schema. Typical use cases:- Extracting entities and fields from unstructured text
- Classification / labeling / sentiment analysis
- Standardized passing of intermediate results in multi-step reasoning
- Strongly-typed constraints on Agent tool call parameters
Protocol Parameter Comparison
The parameter names differ across the three protocols, but the underlying mechanism is the same: the model output strictly matches the JSON Schema you provide.
Quick Start
OpenAI Protocol (Recommended)
Works with all models that support Structured Outputs, across providers.Using Other Models (GLM-5.2 Example)
The same OpenAI protocol parameters work with all models that support Structured Outputs — just switch themodel.
Python
Claude Native Protocol
Call directly with the Anthropic SDK using theoutput_config.format parameter.
Schema Writing Guidelines
Required Fields
Allobject types must explicitly declare additionalProperties: false; otherwise some upstream providers will reject the request.
Nested Objects
Nestedobject types also require additionalProperties: false:
Cross-Protocol Schema Differences
Auto-Degradation Mechanism
The gateway enables auto-degradation protection for Structured Outputs on all requests by default. When the model or platform does not support it, the gateway will not return an error. Instead, it automatically strips the Schema constraint and marks the degradation reason in a response header. Your request will still receive a normal model response — the output simply won’t be strictly constrained by the Schema. This means you can safely enable Structured Outputs uniformly on the client side without having to check compatibility for each model:- Seamless multi-model switching: When switching models between Claude, GPT, Gemini, and GLM with the same codebase, requests won’t fail even if the target model doesn’t support Structured Outputs
- Transparent fallback: Even when the model version that ends up handling your request doesn’t support Structured Outputs, the request still completes normally, with degradation flagged in the response header
- Simplified client logic: No need to maintain a list of “which models support Structured Outputs” — the gateway handles it automatically; the client only needs to check the response header to decide whether additional parsing is needed
Response Header
Detection Example
Python
Difference from json_object Mode
FAQ
Which models support Structured Outputs?
Which models support Structured Outputs?
Claude series (via Anthropic API’s
output_config.format):- Opus / Sonnet / Haiku 4.5 and above
- Fable / Mythos 5 and above
response_format):- GPT-4o and above, GPT-5 series
responseSchema):- Gemini 2.5 and above
Is the JSON Schema modified during cross-protocol calls?
Is the JSON Schema modified during cross-protocol calls?
Yes. When calling Claude models via the OpenAI protocol, the gateway automatically:
- Converts
response_formattooutput_config.format - Removes Schema keywords not supported by Anthropic (
minimum,maxLength, etc.) - Marks
schema_keywords_strippedin the response header if any keywords were stripped
Can Structured Outputs be used together with Extended Thinking?
Can Structured Outputs be used together with Extended Thinking?
Yes. The
format (Structured Outputs) in output_config and the effort (thinking intensity) in reasoning are independent parameters that can be set simultaneously:How does the degradation mechanism compare to other aggregation platforms like OpenRouter?
How does the degradation mechanism compare to other aggregation platforms like OpenRouter?
Most API aggregation platforms return an error outright when a model does not support Structured Outputs. AIHubMix uses a graceful degradation strategy: it automatically strips incompatible parameters, returns the model response normally, and informs the client of the degradation reason via the
X-Structured-Output-Degraded response header. Your application will not break because of this.