Skip to main content

Module pricing

Module pricing 

Source
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

ModelInputOutput
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 are None, 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.