Page languageFrançaisEnglish
Teacher area
Laurent PoupetClaude trainer and artificial intelligence architectStudent area

Category · Models and how they work

What is structured output?

Structured output means forcing the model to follow a JSON (JavaScript Object Notation) schema exactly. At each token, the provider blocks anything that would break the schema, so the format is always valid. The code only has to check the meaning.

By , Claude trainer and artificial intelligence architect · Updated

How it works

  • Constrained decoding removes, at each token, the choices that would violate the schema. The model can therefore only produce a valid document, which removes retries for invalid formats.
  • Strict mode requires every field to be mandatory and forbids extra properties. An optional field is then expressed as an allowed null value.
  • On Azure OpenAI, this mode does not work with parallel tool calls, which must be turned off. Schemas also have limits on size and nesting depth.

The trap to avoid

The trap is the refusal. If the model refuses to answer for safety reasons, the response carries a refusal field instead of the expected document, and the code must plan for it.

Related terms

Where this is taught

Lesson content (step-by-step instructions, exercises with solutions, quizzes) is for students only, with an access code received after the first lesson.

See the full program

All glossary terms

Trial lesson · 30 min · $20

Book (new tab)