AI glossary
Structured output
Structured output is asking a language model to reply in a fixed machine-readable shape, such as JSON with named fields, instead of free text.
Code cannot use "The customer seems quite unhappy about the delivery". It can use {"sentiment": "negative", "topic": "delivery"}. Structured output turns a model into a function your program can call.
Ask for the shape in the prompt, use the API's JSON or schema mode where it has one, then parse and validate the reply. If it fails, send the error back and ask again a limited number of times.
Valid JSON is not correct JSON. A reply can match the schema perfectly and still put the wrong value in a field, so check the values that matter too.
Learn it hands-on
These free lessons teach it with commands to run in a lab and checked tasks. Read them whole with no account.