Lesson 305 of 1596
Structured Outputs: Make the Model Return Data You Can Trust
For production apps, pretty prose is often the wrong output. Learn when to use structured outputs, function calling, and schema validation.
Creators · Tools Literacy · ~27 min read
Production Apps Want Shapes
A chatbot can answer in paragraphs. A production workflow often needs fields: title, dueDate, riskLevel, citations, lineItems, actions. Structured Outputs make the model follow a JSON schema so downstream code can trust the shape.
Compare the options
| Need | Pattern |
|---|---|
| Model should call your app's code | Function calling |
| Model should answer with strict JSON | Structured output with text.format |
| You only need valid JSON, not exact schema | JSON mode, but prefer structured outputs when supported |
| User request may be unsafe | Handle refusals explicitly |
A schema is a contract between the model and your application.
const response = await client.responses.create({ model: "gpt-5.5", input: "Extract a task from: Email Sam by Friday about the vendor renewal.", text: { format: { type: "json_schema", name: "task", strict: true, schema: { type: "object", additionalProperties: false, required: ["assignee", "due", "topic"], properties: { assignee: { type: "string" }, due: { type: "string" }, topic: { type: "string" } } } } } });- 1Keep schemas small at first.
- 2Require every field you truly need.
- 3Set additionalProperties to false when strictness matters.
- 4Log refusals and parse failures as product signals.
- 5Version schemas when clients depend on them.
Key terms in this lesson
The big idea: structured outputs make model responses easier to integrate, but they are not a substitute for validation, source checking, or user review.
End-of-lesson quiz
Check what stuck
8 questions · Score saves to your progress.
Tutor
Curious about “Structured Outputs: Make the Model Return Data You Can Trust”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 9 min
AI Tools: Instructor for Structured Outputs
How Instructor pairs Pydantic models with retries to get reliable JSON from LLMs.
Creators · 9 min
Pro Search vs Default: When To Spend The Compute
Pro Search runs more queries, reads more pages, and routes to a stronger model. It is not always worth the wait — knowing when it is is the skill.
Creators · 10 min
Perplexity For Academic Research: Strengths And Limits
Perplexity is fast at literature scoping and slow at literature reviewing. Knowing where the line falls saves graduate students from rookie mistakes.
