diff --git a/lib/stats/token-usage.mjs b/lib/stats/token-usage.mjs index 229da4f..291b73d 100644 --- a/lib/stats/token-usage.mjs +++ b/lib/stats/token-usage.mjs @@ -27,6 +27,7 @@ import { join, dirname } from 'node:path'; // Per-Mtok USD prices, resolved 2026-06-26 via the claude-api skill reference: // base input/output from the model table; cache rates from the prompt-caching // doc multipliers (cache_read 0.1x, write_5m 1.25x, write_1h 2.0x of input). +// claude-fable-5 resolved 2026-07-02 from the official platform pricing docs. export const PRICE_TABLE = Object.freeze({ 'claude-opus-4-8': Object.freeze({ input: 5.0, @@ -35,10 +36,17 @@ export const PRICE_TABLE = Object.freeze({ cache_write_5m: 6.25, cache_write_1h: 10.0, }), + 'claude-fable-5': Object.freeze({ + input: 10.0, + output: 50.0, + cache_read: 1.0, + cache_write_5m: 12.5, + cache_write_1h: 20.0, + }), }); // Date the PRICE_TABLE values were resolved/verified. Bump when prices change. -export const PRICE_TABLE_VERSION = '2026-06-26'; +export const PRICE_TABLE_VERSION = '2026-07-02'; function num(v) { return typeof v === 'number' && Number.isFinite(v) ? v : 0; diff --git a/tests/lib/token-usage.test.mjs b/tests/lib/token-usage.test.mjs index bccdfe7..3df92d4 100644 --- a/tests/lib/token-usage.test.mjs +++ b/tests/lib/token-usage.test.mjs @@ -75,6 +75,15 @@ test('deriveCost — hand-computed value for a known model (cache-aware)', () => assert.equal(is_estimate, false); }); +test('deriveCost — hand-computed value for claude-fable-5 (v5.9 fable tier)', () => { + const totals = { tokens_input: 3000, tokens_output: 500, tokens_cache_creation: 1000, tokens_cache_read: 6000 }; + const { cost_usd, is_estimate } = deriveCost(totals, 'claude-fable-5'); + // (3000×10 + 500×50 + 1000×12.5 + 6000×1) / 1e6 + // = (30000 + 25000 + 12500 + 6000) / 1e6 = 73500 / 1e6 = 0.0735 + assert.equal(cost_usd, 0.0735); + assert.equal(is_estimate, false); +}); + test('deriveCost — refuse-to-estimate for an unknown model', () => { const totals = { tokens_input: 3000, tokens_output: 500, tokens_cache_creation: 1000, tokens_cache_read: 6000 }; const out = deriveCost(totals, 'claude-unknown-9');