A free ebook, as a PDF and an EPUB
Filtering and structured LLM output: schema, repair, ground
Get JSON another system can trust: a short strict schema, Pydantic validators, a bounded repair, a grounding check, a filter on every reply and the rates you alert on.
The ebook is open in a new tab
If it did not open, open the PDF. For a reading app, download the EPUB. Both links work for a day; the form gives you new ones any time.
Build it live, with an engineer reviewing your choices
Secure AI Agents with Guardrails. Agents that each sign in with their own identity, act only within the user's permissions and refuse an injected instruction.
The Lightning recordings on this site are free with an account.
Look insidePages from the PDF, as they print.

Page 3: A reply that reads fine to a person can still crash the code that reads it. 
Page 4: Free-text output fails in five ways, and each has a fix at parse time. 
Page 7: A short, strict schema is followed; a vague one drifts. 
Page 13: Pydantic beats a bare JSON Schema check because its errors and hooks feed the repair. 
Page 19: Valid JSON can still be invented, so check each value against the source. 
Page 24: Each rate has an alert line and a first place to look.
What the ebook covers
- 1
Why free-text output fails in production
Text for a person can be prose. Output that feeds a ticket queue, a database or the next agent step is code, and free text breaks it in five known ways.
- 2
Schema design: fewer fields, stricter types
Every field is a chance to fail. A short flat schema with enums, typed numbers and a description per field is followed; a schema of loose dictionaries drifts.
- 3
Pydantic validation and bounded repair
Parse, validate, then repair. Pydantic checks types, enums, ranges and your business rules, and a failed check goes back to the model with the error, at most twice.
- 4
Grounding checks and the output filter
A valid ticket can still name a product the customer never mentioned. A grounding check finds each value in the source, and a filter sends every reply to accept, review or reject.
- 5
Compliance metrics and alerting
Schema compliance is a service level, tracked like API errors. Four rates show which layer is slipping, and each alert line points at the schema first, the prompt second and the model third.
- 6
The page to keep and the questions people ask
Every layer on one page, then short answers to what engineers search about structured LLM output.