anth-cost-tuning

Featured

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".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 ```python 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, "cache_read": 1.50}, } rates = pricing[model] uncached_input = input_tokens - cached_input cost = ( uncached_input * rates["input"] + cached_input * rates["cache_read"] + output_tokens * rates["output"] ) / 1_000_000 if use_batch: cost *= 0.5 return cost # Example: 10K requests/day, 500 input + 200 output tokens ...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category