9io.ai / Blog

Structured outputs compared: which JSON Schema each LLM API enforces

How OpenAI, Claude, Gemini, Mistral, vLLM and SGLang enforce structured outputs, the JSON Schema each accepts, and the failures you still have to catch.

Key takeaways

  • OpenAI in strict mode, Claude, Gemini, vLLM and SGLang enforce your schema; Mistral doesn’t document how.
  • A response cut off at the token limit breaks the schema on every API, and refusals can too.
  • OpenAI requires every field; its nullable workaround counts against Claude’s limit of 16 union-type parameters.
  • Gemini silently ignores minLength, maxLength, uniqueItems and similar keywords, so check them in code.
  • MCP’s 2026-07-28 revision allows any JSON Schema 2020-12 keyword in tool schemas, including ones strict modes reject.

Structured outputs make a model answer in JSON that matches a schema you supply. As of 5 November 2026, OpenAI (with strict: true), Anthropic and Google enforce the schema inside their APIs, and the open-source servers vLLM and SGLang do it with grammar libraries such as xgrammar and llguidance. Mistral accepts a strict flag but doesn’t document how it enforces it. Each accepts a different subset of JSON Schema, and none promises usable JSON on every call. A response cut off at the token limit, or a refusal, still reaches your parser, so check the stop reason, validate with Pydantic or Zod, and retry on purpose.

The differences bite when one schema has to serve several providers. OpenAI’s strict mode rejects a schema with any optional field. Anthropic rejects recursion and numeric bounds, and caps the optional and nullable fields in a request. Gemini accepts string length limits and then ignores them without an error. Since MCP’s 2026-07-28 revision, a tool schema from an MCP server may use any JSON Schema 2020-12 keyword, including several that these strict modes refuse.

Below, we compare the six from their documentation and source code, list what enforcement still lets through, show a validation and retry wrapper, and end with a checklist for portable schemas. We haven’t benchmarked any of them.

How each API asks for structured outputs

OpenAI, Anthropic and Google each offer a response format for the model’s answer and a separate strict setting for tool arguments. The open-source servers accept OpenAI’s request shape.

API Response format Tool arguments How it is enforced Streaming First request with a new schema
OpenAI Responses API: text.format with type: "json_schema", name, schema and strict: true. Chat Completions: response_format with type: "json_schema" and a json_schema object strict: true on the function Schema adherence guaranteed with strict: true; the docs don’t describe the mechanism Yes, with refusals streamed as separate events Extra latency while the API processes the schema, then none
Anthropic output_config.format with type: "json_schema" and schema strict: true on the tool Grammar-constrained sampling Yes Grammar compiles first, then stays cached for 24 hours after last use; 180-second compile timeout
Google Gemini Interactions API: response_format with type: "text", mime_type: "application/json" and schema. generateContent: responseMimeType plus responseSchema or responseJsonSchema validated tool-choice mode Schema compiled into a state machine that constrains token generation Yes; chunks join into the final JSON Not documented
Mistral response_format with type: "json_schema" and a json_schema object holding name, schema and strict Not documented Not documented; the schema is also added to the system prompt Not documented Not documented
vLLM 0.32 response_format with json_schema, or structured_outputs with json strict: true, a named or required tool choice, or --tool-strict-level on the server Constrained decoding with xgrammar, llguidance or Outlines Not covered in its structured outputs docs Several seconds or more the first time a named tool’s grammar compiles
SGLang response_format with json_schema, or the native json_schema parameter Named or required tool choice, built from an EBNF grammar Constrained decoding, XGrammar by default Not covered Not documented

Sources: the providers’ guides and API references, read 5 November 2026.1234567891011121314

OpenAI’s strict defaults to false on JSON Schema response formats in both the Responses and Chat Completions APIs, so leaving it out gets best-effort output.34 Function tools work differently in the Responses API. Leave strict out there and the API uses strict mode when the schema allows, falls back to best effort when it doesn’t, and in that case reports strict: false on the tool. Chat Completions stays non-strict unless asked, and strict mode switches off when a fine-tuned model makes several calls in one turn.2

On Claude Sonnet 5.5, Opus 5.5, Fable 5.1 and Mythos 5.1, tool_choice types any and tool return a 400 error, so forcing a tool call to get JSON no longer works there. Anthropic points to strict tool use or structured outputs instead.15 Structured outputs add a system prompt that costs input tokens, can’t be combined with citations or prefilling, and work on every model Anthropic still serves.516

Google recommends the Interactions API for new work and keeps generateContent supported.17 Structured outputs combined with tools such as Google Search are a preview limited to Gemini 3 models.7 Mistral released custom structured outputs for all its models on 28 January 2025.1810 On Mistral reasoning models at high effort, message.content arrives as a list of thinking and text chunks, so take the text chunk before parsing.19

Which JSON Schema keywords each API accepts

All six take a subset of JSON Schema, and they differ most in how they treat a keyword outside it. OpenAI and Anthropic reject the request, Gemini drops the keyword silently, and vLLM may hand the request to another grammar backend.

API Object rules Not supported or not enforced What happens to an unsupported keyword Recursion
OpenAI Every property in required; additionalProperties: false on every object; the root must be a plain object with no top-level anyOf allOf, not, if/then/else, dependentRequired, dependentSchemas Request rejected when strict is true Supported
Anthropic additionalProperties must be false; optional properties allowed minimum, maximum, multipleOf, minLength, maxLength, array bounds other than minItems of 0 or 1, external $ref, allOf with $ref, regex lookarounds, backreferences and \b 400 error; the SDK helpers move the constraint into the description and check it after the call Not supported
Google Gemini additionalProperties may be a boolean or a schema; optional properties allowed minLength, maxLength, minProperties, maxProperties, uniqueItems, contains, minContains, maxContains Stripped without an error Supported; Google advises making the recursive reference optional or nullable
Mistral The docs example sets additionalProperties: false and lists every field as required Not documented Not documented Not documented
vLLM 0.32 Depends on the backend xgrammar can’t handle multipleOf on numbers, or uniqueItems, contains, minContains and maxContains on arrays auto mode passes the request to llguidance, then Outlines; a backend you name explicitly has no fallback llguidance supports local $ref
SGLang Depends on the backend Not documented Not documented Not documented

Sources: the hosted providers’ guides, vLLM’s source at the v0.32.0 tag and llguidance’s JSON Schema notes, read 5 November 2026.157102021

The schema your library generates is rarely what strict mode wants. Pydantic writes JSON Schema 2020-12, turns float | None = None into an anyOf with null, leaves fields with defaults out of required, and adds additionalProperties: false only when the model forbids extra fields.22 Zod 4’s z.toJSONSchema() adds additionalProperties: false to plain objects by default.23 OpenAI’s Python helper marks every property required and adds additionalProperties: false before sending.24 Most of Anthropic’s SDK helpers strip the constraints its API can’t enforce and copy them into field descriptions, and the ones that validate responses check them against your original schema.5

String formats and regular expressions travel worst. Anthropic accepts a uri format that OpenAI’s list leaves out. Claude doesn’t support lookarounds, backreferences or \b in pattern, llguidance has no lookarounds, and Gemini’s guide doesn’t list pattern at all.51217 In vLLM, xgrammar, llguidance and Outlines read regular expressions in Rust syntax, while lm-format-enforcer uses Python’s.11

OpenAI structured outputs vs Claude: limits that collide

These are the documented limits for the hosted APIs that publish any, as of 5 November 2026.

Limit OpenAI Anthropic Google Gemini
Schema size 5,000 object properties, 10 levels of nesting Unpublished limits on compiled grammar size, enforced with a 400 error Unpublished limits on states, branches and depth; 400 INVALID_ARGUMENT
Text in the schema 120,000 characters of property names, definition names, enum values and const values Not stated Not stated
Enums 1,000 values in total; 15,000 characters for a single string enum with more than 250 values Strings, numbers, booleans or nulls only Each value adds branching to the grammar
Optional properties Not allowed; use a null type 24 per request, across all strict schemas Allowed; Google suggests required plus null
Union types anyOf allowed below the root 16 parameters per request that use anyOf or type arrays Allowed; each branch adds to the grammar
Strict tools Not stated 20 per request Not stated
Compile time Not stated 180-second timeout Not stated

Sources: OpenAI’s supported schemas section, Anthropic’s schema complexity limits and Google’s notes on simplifying schemas.157

The two strict modes collide on optional fields. OpenAI wants every property in required and a null type for values that may be missing.1 Anthropic counts every anyOf and every type array such as ["string", "null"] towards a limit of 16 per request, summed across all strict tools and the response format, and separately allows 24 optional parameters.5 A schema written for OpenAI with 17 nullable fields therefore fails on Claude, and the same schema with those fields made optional fails on OpenAI. If one schema must serve both, keep nullable and optional fields to 16 or fewer. Otherwise generate a variant per provider from one Pydantic or Zod model.

Property order matters because the model writes JSON from left to right. OpenAI emits keys in schema order, and Anthropic does too, except that required properties move ahead of optional ones.15 Google Cloud’s guide contradicts itself on Gemini. One paragraph promises schema order, and a later one says that outside the Python SDK, properties come out alphabetically with required ones first unless you set propertyOrdering.25 To get a short explanation before a verdict, put it first, make it required and test each provider. On recent Claude models, don’t call it reasoning or thinking, because Anthropic says such a field can trigger a reasoning_extraction refusal.26

Long enums cost something on every API, as the table shows. If the whole answer is one label from a long list, a decision model may suit the job better, and our comparison of decision models, LLMs and classifiers covers when.

Constrained decoding in vLLM and SGLang

Open-model servers enforce schemas with constrained decoding, where a grammar library masks out every token that would break the schema. vLLM 0.32 supports xgrammar, llguidance (called guidance in its settings), Outlines and lm-format-enforcer. Its default auto mode tries xgrammar, falls back to llguidance when xgrammar rejects a schema, and then to Outlines. vLLM calls auto opinionated and subject to change in each release, and its development docs deprecate lm-format-enforcer from v0.33.0.2027 SGLang uses XGrammar by default, switches backend with --grammar-backend, and takes one constraint per request.13

Pin the backend in production, because the backends differ. vLLM ships a flag whose only job is to make its llguidance backend treat additionalProperties the way xgrammar and Outlines do, so set additionalProperties: false in the schema yourself.20 Grammars also allow whitespace between JSON tokens by default. vLLM’s disable_any_whitespace and llguidance’s whitespace_pattern limit it, which guards against the failure OpenAI’s JSON mode docs describe, a model emitting whitespace until it hits the token limit.20211

Tool calls in vLLM 0.32 depend on tool_choice. Named and required choices always run under a grammar. With tool_choice="auto", calls get no grammar unless at least one tool sets strict: true or the server raises the floor with --tool-strict-level, and even then a tool’s arguments follow its schema only if that tool is strict or the floor is parameter.12 A new grammar can take several seconds to compile on first use. The docs promise only “a validly-parsable function call - not a high-quality one”. SGLang builds required and named calls from an EBNF grammar, which it says is fully supported with XGrammar and may not be with Outlines.14

Reasoning models need the grammar kept out of their thinking. Anthropic applies it only to Claude’s direct output, and SGLang lifts it inside reasoning sections when you pass --reasoning-parser.528 vLLM warns that Qwen3 Coder models can lose structured outputs when reasoning isn’t parsed separately, unless you set --structured-outputs-config.enable_in_reasoning=True.11 vLLM and SGLang also advise describing the format in the prompt, while Google Cloud says repeating the schema in a Gemini prompt can lower output quality.111325

What still breaks with enforcement on

Enforcement holds the shape of a finished answer. These cases still hand your parser JSON you can’t use.

  • Truncation. A response that hits the output limit stops mid-object. Reasoning tokens count towards that limit on OpenAI and Claude, so long thinking can leave no room for the JSON.429 Anthropic advises retrying with a higher max_tokens.5
  • Refusals. OpenAI returns a refusal item in place of the text. Claude returns HTTP 200 with stop_reason: "refusal", bills the tokens and warns that the output may not match your schema.15
  • Enum casing on Claude. Anthropic doesn’t guarantee the capitalisation of string enum and const values, typically the first letter after a space, and the response completes normally. Compare case-insensitively and avoid values that differ only in case.5
  • Invented answers that fit. OpenAI warns that the model always tries to fill the schema, which can produce hallucinations when the input has nothing to do with it.1 Give the schema a way to say nothing matched, such as a status enum with a not_found value.
  • Best effort that looks strict. OpenAI response formats default to non-strict, its Responses API can quietly downgrade a tool, vLLM leaves auto tool arguments unconstrained without strict, and Mistral doesn’t say what strict does.
  • Constraints nobody enforced. Gemini drops length and uniqueness keywords and Claude’s SDK helpers turn bounds into descriptions, so your validator is the only place those rules get checked.

Each API flags unusable output in its own field, as of 5 November 2026.

API Cut off at the output limit Refused
OpenAI Responses status: "incomplete" with incomplete_details.reason: "max_output_tokens" A content item of type refusal
OpenAI Chat Completions finish_reason: "length" message.refusal is set
Anthropic stop_reason: "max_tokens" stop_reason: "refusal", with HTTP 200
Gemini Interactions API status: "incomplete" Not documented
Gemini generateContent finishReason: "MAX_TOKENS" finishReason: "SAFETY" and related values
Mistral finish_reason: "length" or "model_length" Not documented
vLLM finish_reason: "length" Not documented

Sources: the OpenAI and Gemini API references, Anthropic’s structured outputs guide, and the Mistral SDK and vLLM source.4353093120

Validate with Pydantic or Zod, then retry on purpose

The SDK helpers already parse and validate. OpenAI’s responses.parse() and chat.completions.parse(), Anthropic’s messages.parse() and Mistral’s chat.parse() all return a typed object, and OpenAI’s Python chat.completions.parse() raises LengthFinishReasonError when a response hits the token limit.32510 In TypeScript, Zod’s .safeParse() returns the data or an error without throwing.33 The helpers don’t decide what happens next. We’d keep that decision in one small function that every provider adapter feeds.

from typing import Literal
from pydantic import BaseModel, ConfigDict, Field, ValidationError

class Invoice(BaseModel):
    model_config = ConfigDict(extra="forbid")   # additionalProperties: false
    vendor: str
    currency: Literal["EUR", "GBP", "USD"]
    total_cents: int = Field(ge=0)              # Claude's API won't enforce this bound
    due_date: str | None                        # nullable, but still required

class Refused(Exception):
    pass

def extract(call, prompt: str, max_tokens: int = 1024, attempts: int = 3) -> Invoice:
    # call() wraps one provider and returns (text, state),
    # where state is "ok", "truncated" or "refused".
    for _ in range(attempts):
        text, state = call(prompt, max_tokens)
        if state == "refused":
            raise Refused(text)                 # not a parsing problem
        if state == "truncated":
            max_tokens *= 2                     # stopped mid-object, so give it room
            continue
        try:
            return Invoice.model_validate_json(text)
        except ValidationError as err:          # schema-valid JSON can still break rules
            prompt += f"\n\nYour last answer failed validation:\n{err}\nReturn corrected JSON."
    raise RuntimeError(f"no valid Invoice after {attempts} attempts")

The adapter maps each provider’s signal from the table above to one of the three states. Truncation gets more room, since an object with no closing brace means the budget ran out. A validation failure gets a retry with the error text, which suits what enforcement misses, such as a negative total or a mis-cased enum value. A refusal leaves the loop. For Anthropic’s reasoning_extraction category, the advice is to change the prompt rather than repeat the request.26 Count the three outcomes separately in your metrics, so that a rise in validation failures after a model or SDK upgrade shows up the same day.

MCP tool schemas after the 2026-07-28 revision

MCP’s 2026-07-28 revision loosened tool inputSchema and outputSchema to allow any JSON Schema 2020-12 keyword.34 The proposal behind it, SEP-2106, keeps type: "object" mandatory for inputs and allows composition (oneOf, anyOf, allOf, not), conditionals (if, then, else) and references ($ref, $defs, $anchor).35 Implementations must not fetch network $refs by default, and the spec asks for bounds on composition keywords so that a hostile schema can’t tie up a validator.36 Our guide to the stateless MCP revision covers its other changes.

MCP clients pass a server’s inputSchema straight into the model provider’s tool definition, as MCP’s own client tutorial does.37 A valid MCP schema can now use keywords that OpenAI’s strict mode rejects, such as allOf, not and if, and none of the three hosted guides lists oneOf. OpenAI’s Responses API won’t fail on such a tool when strict is left out. It falls back to best effort and reports strict: false.2

For each MCP tool, decide whether to send its schema non-strict or a simplified copy in strict mode. Either way, validate the model’s arguments against the server’s original schema before calling the tool. The spec requires servers to validate their inputs and recommends that clients validate results before passing them to a model.38 The structuredContent field in tool results is a separate matter, and the spec notes that it is unrelated to LLM structured outputs.

What this comparison is based on

We read each provider’s guides and API references on 5 November 2026, plus vLLM’s source code at the v0.32.0 tag where its documentation was silent. We haven’t measured latency, compile times or failure rates. Mistral’s and SGLang’s documentation says little about limits, so “not documented” in a table means exactly that. Several of these features changed in the past year, including Anthropic’s move out of beta on 29 January 2026 and Google’s shift to the Interactions API, so check the linked pages before you rely on a limit.1517

A checklist for schemas that work across providers

  1. Make the root an object and set additionalProperties: false on every object.
  2. List every property in required and use a null type for values that may be missing. With Claude in the mix, keep nullable and anyOf fields to 16 or fewer per request, tool schemas included.
  3. Flatten recursive structures into lists with parent ids, since Claude rejects recursion.
  4. Limit yourself to basic types, enum, anyOf below the root, local $ref with $defs, items, required and description, which all three hosted guides list. Enforce bounds, lengths and patterns in your validator.
  5. For string formats, stick to date-time, date and time, which OpenAI, Anthropic and Google all name.
  6. Keep enums short, distinct beyond letter case, and compared case-insensitively when Claude writes them.
  7. Order fields the way the model should write them, make the early ones required, and don’t name an explanation field reasoning.
  8. Keep schemas static. Each new schema compiles on first use, and Anthropic caches compiled schemas for up to 24 hours, so keep personal data out of property names, enum values and patterns.5
  9. Set strict: true explicitly wherever the API offers it, log what the response says it used, and leave room in the output limit for reasoning tokens.
  10. Check the stop reason before parsing, validate with Pydantic or Zod, retry truncation with more tokens and validation failures with the error text, and route refusals separately.
  11. For MCP tools, validate arguments against the server’s original schema even when the model saw a simplified copy.
  12. On vLLM or SGLang, pin the grammar backend, cap whitespace and describe the format in the prompt.

  1. OpenAI, “Structured model outputs”, API docs, read 5 November 2026, https://developers.openai.com/api/docs/guides/structured-outputs ↩↩↩↩↩↩↩↩↩

  2. OpenAI, “Function calling”, API docs, sections “Strict mode” and “Parallel function calling”, read 5 November 2026, https://developers.openai.com/api/docs/guides/function-calling ↩↩↩

  3. OpenAI, “Create chat completion”, API reference, response_format and finish_reason, read 5 November 2026, https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create ↩↩↩

  4. OpenAI, “Create a response”, API reference, text.format, function tool strict, max_output_tokens and incomplete_details, read 5 November 2026, https://developers.openai.com/api/reference/resources/responses/methods/create ↩↩↩↩

  5. Anthropic, “Structured outputs”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/build-with-claude/structured-outputs ↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩

  6. Anthropic, “Strict tool use”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use ↩

  7. Google, “Structured outputs”, Gemini API docs, read 5 November 2026, https://aistudio.google.com/docs/structured-output ↩↩↩↩↩

  8. Google, “Function calling with the Gemini API”, sections “Function calling modes” and “Notes and limitations”, read 5 November 2026, https://aistudio.google.com/docs/function-calling ↩

  9. Google, “generateContent”, Gemini API reference, GenerationConfig, Schema and FinishReason, read 5 November 2026, https://aistudio.google.com/api-reference/generate-content/generate-content ↩↩

  10. Mistral AI, “Custom Structured Outputs”, read 5 November 2026, https://docs.mistral.ai/inference/conversations/structured-output/custom ↩↩↩↩

  11. vLLM, “Structured Outputs”, documentation for v0.32.0, read 5 November 2026, https://docs.vllm.ai/en/v0.32.0/features/structured_outputs.html ↩↩↩↩

  12. vLLM, “Tool Calling”, documentation for v0.32.0, sections “Named Function Calling” and “Constrained Decoding Behavior”, read 5 November 2026, https://docs.vllm.ai/en/v0.32.0/features/tool_calling.html ↩↩

  13. SGLang, “Structured Outputs”, read 5 November 2026, https://docs.sglang.io/docs/advanced_features/structured_outputs ↩↩↩

  14. SGLang, “Tool Parser”, section “Tool Choice Mode”, read 5 November 2026, https://docs.sglang.io/docs/advanced_features/tool_parser ↩↩

  15. Anthropic, “Claude Platform release notes”, including the entry for 29 January 2026 and the Sonnet 5.5, Opus 5.5 and Fable 5.1 migration notes, read 5 November 2026, https://platform.claude.com/docs/en/release-notes/overview ↩↩

  16. Anthropic, “Model deprecations”, model status table, read 5 November 2026, https://platform.claude.com/docs/en/about-claude/model-deprecations ↩

  17. Google, “Migrating to the Interactions API”, Gemini API docs, read 5 November 2026, https://aistudio.google.com/docs/migrate-to-interactions ↩↩

  18. Mistral AI, “Changelog”, entry for 28 January 2025, read 5 November 2026, https://docs.mistral.ai/resources/changelogs ↩

  19. Mistral AI, “Reasoning”, section “Handling thinking chunks”, read 5 November 2026, https://docs.mistral.ai/inference/conversations/reasoning ↩

  20. vLLM source at the v0.32.0 tag: StructuredOutputsConfig, https://github.com/vllm-project/vllm/blob/v0.32.0/vllm/config/structured_outputs.py; backend selection, https://github.com/vllm-project/vllm/blob/v0.32.0/vllm/sampling_params.py; xgrammar feature checks, https://github.com/vllm-project/vllm/blob/v0.32.0/vllm/v1/structured_output/backend_xgrammar.py; finish reasons, https://github.com/vllm-project/vllm/blob/v0.32.0/vllm/v1/engine/init.py ↩↩↩↩↩

  21. guidance-ai, “JSON schema -> llguidance converter”, llguidance repository, read 5 November 2026, https://github.com/guidance-ai/llguidance/blob/main/docs/json_schema.md ↩↩↩

  22. Pydantic, “JSON Schema”, documentation, read 5 November 2026, https://docs.pydantic.dev/latest/concepts/json_schema/, and GenerateJsonSchema in the Pydantic source, https://github.com/pydantic/pydantic/blob/main/pydantic/json_schema.py ↩

  23. Zod, “JSON Schema”, documentation, read 5 November 2026, https://zod.dev/json-schema ↩

  24. OpenAI, to_strict_json_schema, openai-python source, read 5 November 2026, https://github.com/openai/openai-python/blob/main/src/openai/lib/_pydantic.py ↩

  25. Google Cloud, “Structured output”, Gemini Enterprise Agent Platform docs, last updated 4 November 2026, read 5 November 2026, https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output ↩↩

  26. Anthropic, “Refusals and fallback”, Claude Platform Docs, section “Keep reasoning in thinking blocks”, read 5 November 2026, https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback ↩↩

  27. vLLM, “Structured Outputs”, development documentation, section “Migrating from LM Format Enforcer”, read 5 November 2026, https://docs.vllm.ai/en/latest/features/structured_outputs.html ↩

  28. SGLang, “Structured Outputs For Reasoning Models”, read 5 November 2026, https://docs.sglang.io/docs/advanced_features/structured_outputs_for_reasoning_models ↩

  29. Anthropic, “Extended thinking”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/build-with-claude/extended-thinking ↩

  30. Google, “Interactions API: create”, Gemini API reference, response_format and status, read 5 November 2026, https://aistudio.google.com/api-reference/interactions-api/create-interaction ↩

  31. Mistral AI, client-python, ChatCompletionChoice finish reasons, read 5 November 2026, https://github.com/mistralai/client-python/blob/main/src/mistralai/client/models/chatcompletionchoice.py ↩

  32. OpenAI, “Structured Outputs Parsing Helpers”, openai-python repository, read 5 November 2026, https://github.com/openai/openai-python/blob/main/helpers.md ↩

  33. Zod, “Basic usage”, documentation, read 5 November 2026, https://zod.dev/basics ↩

  34. Model Context Protocol, “Key Changes” in specification 2026-07-28, minor change 10, read 5 November 2026, https://modelcontextprotocol.io/specification/2026-07-28/changelog ↩

  35. Model Context Protocol, “SEP-2106: Tools inputSchema & outputSchema Conform to JSON Schema 2020-12”, pull request merged 18 May 2026, https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2106 ↩

  36. Model Context Protocol, specification 2026-07-28, “JSON Schema Usage”, read 5 November 2026, https://modelcontextprotocol.io/specification/2026-07-28/basic/index ↩

  37. Model Context Protocol, “Build an MCP client”, read 5 November 2026, https://modelcontextprotocol.io/docs/develop/build-client ↩

  38. Model Context Protocol, specification 2026-07-28, “Tools”, read 5 November 2026, https://modelcontextprotocol.io/specification/2026-07-28/server/tools ↩

Frequently asked questions

What is the difference between JSON mode and structured outputs?

JSON mode only aims for syntactically valid JSON. Structured outputs also hold the answer to a JSON Schema you supply. OpenAI recommends structured outputs wherever a model supports them, and Google Cloud’s guide says JSON mode without a schema is only a strong hint that can still produce malformed JSON.

Does Claude support structured outputs?

Yes. As of 5 November 2026, the Claude API takes a JSON Schema in output_config.format and enforces tool inputs with strict: true, on every active Claude model. It rejects recursive schemas, numeric bounds and string length limits, and allows 20 strict tools, 24 optional parameters and 16 union-type parameters per request.

Can structured outputs still return invalid JSON?

Yes. A response that reaches the output token limit stops mid-object, and on OpenAI and Claude a refusal can arrive in place of the JSON. Check the stop reason before parsing, then validate with a library such as Pydantic or Zod.

Does Gemini’s response schema guarantee valid JSON?

Gemini compiles the schema into a state machine that constrains generation, so a finished response follows its structure. It silently ignores minLength, maxLength, minProperties, maxProperties, uniqueItems and contains, and a response cut off at the token limit is incomplete, so validate in your own code.

Which JSON Schema keywords does OpenAI structured outputs not support?

As of 5 November 2026, strict mode rejects allOf, not, if/then/else, dependentRequired and dependentSchemas. Every property must be listed in required, every object needs additionalProperties: false, and the root must be an object. A schema can hold up to 5,000 properties, 10 levels of nesting and 1,000 enum values.

How do I get structured output from vLLM?

Send response_format with type json_schema, or pass structured_outputs with a json schema in the request body. vLLM 0.32 enforces it with xgrammar, llguidance or Outlines, and its default auto mode tries xgrammar first and falls back to the others for schemas xgrammar can’t handle.

Work with us

Building something like this?

9io is a small team of senior engineers with a fractional CTO. We work by the hour, and plans start at $5,000. Send us a note about your product. The reply comes from the person who'd do the work.