Structured outputs
"Sure! Here is the JSON you asked for:" has broken more production code than any model bug. Structured outputs make the shape guaranteed. Making the contents right is still your job.
In this lesson you'll learn to
- Compare prompt-only JSON, JSON mode, and schema-constrained structured outputs.
- Explain how constrained decoding guarantees the shape, using what you know about sampling.
- Design a schema that reduces made-up values, with enums, required fields and nulls.
- Validate values after parsing, and recover when a check fails.
Create a free account to open this lesson
It's free. You'll get every free lesson, quizzes that save your progress, daily flashcards and streaks.