Documentation
¶
Overview ¶
Command updatepricing regenerates pricing.json from Anthropic's published pricing documentation.
Anthropic publishes no pricing API — GET /v1/models returns capabilities and token limits but no rates — so the source of truth is the docs page, which is served as plain markdown with a stable "Model pricing" table:
https://platform.claude.com/docs/en/about-claude/pricing.md
The table lists display names ("Claude Opus 4.8") rather than API model IDs, so names are mapped to IDs mechanically: lowercase the family, replace the dot in the version with a dash. Rows carrying an effective date ("through August 31, 2026" / "starting September 1, 2026" — used for Claude Sonnet 5's introductory pricing) are filtered down to whichever row is in effect today.
Because that's a scraped source, every result is cross-checked against LiteLLM's machine-readable price list. Disagreements are reported but not fatal: LiteLLM lags new launches, and Anthropic's own page wins.
Prices are accumulated, never overwritten. pricing.json carries a dated history per model so that logs are always costed at the rate that applied on the day they were written; a price change appends a new period instead of rewriting the past. Announced future changes (Claude Sonnet 5's introductory rate ending August 31, 2026) are recorded with their exact start date, so they take effect on the right day without a regeneration having to land on it. A change we learn about only by observing the docs is dated the day this tool notices it — run it often enough that "noticed" stays close to "took effect".
Usage:
go run ./scripts/updatepricing # rewrite pricing.json go run ./scripts/updatepricing -check # exit 1 if pricing.json is stale