What is structured output?
Structured output (JSON output), told as a story about handing the parrot a form and letting it write only in the boxes.
The answer is right, but its shape changes every time. The machine cannot read it.We want to feed the parrot answer into a ledger program. But yesterday the date came first, today the name. The machine cannot tell which part is which.
The parrot answers in words. With no boxes, it writes freely.Even if the note says keep it short, the shape still varies. People understand every version; a machine needs fixed boxes.
Structured output hands the parrot a form and lets it write only in the boxes.Box names and types are set ahead of time. The parrot fills only those boxes. The machine finds the name box and the date box straight away.
The same content, written in boxes, and the machine can read it.Each box has a name. The machine reads the name from the name box and the number from the amount box. The shape never changes, so it works every time.
A filled form is not a true form. Check the content separately.A number in the amount box can still be made up — the plausible parrot lies inside forms too. And tool requests are written on this kind of form as well.
Structured output = hand the parrot a form with boxes and let it write only in those boxes. A machine can read it straight away. A correct shape does not mean correct content.
Makes the model respond only in a shape that matches a predefined schema (such as JSON Schema). You define field names, types and enums, then parse and validate the response, retrying on failure. Function calling (tool use) works on the same principle — arguments emitted to a schema. A valid shape still says nothing about whether the values are true.
When grown-ups say it
- Structured output
- Writing only in the boxes. Locks the parrot answer into a shape a machine can read.
- JSON mode
- The most common kind of form. A list of boxes in braces and quotes. Nearly every program can read it.
- Schema
- The blueprint of the form. Box names, types (text, number, yes/no) and which boxes are required, written down ahead of time.
- Relation to function calling
- Tool requests are forms too. Which tool, with which values, written into boxes. → the toolbox
- Validation
- Checking the form. The machine first checks that every box is there and of the right type.
- Retry on parse failure
- Outside the boxes? Write it again. Sometimes the form breaks. Point out the error and ask once more.
- Enum
- Only the listed values. For example a status box allows only pending, done or cancelled — no new words.
- Prompt
- The trainer note. Handing over the form is part of the note. → the trainer note