Expand description
Centralised pricing logic for Anthropic models.
All cost calculations live here so that the engine, TUI, and any future consumer share a single source of truth. Update this file — and only this file — whenever Anthropic changes its pricing.
Prices are in USD per million tokens (as of 2026-06). Source: https://www.anthropic.com/pricing
| Model | Input | Output |
|---|---|---|
| Fable | $10.00 | $50.00 |
| Opus | $5.00 | $25.00 |
| Sonnet | $3.00 | $15.00 |
| Haiku | $1.00 | $5.00 |
Cache pricing (relative to input price):
- Cache reads: 0.10× input price (prompt-cache hit)
- Cache write (5m): 1.25× input price (5-minute TTL, the default)
- Cache write (1h): 2.00× input price (1-hour TTL, opt-in via
cache_ttl)
Functions§
- calculate_
cost - Calculate the USD cost of a single model turn (no cache-write TTL split).
- calculate_
cost_ optional_ split - Split-aware cost for callers holding an aggregate plus an optional TTL
split (the shape of
SessionEvent::Usage). When either split bucket is present the split rates apply; when both areNone, the aggregate is billed at the 5m rate — fail-cheap, never fail-expensive. - calculate_
cost_ split - Calculate the USD cost of a single model turn with the cache-write TTL split made first-class.