Beginner level · Module 5: Structured AI Outputs · Lesson 2 of 3
Designing Output Schemas
Learners specify each field's type, whether it is required and its allowed values, creating a schema that both the model and the checking program follow.
In this lesson you will
- Specify fields, types and allowed values
- Write a simple JSON Schema
Key concepts
schematyperequired fieldenum (allowed values)ranges
The lesson
A schema describes a valid output: which fields exist, their types, which are required and what values are allowed. For example, category must be one of fees, admissions, timetable or other; confidence must be a number between 0 and 1; sources must contain at least one item.
JSON Schema is a standard way to write this. Many model providers can be given a schema so that responses follow it, and the same schema can be used to check outputs afterwards.
Design for checking: allowed-value lists are easier to verify than open text, and a needs_human flag makes escalation explicit.
Step by step
- List the project fields with type, required/optional and allowed values.
- Write them as a simple JSON Schema with the instructor's template.
- Validate three example outputs against it.
- Fix the schema or the examples where they disagree.
Practice activity
Write the JSON Schema for the project assistant's answers.
Expected result: A schema that accepts correct examples and rejects incorrect ones.
Check your understanding
-
What does an enum (allowed values) do?
Show answer
It limits a field to a fixed list of values.
-
Why include a needs_human field?
Show answer
It makes the decision to escalate to a person explicit and checkable.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.