By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Your LLM application works great in development. Then you deploy it to production, and your cloud bill triples in a month. By then, you've already shipped to customers and the damage is done. Cost needs to be a design constraint from the start, not something you discover after launch.
The AWS Well-Architected Generative AI Lens breaks cost control into three actionable ideas: choose models and inference approaches that fit your actual requirements, control the variables that drive usage, and set hard boundaries so workflows can't run away. Each one is a design decision, not a tuning knob you turn later.
The most effective cost lever is model tiering. Route requests to different models based on what the task actually needs. A classification or extraction task doesn't need the same model as hard reasoning or code generation.
request ─▶ ROUTER (rules or a tiny model)
│
┌─────────┼───────────────────┐
▼ ▼ ▼
small/cheap mid-size large/expensive
(classify, (most chat, (hard reasoning,
extract) summaries) code, planning)
~80% of traffic ......................... ~5% of trafficStart from evidence. Run your evaluation set against several models and pick the cheapest one that passes your quality bar. This is not guesswork. Then build escalation: try the small model first, and only escalate to a larger one when confidence is low or validation fails. About 80% of your traffic will likely stay on the cheap path.
Re-test regularly. Smaller models improve every quarter. What required the expensive model six months ago might now work fine on a mid-tier model. If you don't re-evaluate, you're leaving money on the table.
Token consumption is your primary cost driver. You control it through several levers, each with different trade-offs.
Prompt length matters. Trim boilerplate from your system prompts. Retrieve fewer chunks for RAG, but make them count. Summarize old conversation history instead of sending the full thread. Each of these reduces input tokens without hurting quality if done right.
Output length is just as important. Set max output tokens explicitly. Ask for structured output like JSON instead of prose when the consumer is a machine. A JSON response is smaller and easier to parse.
For embedding-heavy applications, test smaller embedding dimensions. A 256-dimensional embedding costs less to store and search than a 1536-dimensional one. The quality drop might be acceptable for your use case.
Caching is often the single largest saving. Use it. For non-urgent work, batch APIs let you pay a lower per-token rate.
Enforce limits at multiple levels. Per-request: cap iterations, cap output tokens, set a deadline. Per-user or per-tenant: daily budgets with graceful degradation. When a user hits their daily budget, route to a cheaper model, queue the request, or return a clear message. Don't just fail silently.
Set up alerts on cost per request, tokens per minute, and anomalies. A sudden 10x jump in cost per request is almost always a bug or an attack. You want to know about it in minutes, not when the bill arrives.
Instrument your cost tracking from day one. Tag every API call with feature, tenant, and model. When your bill doubles, you need to know which feature caused it within minutes, not days. A cost dashboard showing tokens per day, cost per day, and cost per request by feature is non-negotiable.
cost dashboard (example shape)
feature tokens/day $/day $/request cache hit
chat 42M $180 $0.009 61%
doc-summary 11M $95 $0.041 12% ← investigate
agent-research 8M $240 $0.80 -- ← needs capsThe dashboard example above shows how quickly anomalies become visible. Doc-summary has a high cost per request and low cache hit rate. Agent-research has no cache at all and costs 80 cents per request. Without this breakdown, you're flying blind.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.