Prompt Engineering
Intermediate

Structured Outputs and Schemas

Design model outputs that applications can parse, validate, and recover from.

35 min
3 sections
json
schema
automation
1
2
3

01. Make output machine-checkable

Section 1 of 3

Enterprise systems should not scrape paragraphs when they need reliable automation. Ask for JSON, define allowed values, validate with a schema, and handle invalid output in code.

json
Task:
Classify an inbound support ticket.

Output JSON:
{
  "category": "bug | billing | feature_request | account | unknown",
  "priority": "low | normal | high | urgent",
  "confidence": 0.0,
  "reason": "short explanation under 160 characters",
  "needsHumanReview": true
}

Rules:
- Use unknown when evidence is weak.
- Set needsHumanReview true for billing disputes or legal threats.
Back to Course