Overview
Use native structured output whenever a program, not a person, reads the response. It removes regex extraction and the retry loops that come with it; structured-output covers schema design and provider differences.
Definition
Structured output is model output constrained to a schema (usually JSON, occasionally XML or YAML) at generation time. Modern APIs support it natively: OpenAI’s response_format: { type: "json_schema" }, Anthropic’s tool-use JSON schemas, and Google Gemini’s responseSchema all enforce the schema during decoding so the response is guaranteed to parse. Pydantic, Zod, and JSON Schema are the most common schema definitions. Structured output replaces fragile regex extraction from free-form text with a typed contract.
When it applies
Use structured output for any model call whose response feeds downstream code: classifications, extractions, function-call arguments, form fills, or multi-field summaries. Skip it for free-form generation (essays, chat responses) where natural prose is the product.
Example
{
"type": "object",
"properties": {
"priority": { "enum": ["P0", "P1", "P2", "P3"] },
"categories": { "type": "array", "items": { "type": "string" } },
"needs_human": { "type": "boolean" }
},
"required": ["priority", "categories", "needs_human"]
}Citing this term
See Structured output (llmbestpractices.com/glossary/structured-output).
Related
- structured-output - the deep-dive with schema patterns and pitfalls.
- prompt-design - the broader prompt-design discipline.
- system-prompt - the system prompt declares the output contract.
- few-shot-prompting - few-shot examples pair with a structured schema.
- evaluation - evaluation of structured output is cheap (exact-field match).