Last verified

Prompting AI glossary

What is prompt engineering?

Prompt engineering is the practice of designing, testing and revising the instructions, examples and context you give a language model until its output reliably meets a defined standard.

At a glance

  • How it works: Draft a prompt, run it on a set of test inputs, see where the outputs miss, change one thing — wording, examples, structure — and run the set again.
  • Why it matters: The same model can fail or excel at a task depending on how it is asked; prompting is the cheapest lever before changing models or training one.
  • What it costs: Every prompt token is billed on every call — on GPT-6 Sol at $2 per million, or $0.2 for a cached prefix.
  • Related to: System prompt, prompt caching, reasoning effort, fine-tuning.

What prompt engineering actually involves

The phrase suggests magic words, but the work is closer to testing software. You decide what a good output looks like, collect a set of inputs that represent real use, and measure how often the model gets them right. Then you change the prompt and measure again. Without the measuring step, prompt changes are guesses that happen to look good on the example you tried.

Both major vendors frame it this way. Anthropic's guide assumes three things before any technique: clear success criteria, a way to test against them, and a first draft to improve. OpenAI describes the goal as getting a non-deterministic model to produce output that consistently meets your requirements, and recommends building evaluations to measure prompt changes rather than eyeballing them. Anthropic adds a caveat worth keeping: some problems that look like prompt problems — latency and cost in particular — are often solved more easily by choosing a different model.

The techniques that matter

  • Say exactly what you want. The task, the audience, the format, the length, what to do when information is missing. Most failures are instructions the writer thought were obvious.
  • Show examples. A few input-and-output pairs teach format and tone faster than description. OpenAI advises covering a varied range of inputs so the model does not copy one example's quirks.
  • Give the prompt structure. Headers or XML-style tags separate instructions from reference material; OpenAI suggests putting long context near the end.
  • Use the roles. Standing rules belong in the system or developer message; the user message carries the specific input.
  • Leave room to reason. On hard tasks, letting the model think before answering — or raising its reasoning effort — improves accuracy at the cost of extra output tokens.
  • Split big jobs. A chain of small, checkable prompts is easier to debug than one prompt that does everything.

What a prompt costs

A prompt is input, and input is billed on every call. A 4,000-token set of instructions and examples sent with 100,000 requests a month is 400 million input tokens — before any user has typed a word. That makes prompt length a budget line, not a style choice. On GPT-6 Sol, fresh input is $2 per million and output $10, so both what you send and what you ask the model to write back carry a price.

Two habits keep it under control. First, trim: every example and paragraph should earn its place on the test set. Second, order the prompt so the part that never changes comes first — OpenAI recommends exactly this, because a repeated prefix can be served from the cache at $0.2 per million instead of the full rate. Asking for shorter answers helps on the other side of the bill: output is usually the more expensive token. The worked example prices the same prompt three ways.

Worked exampleOne assistant prompt, three ways

100,000 requests a month on GPT-6 Sol, priced at its current list rates, checked on 2026-09-30.

4,000-token prompt, uncached
Input · 400M tokens @ $2.00/M$800
Output · 40M tokens @ $10.00/M$400
Blended · per 1M tokens billed$2.73
Per request$0.012
Per month$1,200
Trimmed to 1,500 tokens −42%
Input · 150M tokens @ $2.00/M$300
Output · 40M tokens @ $10.00/M$400
Blended · per 1M tokens billed$3.68
Per request$0.007
Per month$700
4,000 tokens, 90% cached −52%
Input · 90% served from cache · 400M tokens @ $0.43/M$172
Output · 40M tokens @ $10.00/M$400
Blended · per 1M tokens billed$1.30
Per request$0.00572
Per month$572

100,000 requests a month, each with a 400-token answer. The prompt sizes are illustrative. Caching only discounts the repeated prefix, so the stable instructions have to come first and stay byte-for-byte identical between calls.

Change the workload or the model in the LLM API cost calculator.

Prompting reasoning models

Reasoning models change the advice. OpenAI's guidance is that they work best when given the goal and the constraints, and need less step-by-step direction than conventional models — closer to briefing a senior colleague than scripting a junior one. Detailed instructions on how to think can get in the way of the model's own planning.

The cost lever moves too. With a reasoning model, the expensive part is often the hidden reasoning tokens, billed as output. Setting the effort level to match the task is part of prompt engineering now: a classification job rarely needs the reasoning budget of a hard proof.

When prompting is the wrong lever

  • The model lacks the knowledge. No wording supplies facts the model never saw; retrieve them instead with RAG.
  • The model lacks the capability. If the test set shows a ceiling no prompt breaks, a stronger model is cheaper than more prompt iterations.
  • The format must be exact at huge volume. A long prompt full of examples, repeated millions of times, can cost more than fine-tuning a model that needs a short prompt — where fine-tuning is still offered.
  • The problem is latency or price. A smaller or faster model may solve it outright, as Anthropic notes.

Prompts in production

Treat prompts as code. OpenAI now recommends keeping them in the application's source, with typed inputs, code review and tests, and is deprecating its stored prompt objects in favour of that. Pin the application to a specific model snapshot so behaviour does not shift under you, and rerun the test set before switching versions — a prompt tuned for one model can quietly degrade on its successor, which matters every time a vendor schedules a model retirement.

Frequently asked.

Short answers to the questions that come up next.

Q · 01 Is prompt engineering still needed with newer models? +
Yes, though it has changed. Newer models follow plain instructions better, so tricks matter less and clear requirements, good examples and testing matter more. Reasoning models in particular do better with a stated goal than with step-by-step scripts.
Q · 02 What is the difference between prompt engineering and fine-tuning? +
Prompt engineering changes what you send the model on each call; fine-tuning changes the model itself by training it on examples. Prompting is faster and cheaper to iterate; fine-tuning can shorten prompts at very high volume, where vendors still offer it.
Q · 03 Does a longer prompt cost more? +
Yes. Every prompt token is billed as input on every call. A repeated prefix can be cached at a lower rate, so put stable instructions first and keep them identical between calls.
Q · 04 How do I know if a prompt change is an improvement? +
Run the old and new prompt on the same set of realistic test inputs and score the outputs against criteria you wrote down in advance. One good-looking example is not evidence; a test set is.
Q · 05 How many examples should a prompt include? +
As few as reliably fix the behaviour you need — often two to five. Each example is input billed on every call, so add them one at a time and keep only those that measurably improve results on your test set. Make them varied, so the model learns the pattern rather than copying one case.
Q · 06 Where does the system prompt fit in? +
The system prompt holds the standing rules — role, tone, constraints, output format — and is usually the largest and most stable part of a prompt, which also makes it the best candidate for caching.

Sources · read on the date shown