From a294a12b91b34b07f88662109665ae72e598819a Mon Sep 17 00:00:00 2001 From: tianyao Date: Thu, 23 Jul 2026 10:24:37 +0000 Subject: [PATCH] fix(pricing): refresh Claude and Gemini pricing to current vendor rates Anthropic, Google, and OpenAI have all shipped newer models and price changes since this table was last touched. Adds Claude Opus 4.7/4.8, Sonnet 5, and Fable/Mythos 5 pricing, and replaces the stale/guessed Gemini 3.x entries with current per-model rates (3, 3.1, 3.5, 3.6 Flash/Pro/Flash-Lite tiers), which also covers Google Antigravity sessions since that tool runs on Gemini models. Co-Authored-By: Claude Sonnet 5 --- cli/src/utils/pricing.test.ts | 30 ++++++++++++++++++++++++++++++ cli/src/utils/pricing.ts | 26 +++++++++++++++++++++----- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/cli/src/utils/pricing.test.ts b/cli/src/utils/pricing.test.ts index 8a761ed8..97403f11 100644 --- a/cli/src/utils/pricing.test.ts +++ b/cli/src/utils/pricing.test.ts @@ -42,6 +42,36 @@ describe('getModelPricing', () => { const pricing = getModelPricing('claude-3-5-haiku-20241022'); expect(pricing).toEqual({ input: 0.8, output: 4 }); }); + + it('returns exact match for Claude Opus 4.8', () => { + const pricing = getModelPricing('claude-opus-4-8'); + expect(pricing).toEqual({ input: 5, output: 25 }); + }); + + it('returns exact match for Claude Sonnet 5', () => { + const pricing = getModelPricing('claude-sonnet-5'); + expect(pricing).toEqual({ input: 3, output: 15 }); + }); + + it('returns exact match for Claude Fable 5', () => { + const pricing = getModelPricing('claude-fable-5'); + expect(pricing).toEqual({ input: 10, output: 50 }); + }); + + it('returns prefix match for a dated Opus 4.8 variant, not the older 4.x entries', () => { + const pricing = getModelPricing('claude-opus-4-8-20260601'); + expect(pricing).toEqual({ input: 5, output: 25 }); + }); + + it('returns updated pricing for Gemini 3.1 Pro', () => { + const pricing = getModelPricing('gemini-3.1-pro'); + expect(pricing).toEqual({ input: 2, output: 12 }); + }); + + it('returns updated pricing for Gemini 3 Flash, distinct from Gemini 3.5 Flash', () => { + expect(getModelPricing('gemini-3-flash')).toEqual({ input: 0.5, output: 3 }); + expect(getModelPricing('gemini-3.5-flash')).toEqual({ input: 1.5, output: 9 }); + }); }); describe('calculateCost', () => { diff --git a/cli/src/utils/pricing.ts b/cli/src/utils/pricing.ts index 3d0aa37f..6deab965 100644 --- a/cli/src/utils/pricing.ts +++ b/cli/src/utils/pricing.ts @@ -1,7 +1,7 @@ /** * Model pricing table and cost calculation utilities. - * Prices are USD per 1M tokens, sourced from Anthropic's pricing page. - * Last updated: 2026-02-18 + * Prices are USD per 1M tokens, sourced from each vendor's pricing page. + * Last updated: 2026-07-23 */ export interface ModelPricing { @@ -23,6 +23,12 @@ export interface UsageEntry { // Cache read tokens are priced at 10% of input price (Anthropic standard) // Cache creation tokens are priced at 25% more than input price const MODEL_PRICING: Record = { + // Claude 5.x / Fable family — longest/most-specific keys first + 'claude-fable-5': { input: 10, output: 50 }, + 'claude-mythos-5': { input: 10, output: 50 }, + 'claude-opus-4-8': { input: 5, output: 25 }, + 'claude-opus-4-7': { input: 5, output: 25 }, + 'claude-sonnet-5': { input: 3, output: 15 }, // Claude 4.x family 'claude-opus-4-6': { input: 5, output: 25 }, 'claude-opus-4-5': { input: 5, output: 25 }, @@ -41,13 +47,23 @@ const MODEL_PRICING: Record = { 'claude-3-sonnet-20240229': { input: 3, output: 15 }, 'claude-3-haiku-20240307': { input: 0.25, output: 1.25 }, - // Gemini family + // Gemini family (incl. Google Antigravity, which runs on Gemini models) — + // longest/most-specific keys first. Pro-tier prices are the <=200K-context + // tier; requests beyond that context window are billed higher by Google. + 'gemini-3.6-flash': { input: 1.5, output: 7.5 }, + 'gemini-3.5-flash-lite': { input: 0.3, output: 2.5 }, + 'gemini-3.5-flash': { input: 1.5, output: 9 }, + 'gemini-3.1-flash-lite': { input: 0.25, output: 1.5 }, + 'gemini-3.1-pro': { input: 2, output: 12 }, + 'gemini-3-flash': { input: 0.5, output: 3 }, + 'gemini-3-pro': { input: 2, output: 12 }, + 'gemini-2.5-flash-lite': { input: 0.1, output: 0.4 }, + 'gemini-2.5-flash': { input: 0.3, output: 2.5 }, + 'gemini-2.5-pro': { input: 1.25, output: 10 }, 'gemini-2.0-pro': { input: 3.5, output: 10.5 }, 'gemini-2.0-flash': { input: 0.1, output: 0.4 }, 'gemini-1.5-pro': { input: 3.5, output: 10.5 }, 'gemini-1.5-flash': { input: 0.075, output: 0.3 }, - 'gemini-3.1-pro': { input: 3.5, output: 10.5 }, - 'gemini-3.1-flash': { input: 0.1, output: 0.4 }, // OpenAI GPT-5.x family (incl. Codex CLI models) — longest/most-specific keys first 'gpt-5.6-luna': { input: 1, output: 6 },