Structured Output

Structured output is the practice of making a large language model produce answers in a predefined, machine-readable format – typically JSON that follows a given schema – instead of free text. It is what lets programs and AI agents use model output directly, without fragile parsing.

From prompting to guarantees

Developers first simply asked models in the prompt to answer in JSON, which often failed: models added commentary, left out required fields or produced invalid syntax. Tool use, in which a model fills in the arguments of a function call, made formats more reliable, and in November 2023 OpenAI added a “JSON mode” that guaranteed valid JSON but not a particular structure. In August 2024 OpenAI introduced “Structured Outputs,” which guarantee that responses match a developer-supplied JSON schema; Google offers similar controls for Gemini, and Anthropic added structured outputs to its API as a public beta in November 2025 (generally available since February 2026), both for JSON answers and for “strict” tool calls.

How it works

The guarantees rely on constrained decoding: at each step of generation, the system masks out every token that would break the schema, so the model can only choose among valid continuations. The schema is typically compiled into a grammar in advance. Open-source libraries such as Outlines, Microsoft’s Guidance and the grammar feature of llama.cpp brought the technique to open-weight models before the commercial APIs offered it.

Trade-offs

Forcing a format is not free. A 2024 study found that strict format requirements can reduce performance on reasoning tasks, possibly because the model loses room to work through a problem in text; the makers of Outlines disputed its method, arguing that with matched prompts structured generation performed better. Common remedies are to include a field for reasoning before the answer or to let the model think first and format afterward (see Chain of Thought). The guarantees also have limits: providers support only part of the JSON Schema standard, and a response cut off by a length limit or replaced by a refusal may not match. A valid structure also says nothing about whether the content is true: a perfectly formatted answer can still contain a hallucination.

Why it matters

Structured output helped turn language models from chat partners into components that can be slotted into software, databases and automated workflows, and it underpins agents, data extraction and protocols such as the Model Context Protocol.

Written with Claude, made by Anthropic, which offers structured outputs in its API and created the Model Context Protocol; competitor OpenAI, Google (a competitor and Anthropic investor) and investor Microsoft, whose Guidance library is named here, offer comparable features.

Related

Tool Use · AI Agent · Model Context Protocol · Prompt Engineering · Token · API

Sources: OpenAI: Introducing Structured Outputs in the API (August 6, 2024) · Claude: Structured outputs on the Claude Developer Platform (November 14, 2025) · Claude Docs: Structured outputs · Brandon T. Willard and Rémi Louf: Efficient Guided Generation for Large Language Models (arXiv) (2023) · Zhi Rui Tam et al.: Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Models (arXiv) (2024) · dottxt: Say What You Mean – A Response to ‘Let Me Speak Freely’ (2024)

Leave a Reply

Your email address will not be published. Required fields are marked *