Chapter 9 · Talking to models: prompting and context
Structured output
Ask for JSON or a fixed format so software can read the answer reliably.
Preparing structured output: json a program can read
Chapter 9 · Talking to models: prompting and context
Ask for JSON or a fixed format so software can read the answer reliably.
Free text pours into labelled boxes…
A fixed shape lets software pick out each value, with no guessing.
A person reads “Asha is 12 and lives in Pune” easily. A program wants the name, the age and the city in known places.
Switch fields on or off, set their type and whether they are required. Then pick a sample reply, or type your own.
0 of 6 sample replies pass your schema. Can you make a tidy reply pass without letting the broken ones through?
Why ask a model for JSON?
A reply says “Sure! Here you go:” before the JSON. What happens to a strict reader?
What should a program do with a model's structured reply?