As long as the model answers in prose, a human has to read it. The moment its output is structured — JSON, a fixed table, labeled fields — code can take over: validate it, store it, route on it. Structured output is the pattern that turns “a chatbot” into a software component, and it happens to be a token saver too.
The analogy
The form versus the free-text letter. An insurance claim written as a heartfelt three-page letter must be read, interpreted, and often sent back for missing details. The claim form — policy number, date, amount, checkbox — is processed in minutes, partly automatically. Same information; the structure does the work.
The principle
PROSE: "Analyze this review and tell me how the customer feels"
→ 150 words of nuance a human must read.
STRUCTURED:
"Analyze this review. Reply with ONLY this JSON:
{ "sentiment": "positive" | "neutral" | "negative",
"topics": [string, max 3],
"urgent": boolean,
"quote": string // the sentence that best justifies it
}"
→ 40 tokens, parseable, actionable.
What makes it robust:
- Give the exact schema, not a description of it — the shape is the instruction (and a few-shot example of a filled one seals it).
- Close the enums.
"positive" | "neutral" | "negative"beats “describe the sentiment” — you can’tswitchon poetry. - Say “ONLY this JSON” — otherwise you get a friendly paragraph wrapped around it that breaks your parser.
- Validate programmatically, and on failure retry once with the error message. That check is the natural gate of a prompt chain. Many APIs and harnesses can also enforce a JSON schema at generation time — use that when available.
A concrete example
A ticket triage feeding a real system:
LLM output → {"sentiment":"negative","topics":["billing","refund"],
"urgent":true,"quote":"third time I'm charged twice"}
code → urgent && billing → priority queue, finance notified
→ stored in the DB, dashboards update
No human read the ticket; the structure carried it end to end. This is also how tool calls work under the hood — agents are structured output all the way down.
💶 The token payoff
- Structured answers are dramatically shorter: 40 tokens of JSON versus 150+ words of prose — and it’s output tokens you’re trimming, the 3–5× expensive kind. At 10,000 calls a month, that single change often cuts the output bill by two-thirds.
- Parse failures are the expensive path: every “sorry, please answer in valid JSON” retry re-bills the entire context. A tight schema + one validation gate keeps the retry rate near zero.
- The schema is stable → it lives in the cacheable prefix (prompt caching) with your instructions and examples.
The classic trap
Trusting the shape to guarantee the substance. Valid JSON with the right keys can still contain a wrong sentiment or an invented quote — schema-valid is not correct. Validate the values too (does the quote actually appear in the review?), and keep a small eval set scoring the content, not just the parse rate.