OpenAI prompt-engineering best practices
Reference for separating instructions, context, examples, and desired output when refining a request.
Compute College
Learn the main parts of a production prompt and how each one affects model behavior, tokens, and validation.
Prompt anatomy separates a model request into parts with clear jobs. A useful prompt commonly contains instructions, the current user input, relevant context, examples, constraints, and an output format. API names differ by provider, but the design problem stays the same: make the task and the information needed to complete it easy to distinguish and validate.
Memory trick: Instructions tell. Context informs. Examples demonstrate. Constraints limit. Output contracts verify.
When instructions, reference material, user content, and output requirements are mixed together, models and reviewers have a harder time determining which text is authoritative and what the answer should contain. Separating the parts makes prompts easier to version, test, secure, and shorten. It also makes recurring token and latency costs easier to attribute.
A document-review prompt can be organized as: Instructions — identify unsupported claims; Context — the document and review policy; Input — the current document section; Examples — one passing and one failing finding; Constraints — do not infer facts absent from the text; Output — JSON containing `claim`, `evidence`, `severity`, and `confidence`. This structure makes each responsibility visible to both the model and the evaluator.
Example figures are illustrative calculations, not current quoted market prices.
Current example
OpenAI and Google both describe clear instructions, relevant context, examples, and explicit output requirements as useful prompt-design tools. Provider terminology differs, so treat the anatomy as a transferable design model rather than a guarantee of identical API behavior.
Reference for separating instructions, context, examples, and desired output when refining a request.
Reference for structured instructions, few-shot examples, and breaking complex tasks into steps.
See why prompt anatomy is only one part of the complete information environment.
Source discipline: message roles, caching, structured-output guarantees, and token accounting vary by provider. Check current API documentation before relying on a specific implementation detail.
One undifferentiated block hides the role of each piece of text. A reader cannot easily tell whether a sentence is an instruction, evidence, an example, or an untrusted quote. Changes also become harder to review because a small wording edit can alter several behaviors at once.
Practical takeaway
Take one production prompt and label every line as instruction, input, context, example, constraint, or output requirement. Remove anything without a clear role, then test the labeled version against the same representative cases and compare quality, tokens, latency, and retries.
Decision check: can a reviewer point to the exact part of the prompt that controls the task, supplies evidence, and defines a passing output?
Compute College track
Step 3 of 18: Prompt anatomy