Tutorials · Chapter C (3/4) · ~8 min
Structured outputs & JSON mode
Try it → see it → read → next
Force machine-readable replies — JSON fields your app can trust (and validate).
On paths: Builder · Professional · Student
Try yourself
Playground
Structured output lab
JSON schema when code consumes the answer — free text when humans read it.
App parses user tier from response
Recap
What you just did
You compared the same review as prose vs JSON — one is readable, one is parseable.
Teach
How it works
Structured output uses schema instructions or API features so the model returns JSON (or similar). Your code:
- Defines allowed keys and types
- Parses the response
- Validates before acting
Related to function calling — both return structured payloads, not essays.
Use it
When you'd use this
- Routing tickets, extracting form data, building dashboards
- Any time downstream code needs reliable keys
Watch out
Watch out
Always validate JSON in code. Retry or repair on parse errors. Never eval() model output.
Try next
Try this next
Glossary: structured output · How-to: add function calling