Prompt engineering is the iterative practice of writing and testing prompts so a language model behaves consistently for a given task. It covers instructions, examples, output formats, and how context is arranged.
Why it matters
A well-built prompt can replace more expensive options like fine-tuning and makes outputs easier to parse and validate. Because models change between versions, prompts used in production need regression tests.
Example
Common techniques include giving a role, supplying examples (few-shot prompting), and demanding a structured format:
Classify the ticket as "billing", "bug", or "other".
Return JSON: {"category": "...", "reason": "..."}
Ticket: "I was charged twice this month."
Asking for JSON lets your code validate the answer and retry when it is malformed.
Common mistakes
- Judging a prompt from a single try instead of a set of varied test cases.
- Making prompts long and contradictory rather than clear and minimal.
- Trusting the output without validation, since the model can still hallucinate.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.