| name | anth-cost-tuning |
| description | Optimize Anthropic Claude API costs with model routing, prompt caching,
batching, and spend monitoring.
Use when analyzing Claude API billing, reducing costs,
or implementing cost controls and budget alerts.
Trigger with phrases like "anthropic cost", "claude billing",
"reduce claude spend", "anthropic budget", "claude pricing optimize".
|
| allowed-tools | Read, Write, Edit, Grep |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ai","anthropic"] |
| compatibility | Designed for Claude Code |
Anthropic Cost Tuning
Overview
Optimize Claude API spend through model routing, prompt caching, the Message Batches API, and real-time cost tracking. The four biggest levers: model selection (4-19x), prompt caching (10x input), batches (2x), and max_tokens discipline.
Pricing Reference (per million tokens)
| Model | Input | Output | Cache Read | Cache Write |
|---|
| Claude Haiku | $0.80 | $4.00 | $0.08 | $1.00 |
| Claude Sonnet | $3.00 | $15.00 | $0.30 | $3.75 |
| Claude Opus | $15.00 | $75.00 | $1.50 | $18.75 |
Message Batches: 50% off all model pricing for async processing.
Cost Calculator
def estimate_cost(
input_tokens: int,
output_tokens: int,
model: str = "claude-sonnet-4-20250514",
cached_input: int = 0,
use_batch: bool = False
) -> float:
pricing = {
"claude-haiku-4-20250514": {"input": 0.80, "output": 4.00, "cache_read": 0.08},
"claude-sonnet-4-20250514": {"input": 3.00, "output": 15.00, "cache_read": 0.30},
"claude-opus-4-20250514": {"input": 15.00, "output": 75.00, : },
}
rates = pricing[model]
uncached_input = input_tokens - cached_input
cost = (
uncached_input * rates[] +
cached_input * rates[] +
output_tokens * rates[]
) /
use_batch:
cost *=
cost
daily = estimate_cost(, , ) *
()
()
daily_optimized = estimate_cost(, , , use_batch=) *
()