Skip to content

Lesson 3 of 9 · 4 min read

Structured Outputs and Constrained Decoding

Structured outputs constrain a model's generation so its output matches a schema, typically by masking tokens that would break the grammar at each step. That guarantees syntax and, for supported schema features, types and enums. It does not guarantee semantics: a valid refund call can name the wrong order or an amount larger than the charge. A harness checks three layers (parse, schema, meaning), repairs with a bounded, specific error, and handles truncation at the token limit.

Reviewed By the AIAgentInterviews editorial team
free sign-in, no card required

Practise it as an interviewer asks it

Course lessons that teach this

Related lessons