OpenAI prompt engineering best practices, with prompts to copy

Updated on November 18, 2026 · By Editorial team promptdonuts.com

The OpenAI prompt engineering best practices come down to a few habits: put rules and inputs in separate messages, give the prompt a clear structure, show examples, name the goal, and test every change. Each one is below with a prompt.

This page follows OpenAI's own documentation. Each section gives you a prompt to copy, what to change in it and where it tends to break. If you are new to the subject, start with what prompt engineering is.

Start with a prompt that has four parts

OpenAI's guide says to organize a developer message into four parts, usually in this order: identity, instructions, examples and context. Context goes near the end because it may change from one request to the next.

ChatGPT

Four-part prompt

# Identity You are a [ROLE, e.g. support agent for an online shop]. # Instructions * Answer in [LANGUAGE] and keep replies under [NUMBER] sentences. * Use only the information in the Context section. * If the answer is not in the Context section, say so and offer to pass the question to a human. * Do not [THING TO AVOID]. # Examples Example question: [EXAMPLE QUESTION] Example answer: [EXAMPLE ANSWER IN THE STYLE YOU WANT] # Context [PASTE THE POLICY, PRODUCT DATA OR NOTES HERE] Now answer this question: [CUSTOMER QUESTION]

What to change: the role, the limits and the example. Replace the context block each time the facts change; leave the top alone.

Where it breaks: if the context is long and messy, the model may lean on the wrong part. Trim it to what the task needs. Instructions that contradict each other also cause trouble, so read the prompt once as a stranger would.

Use message roles and clear separators

In the API, developer messages carry the rules and business logic, and user messages carry the input. Developer instructions take priority over user ones. In plain ChatGPT you have no such roles, so the same idea means keeping your rules apart from the material you paste in.

OpenAI suggests Markdown headers and lists to mark sections of a prompt, and XML tags to show where a piece of reference content starts and ends. OpenAI's help article on the API makes the same point with ### or triple quotes: put the instruction first, then separate it from the context.

ChatGPT

Rules apart from material

Summarize the text between the ### lines for [AUDIENCE, e.g. a busy manager]. Rules: * Write [NUMBER] bullet points. * Each bullet starts with a verb. * Leave out anything that is not in the text. ### [PASTE YOUR TEXT HERE] ###

What to change: the audience, the bullet count and the rules. Where it breaks: if the pasted text contains its own instructions, the model may follow them. See prompt injection for how to guard against that.

Say what you want, not only what to avoid

OpenAI's help article asks you to be specific about the context, the outcome, the length, the format and the style. It also advises telling the model what to do instead of only listing what not to do.

The newest model guide adds a point about goals. For work that can run without supervision, say which outcome to reach and which decisions need your input. It also says to give the model room to make reasonable assumptions on longer tasks and keep working.

Any AI chat

Outcome-first task brief

Goal: [THE RESULT YOU NEED, e.g. a one-page onboarding checklist for new hires]. Reader: [WHO WILL USE IT]. Format: [e.g. numbered list, max 12 items]. Tone: [e.g. friendly and direct]. If something is missing, make a sensible assumption and list your assumptions at the end. Ask me before deciding anything about [DECISION ONLY I CAN MAKE]. Material to use: [PASTE NOTES HERE]

What to change: every bracket. Where it breaks: a goal like "make it better" gives the model nothing to aim at. Name the result you would accept. For more on this habit, read prompt discipline for outcome oriented AI.

Show examples, then check they fit

Few-shot prompting means putting input and output examples in the prompt. OpenAI says to show a diverse range of possible inputs with the desired outputs. The help article describes a sensible order: try zero-shot first, then few-shot, and consider fine-tuning only if neither works.

ChatGPT

Few-shot classifier

Classify each customer message as [LABEL 1], [LABEL 2] or [LABEL 3]. Reply with the label only. Message: [EXAMPLE MESSAGE A] Label: [LABEL 1] Message: [EXAMPLE MESSAGE B] Label: [LABEL 2] Message: [EXAMPLE MESSAGE C, A HARD OR UNUSUAL CASE] Label: [LABEL 3] Message: [NEW MESSAGE TO CLASSIFY] Label:

What to change: the labels and the examples. Pick examples that differ from each other. Where it breaks: if all your examples look alike, the model copies that pattern even when the new input is different.

Match the prompt to the kind of model

OpenAI's guide says reasoning models give better results with high-level guidance, while GPT models need more explicit instructions. A prompt that suits one can be too thin or too heavy for the other.

Reasoning modelsGPT models
How to instructKeep prompts simple and direct, and be specific about the end goalSpell out the steps and the rules
Step-by-step requestsOpenAI says "think step by step" may not help and can sometimes hurtFine to include when the task needs a method
ExamplesTry zero-shot first, then few-shot if neededUse diverse examples to show the format
ChatGPT

Lean prompt for a reasoning model

Goal: [THE DECISION OR ANSWER YOU NEED]. Success looks like: [CRITERIA, e.g. one recommendation, two risks, a cost estimate]. Limits: [BUDGET, DEADLINE OR OTHER HARD LIMITS]. Background: ### [PASTE FACTS HERE] ###

What to change: the goal, the success criteria and the limits. Where it breaks: adding long step lists or "explain your reasoning" to this kind of prompt works against the advice above. If you use the Claude family as well, compare with the Anthropic prompt engineering guide.

Model names change often. Check OpenAI's latest model page before you copy a model name into code.

Treat the prompt as code: pin, store and test

For production apps, OpenAI says to pin to specific model snapshots so behavior stays consistent. It also says to store production prompts in your application code and to build tests and evaluation suites that measure prompt behavior, especially when you change or upgrade models.

Another tip is about cost and speed: put reusable instructions in the first developer message, so the shared start of every request can be cached.

Any AI chat

Prompt test-case writer

Here is a prompt I use in my app: ### [PASTE YOUR PROMPT] ### Write [NUMBER] test inputs for it: [NUMBER] ordinary cases, [NUMBER] edge cases and [NUMBER] cases that try to make it break its own rules. For each input, write the output I should expect and a one-line pass or fail check. Put them in a table.

What to change: the prompt and the counts. Where it breaks: the expected outputs are the model's guess, so review them yourself before you trust them as a test suite.

Questions

Where can I find the official OpenAI prompt engineering guide?

OpenAI publishes it in its API documentation under the prompt engineering guide. Its help center also has an article called best practices for prompt engineering with the OpenAI API.

Do these tips work in ChatGPT, or only in the API?

The ideas of clear structure, examples, separators and a stated goal carry over to ChatGPT. Message roles and model pinning apply to the API.

Should I tell a reasoning model to think step by step?

OpenAI's guidance says this may not help reasoning models, because they reason internally, and it can sometimes hurt results. Give a clear goal instead.

How many examples should I put in a prompt?

OpenAI gives no fixed number. It says to show a diverse range of inputs with the desired outputs, and to try zero-shot first before adding examples.

Are the same practices useful with other AI tools?

Many are: clear structure, specific goals and testing are not tied to one vendor. Check each vendor's own guide for model-specific advice.

Sources

  1. Prompt engineering – OpenAI
  2. Reasoning best practices – OpenAI
  3. Using the latest model – OpenAI
  4. Best practices for prompt engineering with the OpenAI API – OpenAI Help Center

MORE GUIDES