LLMs & AI Engineering · How LLMs work
Prompting & structured output
Get reliable JSON out of an LLM: clear instructions, examples, a schema, and validation.
Step 1 of 5 · 1. A good prompt has parts15 min read ·
1. A good prompt has parts
Role/system
who it is, rules
Context
the data (two trade records)
Task
classify the break
Format
exact JSON schema
Examples
1–3 worked cases
SYSTEM: You classify trade breaks. Answer only JSON.
USER: ours={"id":"T2","qty":250,"px":"101.25"}
theirs={"id":"T2","qty":200,"px":"101.25"}
Return {"type": "qty|px|missing|duplicate", "reason": str}Next: 2. Never trust, always validate