From 823693afda2ff8354974568ef28f6d33e0fc687b Mon Sep 17 00:00:00 2001 From: sczheng189 <724100151@qq.com> Date: Mon, 23 Feb 2026 23:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/api.js | 4 +++- src/services/pricingService.js | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/routes/api.js b/src/routes/api.js index c469dd2f..85ad01f5 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -469,7 +469,9 @@ async function handleMessagesRequest(req, res) { cache_read_input_tokens: cacheReadTokens } const requestBetaHeader = - _headers['anthropic-beta'] || _headers['Anthropic-Beta'] || _headers['ANTHROPIC-BETA'] + _headers['anthropic-beta'] || + _headers['Anthropic-Beta'] || + _headers['ANTHROPIC-BETA'] if (requestBetaHeader) { usageObject.request_anthropic_beta = requestBetaHeader } diff --git a/src/services/pricingService.js b/src/services/pricingService.js index 55423361..0eb3b2f6 100644 --- a/src/services/pricingService.js +++ b/src/services/pricingService.js @@ -566,11 +566,11 @@ class PricingService { if (!key.startsWith('fast/')) { continue } - const normalizedFastKey = key - .slice('fast/'.length) - .toLowerCase() - .replace(/[_-]/g, '') - if (normalizedFastKey.includes(normalizedModel) || normalizedModel.includes(normalizedFastKey)) { + const normalizedFastKey = key.slice('fast/'.length).toLowerCase().replace(/[_-]/g, '') + if ( + normalizedFastKey.includes(normalizedModel) || + normalizedModel.includes(normalizedFastKey) + ) { logger.debug(`💰 Found fuzzy fast pricing for ${modelName}: ${key}`) return value } @@ -700,7 +700,7 @@ class PricingService { // 确定实际使用的输入价格(普通或 200K+ 高档价格) // Claude 模型在 200K+ 场景下如果缺少官方字段,按 2 倍输入价兜底 - let actualInputPrice = useLongContextPricing + const actualInputPrice = useLongContextPricing ? hasInput200kPrice ? pricing.input_cost_per_token_above_200k_tokens : isClaudeModel @@ -712,7 +712,7 @@ class PricingService { const hasOutput200kPrice = pricing.output_cost_per_token_above_200k_tokens !== null && pricing.output_cost_per_token_above_200k_tokens !== undefined - let actualOutputPrice = useLongContextPricing + const actualOutputPrice = useLongContextPricing ? hasOutput200kPrice ? pricing.output_cost_per_token_above_200k_tokens : baseOutputPrice