// What a Claude model costs, for the USD meter (release 27). An ESTIMATE: the // Console's usage page is the truth. // // USD per million tokens: input, output, and the cache-read multiplier of the // input price, from the prompt-caching page's table (2026-10-12). Cache writes // bill 1.25x input (5-minute TTL) or 2x (1-hour). The longest matching prefix // wins; an unknown Claude model is priced as Opus 5 (the dearer guess), and a // model that is not Claude (a local one on ollama) costs nothing. export type Price = { input: number; output: number; cacheReadMult: number }; export type CacheTtl = "5m" | "1h"; // The cache-WRITE multiplier of the input price, per TTL. export const CACHE_WRITE_MULT: Record = { "5m": 1.25, "1h": 2 }; export const PRICES: Readonly> = { "claude-fable-5-1": { input: 10, output: 50, cacheReadMult: 0.025 }, "claude-mythos-5-1": { input: 10, output: 50, cacheReadMult: 0.025 }, "claude-fable-5": { input: 10, output: 50, cacheReadMult: 0.1 }, "claude-mythos-5": { input: 10, output: 50, cacheReadMult: 0.1 }, "claude-opus-5-5": { input: 4, output: 20, cacheReadMult: 0.05 }, "claude-opus-5": { input: 5, output: 25, cacheReadMult: 0.1 }, "claude-opus-4": { input: 5, output: 25, cacheReadMult: 0.1 }, "claude-sonnet-5-5": { input: 2, output: 10, cacheReadMult: 0.05 }, "claude-sonnet-5": { input: 2, output: 10, cacheReadMult: 0.1 }, "claude-sonnet-4": { input: 3, output: 15, cacheReadMult: 0.1 }, // Up to 100k input tokens a request; more bills 5x (not modelled here). "claude-haiku-5-5": { input: 0.1, output: 0.5, cacheReadMult: 0.1 }, "claude-haiku-4-5": { input: 1, output: 5, cacheReadMult: 0.1 }, }; const FREE: Price = { input: 0, output: 0, cacheReadMult: 0 }; const BY_LENGTH = Object.keys(PRICES).sort((a, b) => b.length - a.length); export function priceOf(model: string): Price { if (!model.startsWith("claude-")) return FREE; for (const prefix of BY_LENGTH) if (model.startsWith(prefix)) return PRICES[prefix]; return PRICES["claude-opus-5"]; }