mysi Find

Brief in AI engineering

Structured output modes

States which vendor API settings force output to match a JSON Schema and which schema keywords each rejects.

All three constrain decoding to a JSON Schema subset. Anthropic rejects recursion, numeric bounds and string lengths with a 400 error. OpenAI allows recursion and numeric bounds but forces every field to be required. Google silently strips the length and count keywords it cannot enforce.

Facts

Item Anthropic (Claude API) OpenAI Google (Gemini API)
Schema-guaranteed final answer output_config.format with type: "json_schema" [1] text.format {type: "json_schema", strict: true, schema} [2] response_format {type: "text", mime_type: "application/json", schema} [3]
Schema-guaranteed tool input strict: true on a tool, same limits [1] strict: true in function calling [2] not stated on the page
additionalProperties must be false [1] must be false [2] boolean or a schema [3]
Optional fields allowed [1] not allowed: every field must be in required; a null union stands in [2] allowed [3]
Recursive schemas not supported [1] supported [2] supported ($ref: "#") [3]
minimum / maximum / multipleOf not supported, 400 error [1] supported, except on fine-tuned models [2] minimum and maximum supported [3]
minLength / maxLength not supported, 400 error [1] not in the supported string keywords (pattern, format) [2] stripped and ignored, no error [3]
minItems / maxItems minItems 0 or 1 only [1] supported, except on fine-tuned models [2] enforced [3]
Key order in output required keys first, then optional keys [1] same order as the schema [2] not stated on the page
  • Anthropic: not supported: oneOf, not, external $ref, complex types in enums, and anyOf beside type or properties in the same object [1].
  • Anthropic: regex pattern: no backreferences, no lookahead or lookbehind, no \b [1].
  • Anthropic, per request: at most 20 strict tools [1].
  • Anthropic, per request: at most 24 optional parameters and 16 union-type parameters across all strict schemas [1].
  • Anthropic: a schema that is too large returns 400 "Schema is too complex for compilation" [1].
  • Anthropic: grammar compilation times out after 180 seconds [1].
  • Anthropic: a compiled grammar is cached 24 hours from last use [1].
  • Anthropic: the old output_format parameter works only with the beta header structured-outputs-2025-11-13; without it, 400 [1].
  • Anthropic: citations return a 400 error; prefilling is not allowed [1].
  • Anthropic: enum and const capitalization is not guaranteed [1].
  • Anthropic: a refusal returns HTTP 200 with stop_reason: "refusal", and the output may not match the schema [1].
  • OpenAI: not supported: allOf, not, dependentRequired, dependentSchemas, if, then, else [2].
  • OpenAI: the root must be an object and must not be anyOf [2].
  • OpenAI schema limits: 5000 object properties, 10 nesting levels, 1000 enum values [2].
  • OpenAI: property names, definition names, enum and const values: at most 120,000 characters in total [2].
  • OpenAI: one string enum with more than 250 values: at most 15,000 characters [2].
  • OpenAI: a refusal appears in a separate refusal field [2].
  • OpenAI: JSON mode (type: "json_object") gives valid JSON only, and errors if the string "JSON" is missing from the context [2].
  • OpenAI: on GPT-6 and later, a configuration_update input item switches the schema mid-conversation [2].
  • Google: stripped without error: minLength, maxLength, minProperties, maxProperties, uniqueItems, contains, minContains, maxContains [3].
  • Google: a schema past the state, branching or nesting limits returns 400 INVALID_ARGUMENT [3].
  • Google: structured output combined with built-in tools is in preview, only on Gemini 4 and Gemini 3 series models [3].

Use it for

  • Choosing which vendor can enforce numeric bounds, recursion or optional fields inside the schema.
  • Predicting whether a schema keyword returns a 400 error (Anthropic, OpenAI) or is silently dropped (Google).
  • Not for checking whether the values are correct; every vendor validates shape only.

Sources

Tested

Tested 4 Dec 2026: claude-haiku-5-5 stated 7 of its 31 facts without this page and 27 with it; claude-fable-5-2 stated 16 of its 31 facts without this page and 30 with it.

Changes

Cite as: mysi, Structured output modes, mysi.dev/structured-output-modes, version 1, changed 2026-12-04. Text and data CC BY 4.0.