What are structured outputs in LLMs?
Structured outputs constrain a language model's response to a declared schema but do not guarantee that the values the model generates are accurate or truthful.
A structured output is a language model response organized according to a declared schema, so a program can read its fields and values predictably. For example, the schema may require a numeric amount and a supplier code as text. A plain instruction in the prompt, the text sent to the model, can request this format but cannot guarantee it. Constrained decoding acts during generation itself: it limits possible continuations to those compatible with the constraints the decoding engine can enforce. JSON Schema is a common way to describe those constraints; JSON is the text format that carries the data. Conformance depends on the schema features supported and on the response finishing. Even a valid result can contain an incorrect amount: following the structure does not prove that the model read its source correctly. You still need content checks and explicit handling of incomplete responses and model refusals.
See also: Tool calling (function calling)Tool calling lets a language model propose an external function call and its arguments; the application runs it or, for built-in tools, the model provider does.
How it works
The engine examines tokens, the units a model uses to generate text, and at each step excludes those incompatible with the constraints it applies. The JSONSchemaBench study distinguishes between accepting a schema, producing compliant results in tested cases, and enforcing its rules exactly: neither blocking valid responses nor allowing invalid ones. In the study's tests on the official JSON Schema Test Suite, some engines proved too permissive and others too restrictive, so stated support alone does not prove that every schema works.
The JSON Schema object reference points out a practical detail for schema authors: listing fields does not make them required, and extra properties are allowed by default. Required fields, and whether extras are allowed, must be declared separately. Even then, the chosen engine must actually support those rules. The vLLM documentation shows options for JSON schemas, choice lists, and grammars, and recommends checking schemas and results when the underlying engine changes.
An enterprise example
A procurement team receives free-text purchase requests from departments and wants to turn them into records in its management system. It defines a schema with cost center, category from a fixed list, estimated amount, and justification; it makes the fields required, prohibits extras, and includes an explicit value for missing information. The completed response is first checked against the schema; a business-rule check then compares cost center and amount with the available budget. A missing value, interrupted response, or refusal is reviewed rather than recorded automatically. The format spares the team from interpreting every free-form answer, but does not prevent a wrong category or an invented amount, as in hallucinations.
Why it matters for decision makers
Before selecting a solution, test it with actual schemas, including missing fields and edge cases, and measure both conformance and data accuracy through evaluations on representative examples. Check response times, error handling, and behavior when the engine version changes. Tool calling is different: it is how a model requests a function call, and it can use schemas for the arguments, but structured outputs are useful even without tools. Define the format contract and the checks needed before the data can trigger action.
Frequently asked questions
Related terms
- Tool calling (function calling)Tool calling lets a language model propose an external function call and its arguments; the application runs it or, for built-in tools, the model provider does.
- Evals (model evaluation)Evals are systematic assessments that measure an AI system against defined cases and criteria, helping teams compare versions and understand its risks.
- JSON vs TOON vs CSVThree ways to write structured data into a prompt: JSON for APIs, CSV for flat tables, TOON for long uniform lists.
- AI HallucinationsAI hallucinations are generated claims that are false or unsupported by their sources but presented as reliable; verify them before they inform decisions.