Generative AI basics · 13 min
Token-based pricing and the context window
In this lesson you will learn to calculate what a call costs with token-based pricing, what drives up an application's cost and latency, what the context window is and what context engineering decides.
Token-based pricing is the way Amazon Bedrock charges for on-demand inference, that is, when you only pay for what you use without reserving anything. The exam guide asks you to know what effect this pricing has on an application's cost and performance. With this pricing you pay for what the model reads and what it writes, measured in tokens, which are the pieces of text the model works with, instead of paying by the hour as you would for a server. That is why the bill grows with the length of what you send and of what the model responds. For example, if an online store's help chat answers with a paragraph instead of a line, the store pays more for that answer.
Input tokens and output tokens
In Amazon Bedrock, on demand, each model has two prices per million tokens. The first price is for input tokens, which are everything you send in the prompt, and the second is for output tokens, which are what the model generates. In general, each output token costs more than an input token. For example, when one of the store's customers asks "when will my order arrive?", that question and the instructions that come with it are input tokens, and the model's answer is output tokens.

For example, Gemma 4 31B in the Standard tier, in N. Virginia, Ohio and Oregon, had these prices on the Bedrock page on November 9, 2026: 0.14 USD per million input tokens and 0.40 USD per million output tokens. At those prices, a thousand requests with 2,000 input tokens and 500 output tokens each add up to 2 million input tokens, which cost 0.28 USD, and half a million output tokens, which cost 0.20 USD, for a total of 48 cents.
In this example, the output is one fifth of the tokens but almost half of the cost. The reason is that each output token of this model costs almost three times as much as an input token, so a short response can weigh heavily on the bill. For example, if the store asks the model for answers twice as long, the output part of its bill also doubles, even though its customers' questions stay the same.
Why did the bill go up?
A company asks its model in Amazon Bedrock for much more detailed responses. It sends the same number of requests, with the same prompts, and the bill goes up. What explains it?
What drives up cost and latency?
The latency of an AI application is how long it takes for the model's response to arrive. The Generative AI Lens makes three cost recommendations for an application with token-based pricing:
- Short prompts, which the Lens recommends making as short as possible without losing quality, because a long prompt has more input tokens to process and pay for. For example, the store sends only the information about the customer's order and not the list of all their orders.
- Response length, which the Lens recommends limiting, because the model generates one token at a time and a long response takes longer and costs more. For example, the store asks the model to answer in two or three sentences.
- Model size, where the Lens recommends trying a small model first and moving up only if it isn't enough, because newer and larger models usually cost more per token. For example, to tell whether a message is a complaint or a question, a small model is enough for the store.
Prompt caching
A cache is a place where something already processed is stored so it doesn't have to be processed again. Amazon Bedrock prompt caching helps when the beginning of the prompt is the same in many calls, such as a long manual that many people ask questions about. In that case, the cache reuses that beginning, so the response arrives sooner, and according to the pricing page, tokens read from the cache cost 75% less than regular input tokens. This cache only works on the models that support it. For example, if every message in the store's chat starts with the same shipping policy, the cache stores that policy and only the new question is paid at the regular price.
Does the cost go up or down?
0 of 5Tap the correct column for each change in an application with token-based pricing.
Pasting the 40 pages of the rulebook into every message
Asking the model to respond in a single sentence
Switching to a larger model for a simple task
Putting the manual at the fixed beginning of the prompt and using prompt caching
Sending the full history of a two-hour conversation
What is the context window?
The context window is the amount of text, measured in tokens, that the model can consider at once when it generates a response. With a larger window, the model can work with longer documents or take more of the conversation into account, and the Amazon Nova 2 models, for example, accept up to 1 million tokens. For example, with a small window, the store's model couldn't read a very long contract with a supplier all at once, and with a large window it could.

The user's question is a small part of what goes into each call. The Bedrock Converse API receives separately the system instructions, which say who the assistant is and which rules it follows, the messages of the conversation and the tools the model can request. Tools are actions the model can ask for, such as looking up an order. Added to that are the documents a search brought back and the results of the tools. For example, a single call from the store's chat carries the instruction "you are the store's assistant and you answer politely", the customer's previous messages, the return policy that was found, the status of their order and, at the end, their question.
All of those parts are input tokens, and whatever doesn't fit in the window, the model doesn't see. That is why AWS mentions a limited context window as one of the causes of hallucinations, which are false answers the model gives with confidence. For example, if the return policy didn't fit in the window, the model can make up a return period that sounds believable.
What is context engineering?
Context engineering consists of deciding what goes into the context window on each call, and the exam guide asks for it in objective 2.1.5. It differs from prompt engineering, which works on how you write the instruction, because context engineering works on everything that comes with the instruction in the call. For example, rewriting "answer briefly" as "answer in two sentences" is prompt engineering, and deciding that each call carries only the return policy and not the whole manual is context engineering.
AWS doesn't have a page with that name, but it documents each of its pieces separately:
- Including only what the task needs, because every extra token is charged and adds latency.
- Retrieving the chunks that talk about the question instead of pasting all the documents, which is what RAG (retrieval-augmented generation) does, the technique of searching your documents and giving the model only what it found.
- Leaving what doesn't change at the beginning of the prompt and what changes at the end, which is what AWS recommends so that prompt caching finds matches.
- Measuring with the CountTokens API how many tokens you send, and checking in the responses whether the change improved anything.
For example, the store puts its fixed instructions first, then uses RAG to retrieve only the part of its manual that talks about the customer's question, and puts the question at the end.
Which part grew?
An assistant answers worse and costs more after a two-hour conversation with the same user. Which context engineering change helps the most?
In both accounts
In the new experience account, tokens are deducted from your credits instead of being charged to a card. In that account you can only use models available within us-east-2, because it doesn't support cross-Region inference, which is sending your request to a model that runs in another Region, and the price of each model is the one for that Region. In the full AWS account, on the other hand, you choose the Region and you can use cross-Region profiles. For example, if you try a model from the new experience, what you spend comes out of your credits and is calculated with the us-east-2 price.
On the exam
A question on this topic can describe a bill that goes up or a slow application and ask you for the cause or the fix. Some phrases in the question point to the answer:
- "More detailed responses", which points to output tokens.
- "The same document on every call", which points to prompt caching or to RAG.
- "The full document doesn't fit", which points to the context window.
For example, if the question says a team pastes the same catalog at the beginning of every message and the input bill is high, the answer is prompt caching.
cloud path tip: if an option says that Amazon Bedrock on demand charges by the hour, rule it out, because on demand the charge is per token.
Review question
An internal chatbot sends the same 20 pages of company policies in every message, and the cost of input tokens is high. Which change lowers it without losing the policy information?
Next
- Amazon Bedrock pricing, with the price per million input and output tokens for each model and Region.
- Take an AI Practitioner practice exam at /examenes and review your result in domain 2.