Cost Planning and Optimisation
AI costs need to be estimated before building and controlled afterwards. This lesson explains AWS Pricing Calculator, AWS Cost Explorer and the strategies that optimise AI costs without sacrificing value.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish AWS Pricing Calculator from AWS Cost Explorer.
- Calculate a token-based cost estimate.
- Identify strategies that optimise AI costs.
- Identify cost components that estimates for generative AI applications often miss.
- Explain unit economics, showback and chargeback for AI spending.
Planning costs before building
AWS Pricing Calculator is a free web-based tool for estimating the cost of AWS services before using them. Users select services, such as Amazon Bedrock or Amazon SageMaker AI, enter expected usage, such as requests per month and average input and output tokens per request, and the calculator produces monthly and annual estimates that can be grouped, saved and shared. Estimates are only as good as their assumptions, so they should be built for several usage scenarios and updated with data from pilots.
A token-based estimate follows a simple structure: requests per month multiplied by tokens per request, priced separately for input and output tokens. Small changes in prompt length, the amount of retrieved context or response length can change costs substantially at scale.
Monitoring actual costs
AWS Cost Explorer visualises and analyses actual AWS spending over time. It can filter and group costs by service, account, Region and cost allocation tags, which are labels such as project or business unit attached to resources, and it can forecast future spending from past patterns. For AI initiatives, it shows whether costs match the business case, which teams or applications drive spend, and when usage trends call for optimisation or commitments. Pairing it with budget thresholds and alerts helps prevent surprises.
Costs that estimates often miss
Estimates for generative AI applications frequently include only the model's token charges. A complete estimate also includes the other components the application uses. The following list describes the most commonly missed items.
- Retrieval components: creating embeddings for documents and questions, and storing and searching the vector index used by a knowledge base.
- Safeguards: guardrail evaluations, which are charged according to the amount of text checked.
- Growing context: conversation history and agent tool results that increase input tokens with every turn.
- Evaluation and testing: model calls used to test prompts and evaluate new models.
- Logging and monitoring: storing prompts, responses and traces for audit and quality review.
A complete estimate
Unit economics
Total monthly cost says little on its own, because it should rise when usage and value rise. The more useful measure is cost per unit of value: cost per resolved contact, per processed document, per completed task or per active user. Unit costs can be compared with the cost of the previous process and tracked over time, and a rising unit cost is a signal to investigate even when the total budget is not exceeded. Cost allocation tags make unit economics possible by attributing costs to each application and team.
Allocated costs can then be shown to each team (showback) or charged to their budgets (chargeback). Either approach makes teams aware of the cost consequences of their design choices, such as using the largest model for every request.
Cost per unit of value
Optimisation strategies
Several strategies reduce AI costs while preserving value. The following list summarises the most important ones.
- Right-size the model: use the smallest model that meets the quality bar, and route simple requests to cheaper models.
- Reduce tokens: concise prompts, limits on response length and retrieving only relevant passages.
- Cache repeated context: prompt caching lowers the cost of context sent repeatedly, such as long instructions or documents.
- Use cheaper processing modes: batch inference or the Flex tier on Amazon Bedrock for work that is not time-sensitive.
- Commit for steady use: Savings Plans for SageMaker AI and reserved capacity for Bedrock once usage is proven.
- Eliminate waste: shut down idle endpoints, retire unused applications and reclaim unused seats.
- Allocate and show costs: tag resources so that each team sees its AI spending.
Optimisation levers
Estimating and then optimising
A support assistant is expected to handle 300,000 requests a month. Each request sends 3,000 input tokens (instructions plus retrieved articles) and receives 400 output tokens. Assume a model priced at 0.003 USD per 1,000 input tokens and 0.015 USD per 1,000 output tokens. What is the monthly estimate, and how could it be reduced?
Input tokens: 300,000 x 3,000 = 900 million, costing 900,000 x 0.003 = 2,700 USD. Output tokens: 300,000 x 400 = 120 million, costing 120,000 x 0.015 = 1,800 USD. The estimate is about 4,500 USD a month, which could be modelled in AWS Pricing Calculator.
Input tokens dominate, so the biggest levers are on the input side: caching the fixed instructions, retrieving fewer but more relevant articles, and testing whether a smaller model meets the quality bar. After launch, AWS Cost Explorer with a project tag shows whether actual costs match the estimate.
A cost spike
A company's monthly Amazon Bedrock costs triple in one month, although the number of users has barely changed. Finance asks the AI programme lead to explain the increase and prevent it from recurring.
AWS Cost Explorer, grouped by cost allocation tag, shows that almost all of the increase comes from one application: a newly released agent that handles supplier queries. The cost per completed task is far above the estimate. Investigation finds that the agent sends its entire conversation and tool history with every step and sometimes repeats steps when a tool returns an error. The remedies are limits on steps per task, summarising history instead of resending it, and a cheaper model for simple steps. Budget alerts by tag and a unit-cost target for each application would detect such increases in days rather than at month end.
Which AWS tool would you use to see which project caused last month's increase in AI spending?
Show answer
AWS Cost Explorer, grouping costs by cost allocation tags such as project.
Exam Tips
Remember for the exam
- AWS Pricing Calculator estimates costs before building; AWS Cost Explorer analyses actual spend.
- Cost allocation tags let each team or project see its AI spending.
- Right-size models, reduce tokens, cache context and use batch or Flex for non-urgent work.
- Commit (Savings Plans, reserved capacity) only once usage is steady and proven.
- Estimates should include embeddings, vector storage, guardrails, growing context, evaluation and logging.
- Track unit economics, such as cost per resolved contact, not only total spend.