AWS Builder Center
Optimizing Costs for Claude Desktop and Claude Code on Amazon Bedrock

Optimizing Costs for Claude Desktop and Claude Code on Amazon Bedrock

Claude Desktop/Code via Bedrock often costs 1.5 - 4x more than expected, not due to pricing markup (Bedrock rates = Anthropic direct), but because of ~33K-token system prompt overhead per API call and prompt cache instability. When the cache prefix changes mid-session, you pay 1.25x write penalties instead of enjoying 90% read discounts. Fix: stabilize cache prefixes, enable 1-hour TTL, route simple tasks to Haiku, trim CLAUDE.md. Result: 60 - 90% cost reduction using existing Bedrock features.

The Challenge -
As enterprises adopt AI-powered coding assistants at scale, a common question emerges: "Why does our Claude Desktop/Code deployment cost more when routed through Amazon Bedrock compared to Anthropic's direct API?"
This is a valid concern. When organizations deploy Claude Code for 100-500+ developers, even small per-request cost differences compound into significant monthly bills. Teams have reported billing that appears 1.5x to 4x higher than initial estimates.
The good news: this is not a pricing markup issue, and it is entirely solvable through configuration and operational best practices. No custom software development is required.
What You'll Learn -
  • Why the billing gap exists (root cause analysis with token-level math)
  • How Claude Desktop/Code constructs API requests and why this matters for billing
  • Step-by-step solutions to reduce costs by 60-90% using existing Bedrock features
  • A phased implementation roadmap from quick wins to enterprise optimization
  • Monitoring and governance patterns for ongoing cost management
Prerequisites -
  • An AWS account with Amazon Bedrock access enabled
  • Claude model access granted in the Bedrock console (Sonnet, Haiku, or Opus family)
  • Claude Desktop or Claude Code configured to use Bedrock as the API provider
  • Basic familiarity with token-based LLM pricing
  • IAM permissions: bedrock:InvokeModel, cloudwatch:PutMetricData
Understanding the Cost Architecture -
How Claude Desktop/Code Constructs API Requests
To understand the billing behavior, you must first understand what Claude Desktop and Claude Code send to the API on every single turn. Unlike a simple chat application that sends just your message, these tools construct a complex request payload containing:
  1. A large built-in system prompt defining Claude's behavior, capabilities, and safety guidelines (~6,500 tokens)
  1. Tool schemas describing all available tools — file operations, terminal, search, etc. (~24,000 tokens for 27 tools)
  1. Project context including CLAUDE.md files and MCP server definitions (~2,000-20,000 tokens)
  1. Conversation history from the current session (30,000-120,000 tokens)
The 33,000-Token System Prompt
Independent analysis has measured the actual first-turn payload of Claude Code:

Component
Claude Code
Lean Alternative
System Prompt
~6,500 tokens
~2,000 tokens
Tool Schemas (27 tools)
~24,000 tokens
~4,500 tokens
Scaffolding Blocks
~2,000 tokens
None
Total Overhead
~32,800 tokens
~6,900 tokens
In real-world sessions, additional context pushes the total higher:
  • CLAUDE.md / instruction files: +10,000-20,000 tokens
  • MCP server definitions: +1,000-1,400 tokens per server
  • Conversation history: 30,000-120,000 tokens
  • Effective input per turn: 50,000-170,000 tokens
Token Pricing: Bedrock vs. Anthropic Direct API
Key Insight: There is NO per-token markup on Amazon Bedrock. Pricing is identical to Anthropic's direct API.
Model
Input/MTok
Output/MTok
Cache Write
Cache Read
Markup
Sonnet 4.5/4.6
$3.00
$15.00
$3.75
$0.30
None
Opus 4.5/4.8
$5.00
$25.00
$6.25
$0.50
None
Haiku 4.5
$1.00
$5.00
$1.25
$0.10
None
Sonnet 5*
$2.00
$10.00
$2.50
$0.20
None
*Sonnet 5 introductory pricing through August 31, 2026.
The Role of Prompt Caching -
Prompt caching is the mechanism that makes the 33K-token overhead manageable:
First request pays full input rate for the system prompt (cache write at 1.25x)
Subsequent requests within cache TTL pay only cache-read rate (0.1x — a 90% discount)
For 33K tokens on Sonnet 4.6: $0.099/turn without caching vs $0.0099/turn with caching
Prompt caching is not just a nice-to-have — it is the single largest cost lever for Claude Desktop/Code deployments on Bedrock.
Root Cause: Prompt Cache Instability -
What Is Prompt Cache Instability?
Prompt caching works by storing a prefix of the API request and reusing it when subsequent requests have an identical prefix. The critical word is "identical" — even a single byte difference invalidates the cache.
Claude Code's request prefix is inherently unstable:
  • Tool schema reordering: Tool definitions can change order between requests as capabilities load/unload
  • CLAUDE.md rewrites: Project instruction files modified mid-session change the prefix
  • MCP server state: Model Context Protocol servers contribute variable definitions
  • Multiple prefix classes: Different session states produce entirely different prefix patterns
Measured impact: Claude Code generates 5.9x to 54x more cache writes than a client with a stable prefix.
Cache Writes vs. Cache Reads: The Cost Difference
Operation
Rate (Sonnet 4.6)
Multiplier
When It Happens
Standard Input
$3.00/MTok
1.0x
No caching enabled
Cache Write
$3.75/MTok
1.25x (premium)
First request or after invalidation
Cache Read
$0.30/MTok
0.1x (90% off)
Subsequent matching requests
With an unstable prefix, you pay the cache-write premium (1.25x) repeatedly instead of enjoying the cache-read discount (0.1x). This is worse than having no caching at all.
Measuring Cache Hit Rates:
Inspect the usage field in Bedrock API responses:
{
"usage": {
"input_tokens": 5200,
"output_tokens": 1500,
"cache_creation_input_tokens": 0, // Cache writes (want: low)
"cache_read_input_tokens": 33000 // Cache hits (want: high)
}
}
A healthy deployment shows cache_read_input_tokens >> cache_creation_input_tokens after the first few requests.
The Cost Multiplication Effect (Worked Example) -
For a single developer making 150 API turns/day on Sonnet 4.6:
  • No Caching
  • Per turn: 33,000 tokens x $3.00/MTok = $0.099
  • Per day: 150 turns x $0.099 = $14.85
  • Per month (22 days): $326.70
  • Per year: $3,920 (system prompt alone, per developer)
  • Effective Caching (90% hit rate)
  • Cache write (1st turn): 33,000 x $3.75/MTok = $0.124
  • Cache reads (149 turns): 33,000 x $0.30/MTok = $0.0099 each
  • Per day: $0.124 + (149 x $0.0099) = $1.60
  • Per month: $35.15
  • Per year: $422 per developer
For 300 developers: the difference between no caching ($3,920/yr) and effective caching ($422/yr) on system prompt costs alone is over $1M annually.

Solution 1: Enable and Optimize Prompt Caching -
Highest-impact solution: 60-90% cost reduction on input tokens. Prompt caching on Bedrock GA since April 2025, 1-hour TTL added January 2026.
Step 1: Verify Caching Is Enabled
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1
export ANTHROPIC_MODEL=us.anthropic.claude-sonnet-4-20250514-v1:0

#CRITICAL: Do NOT set DISABLE_PROMPT_CACHING=1
Step 2: Choose the Right TTL
TTL
Best For
Considerations
5 min (default)
Rapid-fire coding with < 5 min between turns
Expires during meetings/testing
1 hour
Enterprise teams with variable cadence
Higher write cost but far fewer invalidations
Step 3: Stabilize Your Cache Prefix
  • Fix tool schema ordering — Load MCP servers in consistent sequence
  • Minimize CLAUDE.md churn — Batch updates between sessions
  • Limit MCP servers — Target 3-5 max
  • Consistent initialization — Standardize launch configs
  • Step 4: Monitor Cache Hit Rates CloudWatch target: >80% cache-hit ratio CacheReadInputTokenCount / (CacheRead + CacheWrite + Input)
Solution 2: Intelligent Model Routing -
Route tasks to the appropriate model tier for 40-70% blended cost reduction.
Tier
Task Types
Model
Input Cost
Simple
Autocomplete, linting, simple refactors
Haiku 4.5
$1.00/MTok
Standard
Code gen, debugging, tests, docs
Sonnet 4.5/4.6
$3.00/MTok
Complex
Architecture, multi-file refactoring
Opus 4.5/4.8
$5.00/MTok
Note - Switch in session: /model haiku | /model sonnet | /model opus
Solution 3: Reduce Token Overhead -
  • Keep CLAUDE.md under 2,000 tokens
  • Use project-scoped .mcp.json (3-5 servers max)
  • Use /compact regularly; start new sessions for unrelated tasks
  • Avoid excessive subagent spawning
Solution 4: Batch Inference and Flex Tier -
Up to 50% discount for async workloads (code review, docs, security scanning):
Option
Use Case
Discount
Latency
On-Demand
Interactive coding
Baseline
< 2 sec
Flex Tier
Background analysis
50% off
Secs to mins
Batch
Bulk/overnight jobs
50% off
Mins to hrs
Solution 5: Cross-Region + Reserved Capacity -
  • export ANTHROPIC_MODEL=us.anthropic.claude-sonnet-4-20250514-v1:0 # 10% savings
  • Higher throughput, better availability, reduced throttling
  • Reserved Tier: 20-50% off for committed volume (contact AWS)

Cost Impact Analysis: 300-Developer Enterprise -
Scenario
Monthly Cost
Savings
Annual
A: No optimization
$161,760
Baseline
$1.94M
B: Prompt caching (80% hit)
$105,120
-35%
$1.26M
C: + Model routing
$93,720
-42%
$1.12M
D: Full optimization stack
$84,000
-48%
$1.01M

Implementation Roadmap
  • Phase 1: Quick Wins (Week 1-2)
  • Verify caching - Check DISABLE_PROMPT_CACHING not set
  • Cross-region - Switch to us.anthropic.* model IDs
  • Audit CLAUDE.md - Trim to essentials
  • CloudWatch - Set up cache metrics dashboard
  • Expected: 20 - 40% immediate savings
  • Phase 2: Structural (Week 3-4)
  • Stabilize prefixes - Lock tool schemas, consistent MCP loading
  • Model routing - Haiku for simple, Sonnet standard
  • 1-hour TTL - Reduce expiration misses
  • Expected: 50 - 70% cumulative savings
  • Phase 3: Enterprise (Month 2+)
  • Batch inference - Async code review, docs
  • Reserved capacity - Committed-use pricing
  • Cost allocation - Per-team budgets
  • Expected: 70 - 90% total reduction
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article