Structured output is model-generated data constrained to a predefined machine-readable format, commonly a JSON Schema. It allows an application to consume the response as typed data rather than parsing unrestricted natural language.
Typical uses include information extraction, classification, workflow routing, form completion, user-interface generation, and communication between components in an agentic workflow.
A schema can define:
- required and optional properties;
- strings, numbers, booleans, arrays, and nested objects;
- enumerated values;
- restrictions on additional properties; and
- descriptions that explain the semantic meaning of each field.
Structured output is stronger than asking a Large Language Model (LLM) to "return JSON." Plain prompting may produce malformed syntax, omitted keys, inconsistent types, or unsupported enum values. Schema-constrained generation is designed to ensure that the output conforms to the declared structure.
Schema validity does not guarantee factual or semantic correctness. A model can produce a syntactically valid object containing an incorrect date, unsupported conclusion, or fabricated identifier. Applications must still validate business rules, permissions, references, and high-impact values.
Structured output is related to tool calling. Both commonly use schemas. Structured output describes the model's response contract, while a tool call requests that application code execute an external capability.
Good schemas are narrow and explicit. Deeply nested structures, ambiguous field descriptions, and large enums can reduce reliability. Versioning is also important because changes to a schema are API contract changes for downstream consumers.
Within agent orchestration, structured outputs make routing, state updates, approvals, and handoffs easier to inspect and test. They also support more precise agent evaluation because individual fields can be checked independently.
The OpenAI Structured Outputs guide provides an example of constraining responses with JSON Schema.
The LLM Knowledge Base is a collection of bite-sized explanations for commonly used terms and abbreviations related to Large Language Models and Generative AI.
It's an educational resource that helps you stay up-to-date with the latest developments in AI research and its applications.