Estimating and Reducing Foundation Model Inference Costs
This lesson explains the cost structure of foundation model inference, how to evaluate its cost implications in production and how to manage it with usage optimisation.
Learning outcomes
After completing this lesson, you will be able to:
- Calculate FM cost per request.
- Reduce input and output tokens.
- Choose a deployment model by cost and volume.
How FM costs are calculated
On-demand Bedrock cost per request is input tokens x input price + output tokens x output price, with output tokens usually several times more expensive. Prices differ greatly between models. RAG adds retrieved context to input tokens; conversation history accumulates; agents make several model calls per task; guardrails, embeddings and reranking add their own charges. Provisioned Throughput is charged per model unit per hour regardless of use, and self-hosted models cost instance hours.
Cost per request (on-demand):
input: 3,000 tokens x price_in / 1,000
output: 400 tokens x price_out / 1,000
Monthly cost = cost per request x requests per month
Compare with: Provisioned Throughput hours x price, or self-hosted instance hoursEstimate the bill
Usage optimisation
Reduce input tokens by shortening system prompts, retrieving fewer but better chunks (reranking helps), summarising conversation history and using prompt caching for repeated prefixes. Reduce output tokens with explicit length instructions, structured formats and maxTokens limits. Reduce the number of calls by caching answers to repeated questions and batching. Reduce the price per token with smaller or distilled models, intelligent prompt routing, batch inference and the Flex tier.
Cut input or output tokens?
Choosing a deployment model by cost
At low or variable volume, on-demand is usually cheapest. At very high, steady volume, Provisioned Throughput, the Reserved tier or self-hosting an open model may cost less per token, but they shift utilisation risk to you. The following table summarises the optimisation levers.
| Lever | Reduces |
|---|---|
| Prompt caching | Cost and latency of repeated input prefixes |
| Shorter prompts, fewer chunks, history summarisation | Input tokens |
| Length limits and concise formats | Output tokens |
| Response caching | Number of calls |
| Smaller, distilled or routed models | Price per token |
| Batch inference, Flex tier | Price for non-urgent work |
The following diagram compares the input tokens per request of a RAG assistant before and after four cost-saving changes.

Estimating and cutting cost
A RAG assistant handles 2 million requests per month with 6,000 input tokens (including 8 chunks) and 500 output tokens per request on a large model.
- Reranking lets the assistant send 3 chunks instead of 8, cutting input to about 2,500 tokens.
- Prompt caching covers the 1,000-token system prompt and instructions.
- Intelligent prompt routing sends simpler questions to the smaller model in the family.
- A cache answers the 15% of questions that repeat exactly.
Evaluation confirms quality is unchanged, and estimated monthly cost falls by more than 60%. Buying Provisioned Throughput first would have locked in capacity for the inefficient prompts.
How is on-demand foundation model cost calculated?
Show answer
Input tokens × input price plus output tokens × output price; output tokens usually cost more.
Exam Tips
Remember for the exam
- On-demand cost = input tokens x input price + output tokens x output price.
- Output tokens usually cost more than input tokens.
- Repeated prefixes: prompt caching; repeated questions: response cache.
- Fewer, better chunks via reranking cut RAG input tokens.
- Optimize usage before buying provisioned capacity.