The anatomy of a prompt
A prompt is not one sentence. It is up to five parts joined into one text. Watch a tiffin service build a prompt part by part, see exactly what the model receives, and see what each part changes in the reply.
10 minFree
- Assemble the prompt
- Model reads it
- What came back
- Check the facts
Press Play to watch it run, or step through with ← →. Then switch to Practice and run it yourself.
Write a reply to this customer.
Can I change tomorrow's lunch to no-onion sambar? And what time does it come?Prompt X-ray: what the model sees, what came back
Nothing yet. Press Play to assemble the prompt.
Background: the idea in plain words
You type a short request into an AI model and get back something that sounds fine but is wrong for you. It is too long, or too general, or it states a "fact" about your business that is not true. Most people then blame the model. Very often the cause is simpler: the model never received what it needed.
A prompt is all the text you send to a model in one request. A model (the AI program that writes the answer) does not know your business, your customer or what you were thinking. It has only what it learned in training and what is in the prompt. It also cannot ask you a question before it answers. If something is missing, it fills the gap with a likely guess.
So a useful prompt is usually more than one sentence. It is built from up to five parts:
- Instruction: the job to do. "Write a reply to this customer, using only the facts below."
- Context: the facts the model needs and cannot know. Your rules, your data, today's details.
- Examples: one or more samples of a good answer, so the model can copy the style.
- Input: the thing to work on this time. A customer's message, a document, a question.
- Output format: the shape of the answer. How long, how it starts, plain text or a list.
Your app (or you, in a chat window) joins these parts into one piece of text and sends it as one request. The model does not receive five separate things. It reads one text from top to bottom.
This track uses one habit in every lesson, and we call it the prompt X-ray. Do not look at what you meant. Look at what the model received: the exact final text, read as a stranger would read it. Then look at what came back. Nearly every prompt problem becomes visible when you do this.
The example is a home lunch service in Chennai called Amma's Tiffin. A customer, Kavya, sends a WhatsApp message at 6:40 pm: can she change tomorrow's lunch to no-onion sambar, and what time does it come? The kitchen has rules for this (changes close at 8:00 pm, lunch comes between 12:30 and 1:15), but the model does not know them unless the prompt says so.
Press Play to watch the one-line prompt fail. Then switch Try it to After: all five parts, and finally to the edge case where one part is cut to save tokens.
What to notice
- The model answers the text it received, not the task in your head. In the first run it got two lines. The cut-off time and the delivery window were never sent, so it invented them. The reply was a fair answer to a bad prompt.
- A prompt has parts, and each part has a job. The instruction says what to do. The context carries the facts. The examples show the style. The input is the thing to work on. The output format fixes the shape.
- The parts become one text. The app joins them and sends one request. Tags such as
<kitchen_rules>help the model see where each part starts and ends. A later lesson, Context, delimiters and order, covers this in detail. - A missing part gives a matching failure. In the edge case the style and shape were right and the delivery time was wrong, because only the context was cut. When a result is bad, name the failure, then look at the part that owns it.
- Every part costs tokens. A token is a small piece of text, and you pay for each one on every request. The five-part prompt is many times longer than the one-line prompt. Add a part because it fixes a failure you have seen.
- Always run the X-ray. Print the final text your app sends. Find the line that answers the user's question. If you cannot find it, the model cannot either.
Go deeperWhich part fixes which failure
Use this table when a result is wrong. First decide what kind of wrong it is.
| What went wrong | Part to look at first |
|---|---|
| The model did a different job from the one you wanted | Instruction |
| The answer states things that are not true for you | Context |
| The tone or style is off | Examples |
| The model answered about the wrong thing | Input |
| The answer is too long, or your code cannot read it | Output format |
A simple prompt does not need all five parts. "Translate this sentence into Tamil" needs an instruction and an input, and nothing more. Google's prompting guide says the same thing in its own words: the input is the required part ("the required text in the prompt that you want the model to provide a response to"), and context, examples, constraints and a response format are things you add when the task needs them.
Go deeperThe same parts under other names
The three big vendors describe the same anatomy with slightly different words. You will meet all of these names, so it helps to know that they point at the same ideas.
| This lesson | Google's guide | OpenAI's guide | Anthropic's guide |
|---|---|---|---|
| Instruction | Instructions, constraints | Identity, Instructions | Instructions, a role |
| Context | Context | Context | Context, documents |
| Examples | Few-shot examples | Examples | Examples (few-shot, multishot) |
| Input | Input | The user's message | Variable inputs |
| Output format | Response format | Instructions | Output format |
OpenAI's guide says a developer message usually has its sections in this order: Identity, Instructions, Examples, Context. Anthropic's guide says that wrapping each type of content in its own XML tag "reduces misinterpretation" when a prompt mixes instructions, context, examples and variable inputs. Google's guide says XML-style tags or Markdown headings both work, and that you should pick one and use it consistently in a prompt. The names differ. The anatomy is the same.
In a chat window too You do not need to write code to use this. When you type into a chat app, you can still give the job, paste the facts, show one sample, paste the thing to work on, and say what shape you want back.
Go deeperWhere the parts come from in a real app
In a real app, a person rarely types the whole prompt. Code builds it for every request:
- The instruction, the examples and the output format are written once by the developer and reused. They are the fixed parts.
- The context is often fetched just before the request: today's menu, the customer's plan, a page from a policy document.
- The input arrives from the user.
This is why the prompt X-ray matters so much in apps. The developer wrote the fixed parts weeks ago and never sees the final joined text, unless they print it. A bug in the code that fetches context (an empty result, the wrong customer's plan) looks exactly like "the model is making things up".
Two related lessons go deeper. Context windows and prompts shows the limit on how much text fits in one request. System prompts and roles shows how the fixed parts and the changing parts travel in different "turns" of a request.
Go deeperWords to know
| Word | Meaning in simple words |
|---|---|
| Prompt | All the text sent to the model in one request |
| Instruction | The part that says what job to do |
| Context | Facts the model needs for this job and cannot know by itself |
| Input | The thing to work on this time, such as a customer's message |
| Output format | The part that says what shape the answer must have |
| Prompt X-ray | The habit of reading the exact final text the model received, and then what came back |
Check your understanding
Sources: the official documentation
This lesson is based on the official documentation. Check it for the latest details.
Something wrong or unclear in this lesson? Tell us, it gets fixed.