
Cost-Optimized LLMOps: Running a Production AI Agent for $3.35/Month
This blog explains why AI cost optimization is critical for running production-grade GenAI workloads sustainably and how to reduce LLM inference costs on Amazon Bedrock AgentCore using techniques such as intelligent model routing, prompt optimization, caching, token management, and observability. It solves the challenge of unpredictable AI spending by helping teams build scalable, cost-efficient, and high-performing AI applications without sacrificing quality or reliability.
π° Cost-Optimized LLMOps: Running a Production AI Agent for $3.35/Month
Part 3 of 3: How to build a production LLMOps pipeline on AWS for less than a cup of coffee.
Author: Ramandeep Chandna | Date: July 2026 | Level: 300+
Series: LLMOps Pipeline on AWS β Building, Evaluating, and Optimizing AI Agents
ο»Ώ
π Series Navigation
Part | Blog | Status |
|---|---|---|
Prequel | How I Built an IT Operations Agent That Actually Fixes Things (Not Just Reports Them) | Foundation |
Part 1 | How I Built a Production LLMOps Pipeline on AWS AgentCore End to End | Agent deployed β
|
Part 2 | LLMOps Evaluation: How I Got AgentCore Managed Evaluation Working on Container Runtimes | 9 evaluators active β
|
β Part 3 | This blog β Cost Analysis & Optimization | You are here |
ο»Ώ
π Where We Left Off (From Part 2)
In Part 2, we got 9 evaluators running on both Harness and Container runtimes:
- β 5 built-in evaluators (Helpfulness, Correctness, Relevance, Harmfulness, ToolSelection)
- β 4 custom evaluators (DevOpsQuality, SafetyCheck, ToolUsage, DiagnosisQuality)
- β Batch evaluation scoring sessions on both runtime types
The question now: What does all this actually cost? And how do we optimize it for production scale?
ο»Ώ
The Result: $3.35/Month for Everything
A complete production LLMOps pipeline β agent, 6 tools, guardrails, CI/CD, 9 evaluators, dual memory (AgentCore + DynamoDB), observability, frontend β running for $3.35/month (gross cost, before credits).

ο»Ώ
ο»Ώ
Why Amazon Nova Pro (Not Claude Sonnet)
Model | Input $/1M | Output $/1M | Monthly (my usage) | Credits? |
|---|---|---|---|---|
Claude Sonnet 4 | $3.00 | $15.00 | ~$50-80 | β Not covered |
Nova Pro | $0.80 | $3.20 | $0.38 | β
Covered |
Nova Lite | $0.06 | $0.24 | ~$0.05 | β
Covered |
Savings: 78% cost reduction vs Claude Sonnet. Same agent quality for DevOps tasks.
ο»Ώ
Complete Cost Breakdown (July 2026 β Actual AWS Bill)
Note : Table below reflects a different billing period than the console screenshot as Screenshot were captured later
Category | Usage Type | Cost |
|---|---|---|
Evaluations (Built-in) | BuiltIn-Input (Tier2) | $0.86 |
Evaluations (Built-in) | BuiltIn-Output (Tier2) | $0.51 |
AgentCore Runtime | Memory (GB-hours) | $0.64 |
Nova Pro (Agent) | Input tokens (305K) | $0.30 |
Memory (Dual) | AgentCore semantic + DynamoDB structured | $0.27 |
Evaluations (Custom) | Nova Pro judge (127 runs) | $0.19 |
Claude Sonnet | Earlier failed attempts | $0.34 |
Nova Pro (Agent) | Output tokens (19K) | $0.08 |
AgentCore Runtime | vCPU (hours) | $0.06 |
Guardrails | Content + Topic + PII | $0.01 |
Gateway | Tool indexing | $0.001 |
ο»Ώ | TOTAL | $3.35 |
ο»Ώ
Cost by Category (Visual)
Evaluations (Built-in) ββββββββββββββββββββ $1.37 (41%)AgentCore Runtime ββββββββ $0.71 (21%)Nova Pro tokens βββββ $0.38 (11%)Claude (old attempts) βββββ $0.34 (10%)Memory (LTM) ββββ $0.27 (8%)Custom Evaluators ββ $0.19 (6%)Everything else β $0.09 (3%)βββββββββββββββββββββββββββββββββββββββββββββββββββββββββTOTAL $3.35/monthο»Ώ
Model Routing Strategy (Production)
For higher-traffic production, use a smart router:
def select_model(prompt: str) -> str: """Route simple queries to Lite, complex to Pro.""" simple_patterns = ["list", "status", "health", "what can you"] if any(p in prompt.lower() for p in simple_patterns) and len(prompt) < 100: return "us.amazon.nova-lite-v1:0" # $0.06/1M β simple listing else: return "us.amazon.nova-pro-v1:0" # $0.80/1M β reasoning + toolsQuery Type | % Traffic | Model | Cost/1M tokens |
|---|---|---|---|
Simple (list, status) | ~70% | Nova Lite | $0.06 |
Complex (diagnose, fix) | ~30% | Nova Pro | $0.80 |
Blended average | 100% | Mix | ~$0.28/1M |
ο»Ώ
Evaluator Cost Analysis
Evaluator Type | What They Charge | Your Cost |
|---|---|---|
Built-in (5) | Tier2 token pricing (input + output) | $1.37/month |
Custom (4) | Your model invocation (Nova Pro) | $0.19/month |
Total | ο»Ώ | $1.56/month |
Key Insight: Built-in evaluators are NOT free. They charge Tier2 tokens. But at $0.14 per batch of 10 sessions, it's negligible.
Rule: Don't cheap out on the judge model. A Nova Lite judge gives unreliable scores. Keep judge at Nova Pro or higher.
ο»Ώ
Cost Scaling Projections
Daily Invocations | Agent Cost | Eval Cost | Runtime | Total/Month |
|---|---|---|---|---|
10/day (dev) | $0.38 | $1.56 | $0.71 | ~$3-5 |
100/day (staging) | $3.80 | $15 | $7 | ~$30 |
1000/day (prod) | $38 | $120 | $70 | ~$250 |
10K/day (scale) | $380 | $600 | $700 | ~$1,800 |
At 1000 invocations/day with full evaluation, you'd spend ~$250/month. That's cheap for a production AI agent with 9-evaluator quality monitoring.
ο»Ώ
Cost Reduction Strategies (With Implementation Code)
Strategy 1: Smart Model Routing β Route by Query Complexity
Instead of sending everything to Nova Pro ($0.80/1M), route simple queries to Nova Lite ($0.06/1M).
"""model_router.py β Intelligent model selection based on query complexity."""import reο»Ώ
NOVA_LITE = "us.amazon.nova-lite-v1:0" # $0.06/1M input β simple queriesNOVA_PRO = "us.amazon.nova-pro-v1:0" # $0.80/1M input β complex reasoningο»Ώ
# Patterns that indicate simple queries (no reasoning needed)SIMPLE_PATTERNS = [ r"^list\b", r"^show\b", r"^get\b", r"^what (is|are)\b", r"^status\b", r"^health\b", r"^count\b", r"^describe\b"]ο»Ώ
# Patterns that indicate complex queries (multi-step reasoning)COMPLEX_PATTERNS = [ r"diagnose", r"troubleshoot", r"why.*fail", r"root cause", r"fix\b", r"remediate", r"investigate", r"compare.*and"]ο»Ώ
def select_model(prompt: str) -> tuple[str, str]: """Returns (model_id, reason) based on query complexity.""" prompt_lower = prompt.lower().strip() # Check complex first (takes priority) for pattern in COMPLEX_PATTERNS: if re.search(pattern, prompt_lower): return NOVA_PRO, "complex_reasoning" # Check simple for pattern in SIMPLE_PATTERNS: if re.search(pattern, prompt_lower): return NOVA_LITE, "simple_query" # Default: use Pro for safety (better to overspend than give bad answers) if len(prompt) > 200: return NOVA_PRO, "long_prompt" return NOVA_LITE, "default_simple"ο»Ώ
# Usage in agent:# model_id, reason = select_model(user_prompt)# agent = Agent(model=BedrockModel(model_id=model_id, ...))Savings: 70% of typical DevOps queries are simple (list, status, health) β 70% traffic at $0.06 instead of $0.80 = ~85% token cost reduction.
ο»Ώ
Strategy 2: Prompt Caching β DynamoDB Response Cache
Cache frequent queries. If the same question was answered < 5 minutes ago, return cached response.
"""prompt_cache.py β Cache agent responses to avoid duplicate LLM calls."""import boto3import jsonimport hashlibimport timeο»Ώ
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')cache_table = dynamodb.Table('agent-response-cache')CACHE_TTL_SECONDS = 300 # 5 minutesο»Ώ
def get_cache_key(prompt: str) -> str: """Normalize prompt and create hash key.""" normalized = prompt.lower().strip() return hashlib.sha256(normalized.encode()).hexdigest()[:16]ο»Ώ
def get_cached_response(prompt: str) -> dict | None: """Check if a recent cached response exists.""" key = get_cache_key(prompt) try: item = cache_table.get_item(Key={'cache_key': key}).get('Item') if item and item.get('expires_at', 0) > int(time.time()): return {"response": item['response'], "cached": True, "saved_tokens": item.get('tokens_saved', 0)} except Exception: pass return Noneο»Ώ
def cache_response(prompt: str, response: str, tokens_used: int): """Store response in cache with TTL.""" key = get_cache_key(prompt) cache_table.put_item(Item={ 'cache_key': key, 'prompt': prompt[:200], 'response': response, 'tokens_saved': tokens_used, 'created_at': int(time.time()), 'expires_at': int(time.time()) + CACHE_TTL_SECONDS })ο»Ώ
# Usage in agent handler:# cached = get_cached_response(prompt)# if cached:# return cached["response"] # Skip LLM call entirely!# else:# response = agent(prompt)# cache_response(prompt, str(response), token_count)Savings: For repeated queries (health checks running every 5 min, status dashboards), caching eliminates 100% of duplicate LLM calls. Typical savings: 30-50% of total token cost.
ο»Ώ
Strategy 3: MCP Gateway β Avoid Agent Calls for Simple API Lookups
For queries that just need a direct API call (no reasoning), bypass the agent entirely and call the API via Gateway.
"""gateway_router.py β Route simple lookups directly to APIs, skip the LLM."""import boto3import jsonο»Ώ
# If a query maps directly to a single API call, skip the agentDIRECT_API_ROUTES = { "list instances": { "service": "ec2", "operation": "DescribeInstances", "params": {}, "format": lambda r: [{"id": i["InstanceId"], "state": i["State"]["Name"]} for res in r["Reservations"] for i in res["Instances"]] }, "list alarms": { "service": "cloudwatch", "operation": "DescribeAlarms", "params": {"StateValue": "ALARM"}, "format": lambda r: [{"name": a["AlarmName"], "state": a["StateValue"]} for a in r["MetricAlarms"]] }}ο»Ώ
def try_direct_route(prompt: str) -> dict | None: """If query matches a direct API route, call it without LLM.""" prompt_lower = prompt.lower().strip() for pattern, config in DIRECT_API_ROUTES.items(): if pattern in prompt_lower: client = boto3.client(config["service"], region_name="us-east-1") operation = getattr(client, config["operation"].replace( config["operation"][0], config["operation"][0].lower(), 1 ).replace("Describe", "describe_").rstrip("_")) # Simplified β in production use proper boto3 call try: response = getattr(client, ''.join(['_'+c.lower() if c.isupper() else c for c in config["operation"]]).lstrip('_') )(**config["params"]) return {"response": config["format"](response), "routed": "direct_api", "tokens_used": 0} except Exception: pass return None # No direct route found β use agentο»Ώ
# Usage:# direct = try_direct_route(prompt)# if direct:# return direct # Zero LLM cost!# else:# return agent(prompt) # Use LLM for complex queriesSavings: 20-30% of queries are simple lookups that don't need LLM reasoning. Routing them directly to APIs = $0 token cost for those queries.
ο»Ώ
Strategy 4: Reduce Evaluation Sampling in Production
Don't evaluate 100% of sessions. In production, sample 10-20%.
"""eval_sampling.py β Reduce evaluation cost by sampling."""ο»Ώ
# In your online evaluation config:# samplingPercentage: 10 (only score 10% of sessions)ο»Ώ
# For batch evaluation, run weekly instead of daily:# Schedule: Every Monday at 6 AM UTC# Sessions: Last 7 days# Evaluators: All 9ο»Ώ
# Cost impact:# 100% sampling: $1.56/month# 10% sampling: $0.16/month (90% savings)ο»Ώ
Strategy 5: Prompt Compression β Reduce Token Count
Shorter system prompts = fewer input tokens per call.
# BEFORE (verbose β 150 tokens):SYSTEM_PROMPT = """You are a production DevOps AI Agent responsible for monitoring,diagnosing, and remediating AWS infrastructure issues. You have access to CloudWatch,EC2, SSM, and SNS tools. Always diagnose before taking action. Explain your reasoningclearly. For destructive actions, explain why first. Provide clear summaries."""ο»Ώ
# AFTER (compressed β 60 tokens, same behavior):SYSTEM_PROMPT = """DevOps AI Agent. Tools: CloudWatch, EC2, SSM, SNS.Rules: 1) Diagnose before act 2) Explain reasoning 3) Justify destructive actions"""ο»Ώ
# Savings: 90 tokens/request Γ 1000 requests = 90K tokens saved# At $0.80/1M = $0.07 saved per 1000 requestsο»Ώ
Combined Savings Projection
Strategy | Savings | Effort |
|---|---|---|
Model routing (Lite/Pro) | 85% on tokens | Low (code change) |
Prompt caching (DynamoDB) | 30-50% on repeated calls | Medium (new table) |
Direct API routing (Gateway) | 20-30% calls skip LLM | Medium (route config) |
Eval sampling (10%) | 90% on eval cost | Low (config change) |
Prompt compression | 5-10% on input tokens | Low (prompt edit) |
Combined | ~70-80% total reduction | ο»Ώ |
Before optimization: $3.35/month (current)
After all strategies: ~$0.80-1.00/month (projected)
ο»Ώ
Where to Verify Costs (Console)
Cost Explorer β Group by: Usage Type β Filter: Service = "Amazon Bedrock AgentCore"You'll see:
- Β
Evaluations:Consumption-based:BuiltIn-Input:Tier2Β
- Β
Evaluations:Consumption-based:CustomEvaluators:Tier1Β
- Β
Runtime:Consumption-based:MemoryΒ
- Β
NovaPro-input-tokensΒ
- Β
NovaPro-output-tokensΒ

ο»Ώ

ο»Ώ

ο»Ώ
ο»Ώ
Full Architecture (What $3.35/Month Gets You)

ο»Ώ

ο»Ώ
Component | Included | Cost Contribution |
|---|---|---|
AI Agent (Nova Pro, 6 tools) | β
| $0.38 |
AgentCore Runtime (serverless) | β
| $0.71 |
Bedrock Guardrails | β
| $0.01 |
CI/CD (CodeBuild ARM64) | β
| ~$5 (builds on demand) |
9 Evaluators (LLM-as-Judge) | β
| $1.56 |
Cross-session Memory | β
| $0.27 |
OpenTelemetry Tracing | β
| included |
DynamoDB (memory table) | β
| ~$0.01 |
ECR (image storage) | β
| ~$0.10 |
Key Takeaways
- $3.35/month for a production LLMOps pipeline β agent + eval + guardrails + CI/CD
- Nova Pro > Claude Sonnet for agents β 78% cheaper, same quality for DevOps tasks
- Built-in evaluators aren't free β they charge Tier2 tokens ($1.37 for our usage)
- Custom evaluators are CHEAP β $0.19 for 127 runs (your model, your cost)
- Model routing at scale β Nova Lite for simple, Nova Pro for complex
- All covered by AWS credits β $0.00 actual out-of-pocket
ο»Ώ
π Series Conclusion
Across 3 blog posts + 1 prequel, we went from zero to a complete production LLMOps pipeline:
Blog | What We Achieved |
|---|---|
Prequel (Previous Blog) | Built a working agent with 12 tools |
Part 1 (This series) | Added guardrails, CI/CD, Nova Pro, OTEL tracing |
Part 2 | Got managed evaluation working (7 challenges solved) |
Part 3 | Proved it costs $3.35/month β production viable |
The complete stack:
- π€ Agent: Nova Pro + 6 tools + Strands framework
- π‘οΈ Security: Guardrails (content + PII + injection) + Cedar policies
- π Deployment: CodeBuild ARM64 β ECR β AgentCore auto-deploy
- π§ͺ Evaluation: 9 evaluators (LLM-as-Judge) on every session
- π Observability: OpenTelemetry traces with session.id
- πΎ Memory: DynamoDB cross-session persistence
- π° Cost: $3.35/month all-in
ο»Ώ
Previous: Part 2: Β LLMOps Evaluation: How I Got AgentCore Managed Evaluation Working on Container RuntimesΒ
Full series start: Part 1: Β Building a Production AI Agent on Amazon Bedrock AgentCore From Code to DeploymentΒ
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article