AI guides
Prompt engineering basics: techniques that work across models
The prompting basics that hold across providers: test before you tune, write explicit instructions, separate the parts of a prompt, use varied examples and specify the output. Plus what changes with reasoning models, from dropping step-by-step scripts to budgeting for thinking tokens.
By Best AI Ever Editors Updated
In short
- Prompt engineering is mostly clear writing plus testing: say what you want, give the context a newcomer would need, and check every change against a fixed set of real inputs.
- The official guides from OpenAI, Anthropic and Google agree on the basics: explicit instructions, separated prompt sections, a few varied examples and a stated output format.
- Reasoning models need goals rather than step-by-step scripts, no "think step by step", and their thinking depth is set with an effort or thinking-level parameter.
- Prompt tokens are billed on every request and thinking tokens like output, so prompt design is also cost design.
Start with a test set, not a prompt
Anthropic's prompt engineering guide assumes three things before any tuning starts: a clear definition of success, a way to test against it, and a first draft [1]. The order matters. Without a test set, every prompt change is judged on whichever example you happened to try last.
A workable start is a few dozen real inputs, including awkward ones, each with a note on what a good answer looks like. Run every prompt version against the whole set. OpenAI recommends the same for production: evaluations that measure prompt behavior, and applications pinned to a specific model snapshot so behavior stays consistent [2].
Not every problem is a prompt problem. Anthropic notes that latency and cost are sometimes easier to fix by choosing a different model [1]. If a model keeps failing your test set however you phrase the request, try another: compare shows candidates side by side, and how to choose an AI model covers the selection.
Write instructions a newcomer could follow
Anthropic suggests treating the model like a capable new employee who lacks context on your norms, and checking whether a colleague with minimal context could follow your prompt [3]. Most weak prompts fail that test because they leave out something the author took for granted: the audience, the length, what to do when information is missing.
Four habits close most of the gap:
- Say what you want explicitly. If you want more than the literal request, such as a thorough or ambitious result, ask for it rather than hoping the model infers it [3].
- Explain why. A reason lets the model generalize. Anthropic's example: instead of banning ellipses outright, explain that the text will be read aloud by a speech engine that cannot pronounce them [3].
- Say what to do, not only what to avoid. "Write in flowing prose paragraphs" steers better than "don't use Markdown" [3]. Google's guide also asks you to spell out constraints and the response format [4].
- State constraints and the finish line. Limits such as length, budget or scope belong in the prompt, along with what a complete answer looks like [5].
The difference in practice:
Weak: Summarize this support ticket.
Better: Summarize this support ticket for the on-call engineer who will take it over.
Use at most three sentences: the customer's problem, what has been tried,
and what is still unknown. If the ticket does not name the affected
product version, write "version unknown".
Separate the parts of a prompt
A prompt usually mixes several kinds of content: standing rules, reference material, examples and the actual request. All three providers recommend marking the boundaries, with Markdown headings or XML-style tags such as <instructions>, <context> and <example> [2] [3] [4].
Placement follows a pattern the guides share:
- Role and standing rules first, in the system or developer message. Anthropic notes that even one sentence of role setting changes tone and focus [3]. Google recommends putting essential constraints, personas and output formats in the system instruction or at the very start of the prompt [4].
- Long material in the middle. Documents, data and retrieved passages go above the question.
- The specific request last. Anthropic reports that a query at the end can improve response quality by up to 30 percent in its tests, especially with complex, multi-document inputs [3]. Google gives the same advice for long contexts [4].
OpenAI's suggested order for a developer message (identity, instructions, examples, context) follows the same logic: what stays the same goes first, what varies goes last [2]. This also lowers costs, because prompt caching only applies to an identical prefix.
Use examples, and vary them
Examples are the most direct way to pin down format, tone and scope. Anthropic recommends three to five, matched to the real task, varied enough to cover edge cases, and wrapped in tags so the model does not mistake them for instructions [3]. Google recommends few-shot examples as a rule, warns that too many can make the model overfit to them, and stresses identical formatting across examples, down to whitespace [4]. OpenAI advises a diverse range of inputs with the desired outputs [2].
Variety is the part people skip. If every example is short, positive or about the same product, the model learns that pattern too. Include at least one hard case, such as an input with missing information, and show the answer you want for it.
Reasoning models are an exception to the default. OpenAI notes that they often don't need examples: try the prompt without them first, and if you add some, keep them closely aligned with your instructions [5].
Specify the output
State the shape of the answer: length, structure, field names and what to do with missing data. The guides add three points:
- For machine-readable output, use the platform feature. Google recommends its structured output feature for complex JSON schemas [4]; Anthropic points to structured outputs, or tools with an enum of allowed labels for classification [3]. A schema the API enforces is more dependable than a request in prose followed by parsing.
- Match the prompt's style to the output. A prompt full of bullet points tends to produce bullet points. Anthropic notes that removing Markdown from the prompt can reduce Markdown in the answer [3].
- Ask for length and detail explicitly. Defaults differ by model and shift between versions. Google describes Gemini 3 models as giving direct, efficient answers by default and says to request more detail explicitly [4].
One older trick needs replacing. Writing the first characters of the answer yourself ("prefill"), such as an opening brace for JSON, returns an error on Claude models from the 4.6 generation onward. Anthropic's suggested replacements are structured outputs and direct instructions, such as answering without a preamble [3].
Break large tasks into steps
A prompt that has to research, decide and write tends to do each part less well. Google describes three ways to split the work: one prompt per instruction, chains in which each output feeds the next prompt, and parallel prompts over parts of the data whose results are combined afterwards [4].
Anthropic adds that models with built-in thinking handle most multistep reasoning on their own, so explicit chaining mainly pays off when you need to inspect intermediate results or enforce a fixed pipeline. Its most common pattern is self-correction: draft, review against criteria, revise, each as a separate call that you can log and evaluate [3].
What changes with reasoning models
Reasoning models work through a problem in hidden "thinking" tokens before they answer, and they are now the norm. Of the text models in our catalog whose reasoning support is documented, more than four in five can reason, and for about half of those it cannot be switched off or no off switch is documented (as of October 2026). Claude Opus 5.5, GPT-6.1 Sol and Grok 4.7 always reason, and Gemini 3.8 Flash documents no off setting. GPT-6 Sol, DeepSeek-V4.1-Flash and Mistral Medium 3.5 can run without reasoning. The newer Sol dropped that option, one more reason to re-run your tests before switching versions.
Give goals, not scripts. OpenAI says reasoning models generally do better with high-level guidance, like a senior co-worker you hand a goal, while non-reasoning models need explicit instructions, like a junior one [2]. Keep the constraints and success criteria; drop the procedure unless it is itself a requirement.
Drop "think step by step". The instruction helped older models. OpenAI notes that chain-of-thought prompts may not improve reasoning models and can sometimes hinder them [5], and Google says Gemini 2.5 and 3 models generally don't need to lay out their reasoning in the answer [4]. To see the reasoning, use the provider's thinking summaries. Anthropic advises reading thinking blocks instead of asking for the reasoning in the response text, which several current Claude models may refuse [6].
Control depth with the setting, not with adjectives. Each provider offers a dial: reasoning.effort at OpenAI, effort at Anthropic and thinking_level at Google [7] [8] [9]. Google suggests minimal or low thinking for fact retrieval and classification and the highest level for advanced coding, math and planning [9]; Anthropic recommends low effort for simple, speed-sensitive work such as subagents [8]. Defaults vary even within one provider: Claude Opus 5.5 and Haiku 5.5 default to medium, most other Claude models to high [8]. Set the level explicitly and test it, but don't expect it to rescue an unclear prompt: OpenAI calls effort a tuning knob, not the primary way to recover quality [7].
Leave sampling parameters alone. Google strongly recommends default temperature and sampling settings for Gemini 3 models and warns of looping or degraded performance otherwise [4]. Recent Claude models, Opus 5.5 among them, return an error for non-default temperature, top_p or top_k values [6].
Budget for tokens you don't see. Thinking tokens are billed like output tokens, even when the API returns only a summary or nothing at all [7] [6] [9]. At all three providers they also count toward the output limit, so a tight limit can end a response before any visible text [7] [6] [9]. OpenAI suggests reserving at least 25,000 tokens for reasoning and output while you experiment [7].
The effect is largest for short answers. On GPT-6.1 Sol, at $10 per million output tokens as of October 2026 [10], a 20-token classification costs $0.0002 in output. With 2,000 thinking tokens first, the output side costs $0.0202, about 100 times as much. For simple, high-volume tasks, the lowest effort level that passes your test set can be the largest single saving. Current rates for the models named above:
| Model | Input tokens | Cached input tokens | Output tokens |
|---|---|---|---|
| GPT-6.1 Sol OpenAI | $2.00 per 1M tokens tieredverified 2026-10-25 | $0.10 per 1M tokens tieredverified 2026-10-25 | $10.00 per 1M tokens tieredverified 2026-10-25 |
| GPT-6 Sol OpenAI | $2.00 per 1M tokens tieredverified 2026-10-25 | $0.20 per 1M tokens tieredverified 2026-10-25 | $10.00 per 1M tokens tieredverified 2026-10-25 |
| Claude Opus 5.5 Anthropic | $4.00 per 1M tokensverified 2026-10-25 | $0.20 per 1M tokensverified 2026-10-25 | $20.00 per 1M tokensverified 2026-10-25 |
| Gemini 3.8 Flash Google | $0.75 per 1M tokensverified 2026-10-25 | $0.075 per 1M tokensverified 2026-10-25 | $3.75 per 1M tokensverified 2026-10-25 |
| Grok 4.7 xAI | $2.00 per 1M tokens tieredverified 2026-10-25 | $0.50 per 1M tokens tieredverified 2026-10-25 | $6.00 per 1M tokens tieredverified 2026-10-25 |
| DeepSeek-V4.1-Flash DeepSeek | $0.30 per 1M tokensverified 2026-10-25 | $0.006 per 1M tokensverified 2026-10-25 | $1.20 per 1M tokensverified 2026-10-25 |
| Mistral Medium 3.5 Mistral AI | $1.50 per 1M tokensverified 2026-10-25 | $0.15 per 1M tokensverified 2026-10-25 | $7.50 per 1M tokensverified 2026-10-25 |
Pass reasoning back unchanged. In multi-turn and tool-use flows, return the model's reasoning state exactly as you received it: Claude's thinking blocks, Gemini's thought blocks with their signatures, OpenAI's reasoning items [3] [9] [7]. Editing or dropping them breaks the model's line of reasoning and, on some models, causes errors.
Keep the prompt's cost in view
Input tokens are billed on every request, so a long system prompt has a running cost. Take a 4,000-token system prompt with instructions and five examples, sent 100,000 times a month to GPT-6.1 Sol at $2.00 per million input tokens as of October 2026 [10]. That is 400 million tokens, or $800 a month before any user input. Served from the cache at the $0.10 cached-input rate, the same tokens cost $40, plus cache writes at $2.50 per million whenever the cache has to be rebuilt. OpenAI recommends putting reusable, static content at the start of the prompt for this reason [2].
Two habits follow. Keep rules and examples byte-identical across requests, since a timestamp or user name near the top breaks the cached prefix. And remove instructions that your test set shows make no difference. AI token pricing explained covers the rate types, how to reduce AI API costs covers caching and batching, and the AI cost calculator turns token counts into a monthly estimate; AI pricing lists all current rates.
Model data and prices in this guide come from our catalog; our methodology explains how we collect and check them.
Sources
- Prompt engineering overview - Claude Docs
- Prompt engineering | OpenAI API
- Prompting best practices - Claude Docs
- Prompt design strategies | Gemini API | Google AI for Developers
- Reasoning best practices | OpenAI API
- Thinking - Claude Docs
- Reasoning models | OpenAI API
- Effort - Claude Docs
- Gemini thinking | Gemini API
- Pricing | OpenAI API