- All Courses
- Building LLM Applications
- Talking to a Model
- Structured output and JSON schemas
Lesson 1.3
Structured output and JSON schemas
Parsing prose with a regular expression works until the day it does not.
31mIntermediate14.4k students
Overview
Text is not an interface
Parsing prose with a regular expression works until the day it does not. Asking for output against a schema makes the shape part of the contract, and gives you a real object to hand to the rest of your code.
Validate anyway. A schema constrains structure, not meaning: a required field can still come back as an empty string, and a date can still be nonsense.
Schema design affects accuracy. Flat schemas with descriptive field names and small enums are filled correctly far more often than deeply nested ones with abbreviated keys.
In this lesson you will:
- Constrain the model to a schema
- Validate the response before using it
- Design a schema that is easy to fill correctly
Resources
Notes are not saved yet — they clear when you leave this page.
Previous Lesson
Prompting fundamentals
4m
Tool calling basics
5m