Skip to main content

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

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 the model.
Python

Claude Native Protocol

Call directly with the Anthropic SDK using the output_config.format parameter.

Schema Writing Guidelines

Required Fields

All object types must explicitly declare additionalProperties: false; otherwise some upstream providers will reject the request.

Nested Objects

Nested object types also require additionalProperties: false:

Cross-Protocol Schema Differences

When calling Claude models via the OpenAI protocol, the gateway automatically converts the Schema format and strips incompatible keywords — no manual adaptation needed.

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

json_object mode cannot be converted to the Claude native protocol. If you send response_format: {"type": "json_object"} to Claude via the OpenAI protocol, the response header will mark json_object_unsupported_on_anthropic degradation. Use the json_schema type instead.

FAQ

Claude series (via Anthropic API’s output_config.format):
  • Opus / Sonnet / Haiku 4.5 and above
  • Fable / Mythos 5 and above
OpenAI series (via response_format):
  • GPT-4o and above, GPT-5 series
Gemini series (via responseSchema):
  • Gemini 2.5 and above
Check each model’s capability tags on the Models page.
Yes. When calling Claude models via the OpenAI protocol, the gateway automatically:
  1. Converts response_format to output_config.format
  2. Removes Schema keywords not supported by Anthropic (minimum, maxLength, etc.)
  3. Marks schema_keywords_stripped in the response header if any keywords were stripped
The reverse direction (calling OpenAI models via the Claude protocol) is also automatically converted.
Yes. The format (Structured Outputs) in output_config and the effort (thinking intensity) in reasoning are independent parameters that can be set simultaneously:
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.