n4nAI

Structured outputs on Gemini 3, GPT-5, and Claude compared

A practitioner's structured output model comparison of Gemini 3, GPT-5, and Claude: capabilities, cost, latency, ergonomics, limits, and which to choose.

n4n Team4 min read972 words

Audio narration

Coming soon — every post will get a voice note here.

Doing a structured output model comparison across Gemini 3, GPT-5, and Claude is now mandatory for any team shipping agentic workflows. All three providers have converged on JSON-shaped responses, but the enforcement mechanisms, failure modes, and cost curves differ enough to change your architecture. If you are building extraction, classification, or multi-step tool orchestration, the differences below will save you a week of trial and error.

Comparison at a glance

Dimension Gemini 3 GPT-5 Claude
Capabilities Native JSON schema, constrained decoding, multimodal input Strict JSON Schema mode, function calling, vision Tool-use forced schema, no native JSON mode, strong reasoning
Cost model Per-token, cheap long context, cache discounts Per-token input/output split, batch API Per-token, premium output, prompt caching
Latency / throughput High throughput, low cost at scale Low p50, variable under load Balanced, slower on huge schemas
Ergonomics response_schema dict, verbose response_format OpenAI-compatible tools + tool_choice, indirect
Ecosystem Vertex AI, Google SDKs OpenAI SDK, huge community Anthropic SDK, growing agent frameworks
Limits Max output tokens, schema depth cap Strict mode rejects extra keys Tool recursion limits, max tokens

This table summarizes the structured output model comparison; the sections that follow unpack each row with code and operational notes.

Capabilities

Gemini 3 exposes structured output as a first-class generation config. You pass a response_schema and set response_mime_type: "application/json". The model uses constrained decoding, so malformed JSON is rare. It accepts multimodal input (images, PDF) and will populate schema fields from them.

GPT-5 keeps OpenAI’s response_format with json_schema and a strict: true flag. Strict mode enforces that the model only emits keys in the schema and never adds unspecified properties. This is the most predictable for compliance-heavy pipelines.

Claude does not have a native JSON mode in the same sense. You define a tool with an input_schema and force tool_choice. The assistant returns a tool call whose input is your structured object. It works, but you must parse the tool block rather than a top-level JSON string.

# GPT-5 strict schema (OpenAI-compatible)
resp = client.chat.completions.create(
    model="gpt-5",
    messages=[{"role":"user","content":"Extract: Jane, 42"}],
    response_format={
        "type":"json_schema",
        "json_schema":{
            "name":"person",
            "strict":True,
            "schema":{
                "type":"object",
                "properties":{"name":{"type":"string"},"age":{"type":"integer"}},
                "required":["name","age"]
            }
        }
    }
)

Price and cost model

All three meter by token. Gemini 3 continues Google’s pattern of low per-token rates for long context, and supports context caching that cuts repeated prefix costs. GPT-5 uses separate input/output pricing with a batch endpoint at discount; output tokens are the expensive line item. Claude prices similarly but historically charges more per output token, offset by prompt caching that rewards stable system prompts.

When you run a structured output model comparison on a extraction job over 1M documents, Gemini’s cache and cheap input dominate. For low-volume interactive agents, GPT-5’s predictable strict mode may justify the premium. Claude sits in the middle unless you lean on its caching for long system prompts.

An OpenAI-compatible gateway like n4n.ai unifies the three behind one endpoint and surfaces per-token usage metering, so you can switch models without rewriting billing code.

Latency and throughput

Gemini 3’s decoder is tuned for parallel sampling; under fixed QPS it sustains higher throughput than the others, making it the default for bulk backfills. GPT-5 has low median latency for small schemas but degrades when a provider region is saturated. Claude’s latency is acceptable but grows with schema size because tool serialization adds overhead.

If your service level objective is p95 < 800ms for a 200-token JSON, GPT-5 or Claude will hit it consistently; Gemini may show higher variance on first token due to multisystem routing. For batch jobs where throughput per dollar matters, Gemini wins.

Ergonomics

Gemini’s SDK takes a Python dict schema and validates it server-side. The response is parsed JSON in response.text. GPT-5’s response_format is drop-in if you already use the OpenAI SDK; strict mode removes the need for post-hoc validation. Claude forces you into the tools paradigm:

# Claude forced tool schema
resp = client.messages.create(
    model="claude-3-5-sonnet",
    max_tokens=1024,
    tools=[{
        "name":"emit_person",
        "input_schema":{
            "type":"object",
            "properties":{"name":{"type":"string"},"age":{"type":"integer"}},
            "required":["name","age"]
        }
    }],
    tool_choice={"type":"tool","name":"emit_person"},
    messages=[{"role":"user","content":"Extract: Jane, 42"}]
)
# resp.content[0].input is the dict

The indirectness means your agent loop must handle tool callbacks even when you only wanted data. That is fine for agents, annoying for plain ETL.

Ecosystem

Gemini 3 lives in Vertex AI and the google-generativeai client; if you are already on GCP, IAM and logging are free. GPT-5 has the largest third-party wrapper ecosystem—every agent framework assumes an OpenAI-shaped client. Claude’s Anthropic SDK is clean, and most modern agent libraries now support its tool format natively.

For a team that must support all three, standardizing on the OpenAI message shape and translating for Claude saves mental load. Gateways that honor client routing directives and forward provider cache-control hints let you keep one HTTP client.

Limits

Gemini caps schema nesting depth and rejects schemas with unbounded recursion. GPT-5 strict mode will refuse to start if your schema includes additionalProperties: true or loose types. Claude limits the number of tools per call and the total tool input size; deeply nested schemas can hit max token limits on the tool definition itself.

All three will occasionally emit a valid JSON that violates a semantic constraint (e.g., age as string “42”). None replace application-level validation. Use pydantic or zod downstream.

Which to choose

Bulk document extraction at scale. Use Gemini 3. The cost per million tokens and throughput make it the only sane choice for backfilling a warehouse. Write your schema once, enable caching for the prefix, and parallelize.

Compliance-sensitive agent steps. Use GPT-5 with strict mode. When you need a guarantee that no extra fields leak into a downstream SQL query, strict schema enforcement is worth the premium. Its OpenAI-compatible shape also means you can swap in fallback providers without code changes.

Long-horizon agent reasoning with structured handoffs. Use Claude. Its tool-use model aligns naturally with multi-step plans where each step is a function call. The slight latency and cost penalty buy you better reasoning on ambiguous inputs.

Heterogeneous fleet with one codebase. Route through a unified gateway that supports automatic fallback when a provider is rate-limited or degraded. Keep your primary target per use case above, but let the gateway shift traffic when GPT-5 is throttled or Gemini is erroring. That pattern turns a structured output model comparison from a quarterly debate into a config change.

Tagsstructured-outputgemini-3gpt-5claude

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All structured outputs & json mode for agents posts →