From e8057a70734e1d7556dbc53aec1739c73d0cf8cf Mon Sep 17 00:00:00 2001 From: Sergey Galuza Date: Sun, 31 May 2026 18:16:23 +0200 Subject: [PATCH] refactor(pricing): share Opus fast-tier rate constants Hoist the fast-mode rate sets into OPUS_46_47_FAST_RATES and OPUS_48_FAST_RATES module constants (built via buildRates) so the registry entries reference shared values instead of repeating literal buildRates(...) calls. Also wires the fast tier onto the -thinking aliases (claude-opus-4-6-thinking / -4-7-thinking) so they bill at the same premium as their base ids. Built [OnSteroids](https://onsteroids.ai) --- src/web-server/model-pricing.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/web-server/model-pricing.ts b/src/web-server/model-pricing.ts index ab423c07..c8afc8e2 100644 --- a/src/web-server/model-pricing.ts +++ b/src/web-server/model-pricing.ts @@ -70,6 +70,13 @@ function buildRates(inputPerMillion: number, outputPerMillion: number): PricingR }; } +// Anthropic fast-mode premiums (per +// https://platform.claude.com/docs/en/about-claude/pricing#fast-mode-pricing). +// Opus 4.6 and 4.7 share the same 6x premium; 4.8 is 2x. Shared constants keep +// the registry entries in sync rather than repeating the literal rates. +const OPUS_46_47_FAST_RATES = buildRates(30.0, 150.0); +const OPUS_48_FAST_RATES = buildRates(10.0, 50.0); + // ============================================================================ // USER-EDITABLE PRICING TABLE // Update rates below (per million tokens in USD) @@ -267,7 +274,7 @@ const PRICING_REGISTRY: Record = { cacheCreationPerMillion: 6.25, cacheReadPerMillion: 0.5, serviceTiers: { - fast: buildRates(30.0, 150.0), + fast: OPUS_46_47_FAST_RATES, }, }, 'claude-opus-4-6-thinking': { @@ -275,6 +282,9 @@ const PRICING_REGISTRY: Record = { outputPerMillion: 25.0, cacheCreationPerMillion: 6.25, cacheReadPerMillion: 0.5, + serviceTiers: { + fast: OPUS_46_47_FAST_RATES, + }, }, // Claude 4.7 Opus ($5/$25) — fast mode ($30/$150, 6x premium per Anthropic docs) 'claude-opus-4-7': { @@ -283,7 +293,7 @@ const PRICING_REGISTRY: Record = { cacheCreationPerMillion: 6.25, cacheReadPerMillion: 0.5, serviceTiers: { - fast: buildRates(30.0, 150.0), + fast: OPUS_46_47_FAST_RATES, }, }, // Claude 4.8 Opus ($5/$25) — fast mode ($10/$50, 2x premium per Anthropic docs) @@ -293,7 +303,7 @@ const PRICING_REGISTRY: Record = { cacheCreationPerMillion: 6.25, cacheReadPerMillion: 0.5, serviceTiers: { - fast: buildRates(10.0, 50.0), + fast: OPUS_48_FAST_RATES, }, }, 'claude-opus-4-7-thinking': { @@ -301,6 +311,9 @@ const PRICING_REGISTRY: Record = { outputPerMillion: 25.0, cacheCreationPerMillion: 6.25, cacheReadPerMillion: 0.5, + serviceTiers: { + fast: OPUS_46_47_FAST_RATES, + }, }, // ---------------------------------------------------------------------------