Structured outputs
Structured outputs make the model emit data that matches a JSON Schema, so downstream code can parse it without retries. “JSON mode” (valid JSON only) is weaker: OpenAI’s docs say only Structured Outputs ensure schema adherence. Anthropic describes its version as grammar-based constrained decoding.
| Vendor | How | Notes from docs |
|---|---|---|
| OpenAI | text.format = json_schema with "strict": true; also strict in function calling | Available from gpt-4o-2024-08-06 and later; refusals arrive as a distinct refusal item, detectable in code; some schema features unavailable |
| Anthropic | output_config.format = json_schema, plus strict: true on tools | GA on current Claude models (Opus 5.5, Sonnet 5.5, Fable 5.1 and others) and on Bedrock, Google Cloud and Foundry |
| Google Gemini | response_format with mime_type: application/json and a schema; Pydantic/Zod supported | Supports a JSON Schema subset including minimum/maximum, prefixItems; very large or deeply nested schemas may be rejected; docs tell you to validate values in your app |
Anthropic limits worth knowing
Not supported: recursive schemas, numeric constraints (minimum/maximum), string length constraints, minItems above 1, external $ref URLs, complex regex. At most 20 strict tools, 24 optional parameters and 16 union-typed parameters per request. The first request pays grammar-compilation latency; compiled grammars are cached 24 hours. Changing the format invalidates the prompt cache (prompt-caching). Output can still be invalid on a refusal or max_tokens stop.
Caveats (all vendors)
- Schema-valid does not mean correct: values can be wrong. Validate and evaluate (llm-as-judge-and-evals).
- Not the same thing as MCP
structuredContent/outputSchema, which describes tool results (tool-description-design). - With Claude 4.6 and later, prefilling the answer with
{is no longer available; Anthropic’s migration advice points to structured outputs instead (prompting-reasoning-models).
Sources
- https://developers.openai.com/api/docs/guides/structured-outputs (2026-09-30)
- https://platform.claude.com/docs/en/build-with-claude/structured-outputs (2026-09-30)
- https://ai.google.dev/gemini-api/docs/structured-output (2026-09-30)
- https://modelcontextprotocol.io/specification/2026-07-28/server/tools (2026-09-30)