Structured Output: OpenAI vs Anthropic vs Gemini Compared
OpenAI Structured Output
OpenAI launched structured output in August 2024 and has the most mature implementation. The feature is accessed through the response_format parameter on chat completions.
The API syntax uses response_format: {"type": "json_schema", "json_schema": {"name": "schema_name", "strict": true, "schema": {...}}}. The name field is required and must be a valid identifier. When strict is true, the constrained decoding engine enforces the schema during generation. When strict is false or omitted, the model will attempt to follow the schema but without the hard guarantee, which makes it functionally similar to JSON mode with a suggested structure.
Schema support: OpenAI supports objects, arrays, strings, numbers, integers, booleans, enums, and null types. Union types use anyOf. All properties in an object must be listed in the required array when strict mode is enabled. Optional fields are expressed as {"anyOf": [{"type": "string"}, {"type": "null"}]}. Nesting is supported up to 5 levels deep. Maximum schema size is 100 properties across all levels. Recursive schemas are supported with a maximum recursion depth.
Model support: GPT-4o, GPT-4o-mini, GPT-5, GPT-5.2, and o-series reasoning models all support structured output. The feature works identically across models, with more capable models producing higher-quality content within the schema constraints.
Limitations: additionalProperties must be set to false in strict mode. patternProperties, if/then/else, and format keywords (except for enums) are not supported. The maximum total number of properties across all levels of nesting is 100. Schema compilation adds a small amount of latency to the first request with a new schema, but compiled schemas are cached for subsequent requests.
Legacy JSON mode: OpenAI still supports response_format: {"type": "json_object"} for basic JSON mode without schema enforcement. Their documentation recommends json_schema for all new development.
Anthropic Claude Structured Output
Anthropic introduced structured output as a public beta in November 2025 (beta header: structured-outputs-2025-11-13) and moved to general availability in 2026. The GA implementation uses the output_config parameter instead of the beta's output_format, though the beta parameter continues to work during the transition period.
The API syntax uses output_config: {"format": {"type": "json_schema", "json_schema": {"schema": {...}}}}. Anthropic also supports strict mode on tool definitions with "strict": true, which constrains tool call parameters to match the tool's input schema exactly. This dual approach, structured responses for direct output and strict tool use for function calling, gives developers two complementary paths to schema-enforced output.
Schema support: Anthropic supports the same core JSON Schema features as OpenAI: objects, arrays, primitives, enums, and anyOf unions. The constrained decoding is implemented through grammar-based token masking during inference. All properties must be in the required array, and optional fields use the anyOf-with-null pattern.
Model support: Structured output is generally available on Claude Opus 4.6, Opus 4.5, Sonnet 5, Sonnet 4.6, Sonnet 4.5, Haiku 4.5, and later models including Opus 4.7 and Opus 4.8. It is also available through Amazon Bedrock for Claude models and through the Anthropic Agent SDK.
Limitations: Schema nesting depth limits apply, similar to OpenAI. Some advanced JSON Schema features are not supported. The key difference from OpenAI is the API surface: Anthropic's structured output is integrated into both the messages API (for direct structured responses) and the tools API (for strict tool use), providing flexibility in how you structure your application.
No legacy JSON mode: Anthropic skipped the JSON mode step entirely. They went straight from prompting-for-JSON to schema-enforced structured output. If you want the equivalent of JSON mode (valid JSON, no schema), you can use a very permissive schema or use tool definitions without strict mode.
Google Gemini Structured Output
Google has supported structured output in Gemini since 2024, with ongoing improvements through 2026. The implementation is accessed through the generation_config parameter.
The API syntax uses generation_config: {"response_mime_type": "application/json", "response_schema": {...}}. The response_schema parameter accepts a JSON schema or, in the Python SDK, a Pydantic model or Python type hint. Setting response_mime_type to "application/json" enables JSON output, and the response_schema constrains it to the specified structure.
Schema support: Gemini supports objects, arrays, primitives, enums, and nested types. The Python SDK has a particularly developer-friendly feature: you can pass a Pydantic model class directly as the response_schema, and the SDK converts it to a JSON schema automatically. This eliminates the need to manually write JSON schemas if you are already using Pydantic for data validation.
Model support: Gemini 1.5 Pro, Gemini 1.5 Flash, Gemini 2.0, and later models support structured output. The feature is available through both the Gemini API and Vertex AI.
Limitations: Gemini's schema support has historically been slightly more limited than OpenAI's, particularly around union types and complex nested structures. The implementation has improved significantly through 2025 and 2026, and for most production schemas the differences are negligible. One notable feature is that Gemini supports enum constraints on both string and numeric types, which is useful for classification tasks with numeric codes.
Feature Comparison
Here is how the three providers compare across the features that matter most in production:
Schema compliance guarantee: All three providers offer 100% schema compliance through constrained decoding. The guarantee is equally strong across providers.
Maximum nesting depth: OpenAI supports 5 levels. Anthropic and Gemini have similar limits, though the exact numbers vary by implementation version. For most production schemas, 3-4 levels is sufficient.
Union types (anyOf): All three providers support anyOf, primarily used for nullable fields and discriminated unions. OpenAI's implementation is the most documented and tested.
Enum support: All three support string enums. Gemini additionally supports numeric enums. Enums are the mechanism behind reliable classification, where you want the model to choose from a predefined set of labels.
Streaming: All three providers support streaming structured output, where you receive tokens as they are generated. This is important for long responses where you want to show progress or begin processing before the full response is available. See the streaming structured output page for implementation details.
SDK support: OpenAI's Python and Node SDKs have native structured output support with Pydantic and Zod integration. Anthropic's SDK supports structured output through the messages API and Agent SDK. Google's Python SDK accepts Pydantic models directly as schemas, which is the most ergonomic developer experience.
Schema caching: OpenAI caches compiled schemas, so the first request with a new schema has slightly higher latency but subsequent requests use the cached compilation. Anthropic and Gemini handle schema compilation differently but the user-facing impact is similar: negligible latency overhead after the first request.
Which Provider to Choose
For structured output specifically, the choice between providers usually depends on factors other than the structured output implementation, because all three have reached functional parity on the core capability. The meaningful differences are in model quality for your specific use case, pricing, latency, and ecosystem integration.
Choose OpenAI if you need the most mature and documented implementation, if you are already in the OpenAI ecosystem, or if you need the widest range of supported schema features. Their structured output has been in production longest and has the largest body of community knowledge and troubleshooting resources.
Choose Anthropic if you are building with Claude models for their reasoning quality, if you need the dual structured-response and strict-tool-use approaches, or if you are using the Anthropic Agent SDK. Claude's structured output is newer but functionally equivalent, and Claude models often produce higher-quality content within the structural constraints.
Choose Gemini if you are in the Google Cloud ecosystem, if you want the Pydantic-native schema definition in the Python SDK, or if you need Vertex AI integration for enterprise compliance. Gemini's structured output is practical and well-integrated with Google's AI platform.
For applications that need to work across providers, the Instructor library provides a unified interface for structured output that works with all three providers plus several others. This abstracts away the API differences and lets you switch providers without changing your application code. The Instructor library page covers this multi-provider approach.
Multi-Provider and Open-Source Options
Beyond the three majors, structured output is available through several other channels. Azure OpenAI mirrors OpenAI's implementation for enterprise deployments. Amazon Bedrock supports Anthropic's structured output for Claude models. OpenRouter provides a unified API that supports structured output across multiple providers.
For open-source models, inference engines like vLLM and TensorRT-LLM implement their own constrained decoding, allowing you to get structured output from any model you host yourself. The Outlines library provides grammar-guided generation for open-source models, supporting JSON Schema, regex patterns, and custom grammars. These open-source options are important for applications with data residency requirements or cost sensitivity that makes self-hosting attractive.
All three major providers now offer schema-enforced structured output with 100% compliance guarantees. The implementations differ in API syntax and minor feature details, but the core capability is equivalent. Choose your provider based on model quality, pricing, and ecosystem, not on structured output differences. If you need provider portability, use the Instructor library to abstract the API differences.