Plan for the cases where the guarantee does not hold
Even with structured outputs, some answers do not follow the schema, and providers document it. This lesson reviews these exceptions, how each provider signals them and the behavior your product should adopt for each one, so users are never left facing a broken screen or silently wrong data.
Lesson objective
By the end of this lesson, you will be able to describe the documented cases where a structured output does not follow the schema (refusal, truncation, enum casing), how each provider signals them, and the behavior expected from the product.
Topics covered
- model refusals
- truncation
- max tokens
- error handling
Where it fits
When the output breaks the contract
What does the product check, and what does it do when the output is invalid, refused or cut off?
Lessons in this module
- Specify validation, retries and fallback
- Plan for the cases where the guarantee does not hold (this lesson)
What you will learn in this module
This lesson is part of the course Get reliable, product-ready AI outputs (JSON, schemas, function calling)
- Choose between instructions alone, JSON mode, structured outputs and function calling for a given need, and justify the choice.
- Specify validation (syntax, schema, business rules), retries, handling of refusals and truncation, and the fallback path.
Related courses
- AI & ProductAdvancedRegular practice: you already use the tools or work on this topic.
Build an AI assistant for your product
3 hr
- AI & ProductAdvancedRegular practice: you already use the tools or work on this topic.
Design a RAG architecture that fits your product
3 hr 30 min
- AI & ProductAdvancedRegular practice: you already use the tools or work on this topic.
Evaluate an AI feature: test sets, metrics and LLM judges
3 hr