Structured Output
Constraining model generation to produce valid, machine-parseable formats like JSON or XML.
PromptItIn team

What it means
Structured output goes beyond instructing a model to 'respond in JSON' — it uses constrained decoding, grammar-guided generation, or function-calling APIs to guarantee that the model's output conforms to a specified schema.
OpenAI's JSON mode, Anthropic's tool-use feature, and libraries like Outlines or Guidance implement this at the token sampling level, making schema-invalid tokens impossible to generate.
This is essential in production pipelines where model output is parsed programmatically — an unparseable response breaks the application. Structured output removes the need for fragile regex post-processing and makes model responses reliably consumable by downstream code.
Examples
- Using OpenAI's function-calling API to guarantee a model returns a JSON object matching a Pydantic schema when extracting entities from text.
- Using the Guidance library to constrain a model to output a valid SQL SELECT statement with no free-form text.
Related terms
Output Format
Specifying the exact structure, length, or schema the model should use when responding.
Function Calling
A model feature that allows it to request the execution of developer-defined functions with structured arguments.
Tool Use
The ability of a model to invoke external tools — APIs, code executors, search — to augment its capabilities.
Put this into practice
PromptItIn applies techniques like structured output for you: describe what you want and it builds the prompt.
You might also like