Skip to content
mentoor

Structured outputs

For engineers

Getting machine-readable output with JSON Schema, choosing the right mechanism, validating results and repairing failures

See where you stand

110 questions across four stages: Understand, Apply, Solve and Judge.

Try 5 questions

Practice items, not counted towards your mastery. No account needed.

Check yourself · 1 of 5

Your code reads a status field that must be one of three known values. How should the schema describe it?

Choose one answer

Check yourself · 2 of 5

A model is set to JSON mode and returns {"category": "billing"} when your code also needs priority. What does this show?

Choose one answer

Check yourself · 3 of 5

A reply passes the schema and contains order_id: "ORD-48213". What must your code still do before refunding?

Choose one answer

Check yourself · 4 of 5

A reply fails validation because priority is "high". What should the retry message contain?

Choose one answer

Check yourself · 5 of 5

Your schema uses minLength and pattern, and the provider does not enforce them. What is the safe approach?

Choose one answer

Topics

  1. Defining model output with JSON Schema4 min read · Required fields, enums, descriptions and nullable values written as JSON Schema, Pydantic or Zod models
  2. Strict schemas versus JSON mode versus forced tools4 min read · When to use strict structured outputs, plain JSON mode or a forced tool call, and what each one guarantees
  3. Validating structured output before you use it4 min read · Why schema-valid output can still be wrong: invented ids, out-of-range values, empty strings and refusals
  4. Repairing invalid output with targeted retries4 min read · Sending the validation error back to the model, bounding attempts and falling back when repair fails
  5. Where constrained decoding hits its limits4 min read · Unsupported schema keywords, nesting and size limits, first-request latency and quality loss when answers skip reasoning

Start here

Helps to know first

110 questions · last verified 2026-12