lowob

What Is Structured Output in AI?

Structured output is a model feature that makes an AI response follow a fixed format, usually a JSON schema the developer supplies, so software can read it without guessing. The main providers now enforce the schema during generation, so the output parses and contains the required fields. It does not make the values correct. Structured output is how AI can write into a CRM, a queue or an approval step safely, provided the values are checked before anything acts on them.

Gateway 0ToolingContextRecordReasoningGateway 1Gateway 2Gateway 3
Agents are the reasoning layer, and they touch every stage of the build.

What structured output means

A language model writes text. Software needs fields. Without help, the gap is closed by asking the model for JSON and hoping. Anthropic's documentation lists what goes wrong: invalid JSON syntax, missing required fields, inconsistent data types and schema violations that need retries.

Providers have moved through several stages.

ApproachWhat it guaranteesRemaining risk
Asking in the promptNothingMalformed or incomplete output
JSON modeValid JSON is more likely, but not a particular schemaWrong or missing fields
Structured outputThe response matches the supplied schema, in most casesWrong values, refusals, truncation
Strict tool useTool names and arguments match the tool's schemaWell-formed but wrong arguments

OpenAI introduced Structured Outputs in its API on 6 August 2024. It converts the schema into a grammar and, after each token, masks every next token that would break it. On its complex schema eval, the company reported 100% with the feature, against 93% for the same model without it and under 40% for an older model. Anthropic describes its version as "constrained sampling with compiled grammar artifacts", in two parts: JSON outputs for the response and strict tool use for function arguments. Google's Gemini API takes a schema alongside the request in the same way.

Structured output is a close relative of function calling. A tool call is itself a structured request, and strict modes apply the same guarantee to its arguments.

Why it matters for a commercial team

Every time AI writes into a system, a format is involved. An enquiry classified by segment, size and urgency. Renewal terms pulled from a contract into named fields. A meeting summary turned into next steps with an owner and a date. A draft placed in an approval queue with the account ID attached. If the format breaks, the integration breaks, or writes to the wrong field.

Structured output solves the format problem. It does not solve the truth problem. OpenAI's announcement says it "doesn't prevent all kinds of model mistakes". Google's documentation tells developers to "always validate values in your application", because output can match the schema and still be wrong. A renewal date that parses is not necessarily the renewal date in the contract; see AI hallucination.

The guarantee also has edges. Anthropic and OpenAI both note that a refusal, or a response that hits the maximum token limit, may not match the schema. Each provider supports only part of JSON Schema. Google strips constraints such as minLength and maxLength during decoding rather than enforcing them. Anthropic caps strict tools at 20 per request and rejects schemas too complex to compile. The first request with a new schema is slower while the grammar is built; Anthropic caches compiled grammars for 24 hours from last use.

One finding argues for care in design. Tam and colleagues' 2024 study "Let Me Speak Freely?" found that requiring formats such as JSON significantly reduced models' reasoning performance, and that stricter constraints generally caused larger drops. For a judgment step, such as assessing deal risk, a common pattern is to let the model reason in free text first and fill the structured fields last. Another is to place a reasoning field ahead of the answer fields in the schema.

In lowob's model of the brain, structured output is how the decision record gets filled consistently: decision, reason, owner, status, expected outcome and check date. A schema with an enumerated status and a required reason cannot be saved half-empty. A person still checks that the reason is true, because nothing sends without a person.

How to use it well

PracticeWhy
Use enums for fixed lists such as stages, segments and loss reasonsKeeps values aligned with your pipeline stage definitions; Anthropic notes enum values can differ in capitalisation, so compare without case
Make the reason field requiredBlank reasons are the most common gap in commercial records
Validate values in code after parsingSchema compliance is not accuracy
Handle refusal and token-limit stops explicitlyBoth can break the schema
Keep schemas flat and shortComplex schemas compile slowly or are rejected
Keep personal data out of schema definitionsAnthropic caches schemas for up to 24 hours

lowob takeaways

  • Structured output fixes the format. The response parses and has the required fields.
  • It does not fix the facts. Validate values before anything acts on them.
  • The guarantee has edges. Refusals, truncation and unsupported schema features need handling.
  • Let the model reason before it formats. Strict formats can reduce reasoning quality.

Common questions

What is the difference between JSON mode and structured outputs?

JSON mode makes valid JSON more likely but does not enforce a particular schema. Structured outputs constrain generation so the response matches the schema you supply.

Does structured output stop AI hallucinations?

No. It guarantees shape, not content. A field can be well-formed and wrong, so values still need checking against the source.

Which AI providers support structured output?

OpenAI, Anthropic and Google all offer schema-enforced output in their APIs, each supporting a subset of JSON Schema. Check each provider's list of unsupported features before designing a schema.

How is structured output related to function calling?

A function call is a structured request for an action. Strict modes apply the same schema guarantee to tool arguments that structured output applies to the response.

Sources and notes

What Is an AI Agent, and Where Does It Fit in the Brain?

Read next in The Build Order