Prompts & AI use

Structured Output

AI-assisted editorial review:

Structured output

Structured output is a way of making a large language model (LLM) answer in a format defined in advance by a schema, usually JSON Schema, so that downstream code can parse and check the answer safely. Major model APIs implement it with constrained decoding: while the model generates, tokens that would break the schema are blocked.[1][2] Developers can often write the schema as a code type, such as a Pydantic or Zod model, and let the SDK convert it.[1][9]

What does Structured Output mean in simple terms?

Normally an LLM answers in free-form text. With structured output, you hand the API a form, a schema that lists the fields, their types and the allowed values, and the model must fill in that form instead of writing prose. It is a bit like asking job applicants to fill in the company's fixed application form rather than send a free-form cover letter. When it is switched on, missing required fields, wrong data types and values outside an allowed list are blocked at generation time, so much of the defensive parsing and retry code around the model can be removed.[1][2] There are documented exceptions: a refusal or a reply cut off by the token limit may not match the schema.[1][2] Structured output is now a common building block for products where AI agents call tools, APIs or databases.[7][9]

How can Structured Output be explained with an analogy?

It works like a fixed quote template that guides what can be written in each field. The format is controlled, but the amounts and other values still need checking.

Where is Structured Output used?

Case 1

OpenAI launch — Action items from meeting notes

On August 6, 2024, OpenAI launched Structured Outputs in its API. One of the use cases in the announcement was extracting action items, due dates and owners from meeting notes as a JSON array.[1] On OpenAI's evaluation of complex JSON Schema following, gpt-4o-2024-08-06 with Structured Outputs scored 100%, while the older gpt-4-0613 scored under 40%. Training alone raised the new model to 93%, and constrained decoding closed the remaining gap.[1] Pulling fixed fields out of meeting notes, emails or customer inquiries and loading them into an internal database is a typical use.
Result: 100% on OpenAI's complex JSON Schema evaluation for gpt-4o-2024-08-06 with Structured Outputs, compared with under 40% for gpt-4-0613 (OpenAI internal evaluation).[1]

Case 2

Developer blog — Extracting criteria from program notices

A Korean developer described extracting evaluation criteria, eligibility conditions and required documents from support-program notices with an LLM.[4] With the schema only described in the prompt, the model sometimes wrapped the JSON in Markdown or returned wrong types and missing fields; one sample run produced six validation errors.[4] After switching to Structured Outputs with a Pydantic model passed as the JSON Schema and strict mode on, the same sample passed validation, the prompt became shorter, and schema changes now only required editing the Pydantic model.[4] This is one developer's report, not a controlled benchmark.
Result: Six validation errors to zero on the author's sample output (single developer report).[4]

Case 3

Agent tool calls — Stable tool arguments

In OpenAI's API, setting strict: true in a function definition makes the arguments the model produces match the supplied tool definition.[1][3] Anthropic launched structured outputs as a public beta in November 2025, covering both JSON outputs and strict tool use, and made them generally available on February 4, 2026.[7] Its current docs describe two features: JSON outputs via output_config.format and strict tool use via strict: true.[2] Google's Gemini API also accepts JSON Schema, and its SDKs accept Pydantic and Zod types; it lists generating structured inputs for tools or APIs as a use case.[9] For agents that call SQL queries, payment APIs or internal systems, schema enforcement can reduce format-related retries, but authorization, value validation, and business rules still need application checks.
Result: Tool-call arguments match the schema when strict mode is on, apart from documented exceptions such as refusals and token-limit cut-offs (OpenAI and Anthropic documentation).[1][2]

Case 4

Classification and UI generation — Enums and recursive schemas

OpenAI's launch post showed an app that generates a landing page, a sign-up screen or a stock widget as a JSON component tree from one response_format.[1] The component type is restricted to an enum, and children refers back to the root schema, so trees of any depth stay valid.[1] OpenAI notes that finite-state approaches generally cannot express such recursive types, which is why it compiles schemas into a context-free grammar.[1] Support differs by provider: Anthropic's docs list recursive schemas as unsupported and warn that the capitalization of enum values is not guaranteed.[2] Product categorization, sentiment analysis and document routing, where the answer must come from a fixed list, use the same enum pattern.
Result: Recursive UI trees with enum-restricted component types are supported in OpenAI's Structured Outputs (OpenAI launch demo); not supported in Anthropic's.[1][2]

Try it today

  1. Pick one data extraction task you do often and write one example of the result JSON by hand.
  2. Turn it into a JSON Schema with required fields, types, enums and additionalProperties: false.[1][2]
  3. Set the schema in the API. OpenAI: response_format with type: "json_schema" and strict: true (Chat Completions) or text.format (Responses API).[3] Anthropic: output_config.format, or strict: true on tools.[2] Gemini Interactions API: response_format with type: "text", mime_type: "application/json" and a schema. Check the parameters for the API and SDK version you use.[9]
  4. Run the same inputs with a prompt-only instruction and with structured output, for example 30 times each, and compare schema match rate, accuracy of values and latency.
  5. Add handling for refusals, for replies cut off at the token limit, and for the extra latency on the first call with a new schema.[1][2]

Limits and direction

A valid format does not mean correct content. OpenAI states that the model can still get values wrong, such as a step in a math problem.[1] Google likewise advises validating values, because output can match the schema and still be semantically wrong.[9] A new schema adds latency on the first request: OpenAI’s 2024 launch post reported typical schemas taking under 10 seconds and complex ones up to a minute, and Anthropic caches compiled grammars for 24 hours and enforces a 180-second compilation timeout.[1][2] OpenAI's launch post also noted that Structured Outputs did not work with parallel function calls.[1] Each provider supports only a subset of JSON Schema.[1][2][9] The JSONSchemaBench study found that Outlines had a lower compliance rate mainly because of timeouts, with some schema features taking 40 seconds to 10 minutes to process.[5] Boundary ML, which sells an alternative parsing approach, argues that forcing a format takes away the model's chance to say "this input is not a receipt", so fields may be filled with meaningless values; it recommends allowing free-form errors or parsing free text instead.[8] Whatever approach you use, plan explicit fields or logic for refusals and empty results.

Development is moving in two directions. On the inference side, open-source engines such as XGrammar report up to 100x faster grammar execution than earlier solutions and near-zero overhead when combined with an LLM inference engine.[6] On the SDK side, OpenAI, Anthropic and Google SDKs accept typed models such as Pydantic (and Zod in JavaScript) and convert them to JSON Schema, so the schema increasingly becomes the type in your code.[1][2][9]

Which concepts are related to Structured Output?

  • Related concept
    Prompt VersionOften used together in prompt and AI workflow practice: when a prompt version changes, re-check that the output still fits the schema.
  • Related concept
    Prompt LibraryOften used together in prompt and AI workflow practice: shared prompts can be stored with their output schemas.
  • Related concept
    Persona PromptingOften used together in prompt and AI workflow practice: a persona shapes tone, while a schema fixes the output format.

Which sources explain Structured Output?

  1. OpenAI — Introducing Structured Outputs in the API (2024-08-06) — https://openai.com/index/introducing-structured-outputs-in-the-api/
  2. Anthropic (Claude Platform Docs) — Structured outputs — https://platform.claude.com/docs/en/build-with-claude/structured-outputs
  3. OpenAI API Docs — Structured model outputs — https://developers.openai.com/api/docs/guides/structured-outputs
  4. invisibleVoice (velog, developer blog) — Reliably receiving JSON responses from an LLM: Structured Outputs (2025-12-07) — https://velog.io/@arendt9797/LLM%EC%9D%98-JSON-%EC%9D%91%EB%8B%B5%EC%9D%84-%EC%95%88%EC%A0%95%EC%A0%81%EC%9C%BC%EB%A1%9C-%EB%B0%9B%EB%8A%94-%EB%B0%A9%EB%B2%95-Structured-Outputs
  5. Geng et al., arXiv — JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Models (2025-01-18, v3 2025-02-27) — https://arxiv.org/abs/2501.10868
  6. Dong et al., arXiv — XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models (2024-11-22) — https://arxiv.org/abs/2411.15100
  7. Claude Blog — Structured outputs on the Claude Developer Platform (2025-11-14, updated 2026-02-04) — https://claude.com/blog/structured-outputs-on-the-claude-developer-platform
  8. Boundary ML — Structured Outputs Create False Confidence (2025-12-14) — https://boundaryml.com/blog/structured-outputs-create-false-confidence
  9. Google AI for Developers — Structured outputs (Gemini API, updated 2026-09-23) — https://ai.google.dev/gemini-api/docs/structured-output