Learning outcomes
- Define output schemas
- Separate syntax from semantics
- Handle validation failures
Mental model
Structured output constrains generated syntax to a schema, turning free text into a typed boundary. It does not make the values semantically correct.
Theory
Schemas define fields, types, allowed values, required properties, and nesting. The application validates again at its trust boundary, handles refusal or incomplete output, and applies domain invariants. A valid date field may still contain the wrong date; syntax conformance and factual correctness require different checks.
Alternatives and trade-offs
Loose JSON prompting is portable but fragile. Provider-native schema enforcement improves conformance. Tool calls are structured outputs coupled to an action workflow.
Failure modes and misconceptions
Do not execute merely because parsing succeeded, use oversized schemas that obscure errors, or confuse missing fields with model refusal.
Knowledge check
What validation remains after a response satisfies its JSON schema?
Decision scenario
An expense workflow validates currency codes and numeric types, then separately checks allowed accounts, amount limits, evidence, and approval authority.
Relationships
Prompt Structure
Output contracts extend precise task and response instructions.
prerequisiteTool Calling
Tool calls are schema constrained outputs requiring application validation.
evaluated-byLLM Evaluation
Schema compliance and semantic correctness require systematic evaluation.
Primary sources
- Structured Outputs - OpenAI, verified 2026-07-16