-
-
Notifications
You must be signed in to change notification settings - Fork 343
feat: update model pricing with Claude 4.5 and version-specific rates #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,24 +27,84 @@ class PricingCalculator: | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FALLBACK_PRICING: Dict[str, Dict[str, float]] = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "opus": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "opus-4-5": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 5.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 25.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 6.25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sonnet-4-5": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 3.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 3.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "haiku-4-5": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 1.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 5.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 1.25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "opus-4": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 75.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 18.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 1.5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sonnet": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sonnet-4": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 3.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 3.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "haiku": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "haiku-3-5": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 0.8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 4.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 1.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.08, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sonnet-3-5": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 3.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 3.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "opus-3": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 75.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 18.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 1.5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sonnet-3": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 3.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 3.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "haiku-3": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 0.25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 1.25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 0.3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.03, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "opus": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 5.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 25.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 6.25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "sonnet": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 3.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 15.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 3.75, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "haiku": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "input": 1.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "output": 5.0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_creation": 1.25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cache_read": 0.1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def __init__( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -56,15 +116,17 @@ def __init__( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| custom_pricing: Optional custom pricing dictionary to override defaults. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Should follow same structure as MODEL_PRICING. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Use fallback pricing if no custom pricing provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.pricing: Dict[str, Dict[str, float]] = custom_pricing or { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-opus": self.FALLBACK_PRICING["opus"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-sonnet": self.FALLBACK_PRICING["sonnet"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-haiku": self.FALLBACK_PRICING["haiku"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-5-sonnet": self.FALLBACK_PRICING["sonnet"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-5-haiku": self.FALLBACK_PRICING["haiku"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-sonnet-4-20250514": self.FALLBACK_PRICING["sonnet"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-opus-4-20250514": self.FALLBACK_PRICING["opus"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-opus-4-5": self.FALLBACK_PRICING["opus-4-5"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-sonnet-4-5": self.FALLBACK_PRICING["sonnet-4-5"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-haiku-4-5": self.FALLBACK_PRICING["haiku-4-5"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-opus-4": self.FALLBACK_PRICING["opus-4"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-sonnet-4": self.FALLBACK_PRICING["sonnet-4"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-5-sonnet": self.FALLBACK_PRICING["sonnet-3-5"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-5-haiku": self.FALLBACK_PRICING["haiku-3-5"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-opus": self.FALLBACK_PRICING["opus-3"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-sonnet": self.FALLBACK_PRICING["sonnet-3"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "claude-3-haiku": self.FALLBACK_PRICING["haiku-3"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._cost_cache: Dict[str, float] = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -132,6 +194,13 @@ def calculate_cost( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._cost_cache[cache_key] = cost | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return cost | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _ensure_cache_pricing(self, pricing: Dict[str, float]) -> Dict[str, float]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "cache_creation" not in pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing["cache_creation"] = pricing["input"] * 1.25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "cache_read" not in pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing["cache_read"] = pricing["input"] * 0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return pricing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _get_pricing_for_model( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self, model: str, strict: bool = False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Dict[str, float]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -152,34 +221,48 @@ def _get_pricing_for_model( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check configured pricing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if normalized in self.pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing = self.pricing[normalized] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ensure cache pricing exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "cache_creation" not in pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing["cache_creation"] = pricing["input"] * 1.25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "cache_read" not in pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing["cache_read"] = pricing["input"] * 0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return pricing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check original model name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self._ensure_cache_pricing(self.pricing[normalized]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if model in self.pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing = self.pricing[model] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "cache_creation" not in pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing["cache_creation"] = pricing["input"] * 1.25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "cache_read" not in pricing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pricing["cache_read"] = pricing["input"] * 0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return pricing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # If strict mode, raise KeyError for unknown models | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self._ensure_cache_pricing(self.pricing[model]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if strict: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise KeyError(f"Unknown model: {model}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fallback to hardcoded pricing based on model type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self._get_fallback_pricing(model) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _get_fallback_pricing(self, model: str) -> Dict[str, float]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model_lower = model.lower() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_4_5 = "4-5" in model_lower or "4.5" in model_lower | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_4 = not is_4_5 and ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "4-" in model_lower or "-4-" in model_lower or "4.1" in model_lower | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_3_5 = "3-5" in model_lower or "3.5" in model_lower | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "opus" in model_lower: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["opus"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_4_5: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["opus-4-5"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_4: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["opus-4"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["opus-3"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+237
to
+248
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version detection may miss models ending in "-4". The 🔧 Suggested fix to handle trailing -4- is_4 = not is_4_5 and (
- "4-" in model_lower or "-4-" in model_lower or "4.1" in model_lower
- )
+ is_4 = not is_4_5 and (
+ "4-" in model_lower or "-4-" in model_lower or
+ model_lower.endswith("-4") or "4.1" in model_lower
+ )📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "haiku" in model_lower: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["haiku"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Default to Sonnet pricing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_4_5: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["haiku-4-5"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_3_5: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["haiku-3-5"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["haiku-3"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "sonnet" in model_lower: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_4_5: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["sonnet-4-5"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_4: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["sonnet-4"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if is_3_5: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["sonnet-3-5"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["sonnet-3"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self.FALLBACK_PRICING["sonnet"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def calculate_cost_for_entry( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Claude API pricing January 2025 official documentation💡 Result:
As of January 2025, Anthropic’s official Claude API documentation lists token-based pricing (per 1M tokens) and related multipliers. Key published rates:
Other documented details:
Sources: Anthropic / Claude official docs. [1] https://docs.claude.com/en/docs/about-claude/pricing [2] https://docs.anthropic.com/en/docs/about-claude/models/all-models
🌐 Web query:
Claude 4.5 opus sonnet haiku pricing per million tokens 2025💡 Result:
Here are Anthropic’s Claude 4.5 (Opus / Sonnet / Haiku) API prices per million tokens (USD):
Sources: Anthropic product/news and pricing pages. [1] Anthropic announcement; [2] Claude pricing page; [3] Claude docs (models & pricing).
🌐 Web query:
Claude 4 opus sonnet pricing input output per million tokens💡 Result:
Summary (per‑million‑token API pricing):
Sources: Anthropic/Claude pricing pages and docs. [1] [2] [3]
References:
[1] Anthropic models overview / pricing. (docs.anthropic.com)
[2] Claude pricing page (official). (claude.com)
[3] Recent pricing summary / blog posts (Opus/Sonnet 4.5 announcements). (website.claude.com)
Citations:
🌐 Web query:
Claude 3.5 haiku sonnet pricing input output per million tokens💡 Result:
Short answer — per Anthropic’s docs (current model pages):
Note: some news reporting (Nov 2024) states Claude 3.5 Haiku was later listed at $1 /M input and $5 /M output; you may see either pair in different pages. [3]
Sources: Anthropic model/pricing docs and Claude pricing page. [1][2][3]
🌐 Web query:
Claude 3 opus sonnet haiku pricing input output per million tokens💡 Result:
Summary (price per 1M tokens, USD):
Notes: Anthropic’s docs also list prompt‑caching multipliers (5‑min and 1‑hr cache write rates and cache read rates) that affect billed rates; see the cited pricing table for details. [1][2]
Sources: Anthropic / Claude docs pricing tables. [1] [2]
🌐 Web query:
Claude prompt caching pricing cache write cache read multiplier per million tokens💡 Result:
Short answer:
Multiplier: cache write = 1.25× base input price (25% higher); cache read = 0.10× base input price (10% of base). [1][2]
Example prices (per MTok = per million tokens) reported by Anthropic for Claude models:
Sources: Anthropic prompt-caching blog and Claude pricing docs. [1][2]
Pricing structure verified against official documentation and correctly implemented.
All base input/output prices match Anthropic's official Claude API pricing as of January 2025:
Cache pricing multipliers are correctly applied (1.25× for cache writes, 0.10× for cache reads).
Minor note: The
haiku-3-5entry uses $0.80/$4 per official documentation, but Anthropic updated Claude 3.5 Haiku pricing to $1/$5 in November 2024. Consider updatinghaiku-3-5to match the current rate, or document why the earlier pricing is retained. The generichaikufallback correctly defaults to the current 4.5 pricing ($1/$5).🤖 Prompt for AI Agents