mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
feat(billing): add DeepSeek V4 Pro / Flash fallback pricing
Pricing source: https://api-docs.deepseek.com/quick_start/pricing deepseek-v4-pro: input $0.435/M, output $0.87/M, cache_read $0.003625/M deepseek-v4-flash: input $0.14/M, output $0.28/M, cache_read $0.0028/M Also map legacy aliases deepseek-chat / deepseek-reasoner → v4-flash.
This commit is contained in:
@@ -294,6 +294,24 @@ func (s *BillingService) initFallbackPricing() {
|
||||
CacheReadPricePerTokenPriority: 0.35e-6,
|
||||
SupportsCacheBreakdown: false,
|
||||
}
|
||||
// DeepSeek V4 Pro
|
||||
// Source: https://api-docs.deepseek.com/quick_start/pricing
|
||||
s.fallbackPrices["deepseek-v4-pro"] = &ModelPricing{
|
||||
InputPricePerToken: 4.35e-7, // $0.435 per MTok
|
||||
OutputPricePerToken: 8.7e-7, // $0.87 per MTok
|
||||
CacheReadPricePerToken: 3.625e-9, // $0.003625 per MTok
|
||||
SupportsCacheBreakdown: false,
|
||||
}
|
||||
|
||||
// DeepSeek V4 Flash
|
||||
// Source: https://api-docs.deepseek.com/quick_start/pricing
|
||||
s.fallbackPrices["deepseek-v4-flash"] = &ModelPricing{
|
||||
InputPricePerToken: 1.4e-7, // $0.14 per MTok
|
||||
OutputPricePerToken: 2.8e-7, // $0.28 per MTok
|
||||
CacheReadPricePerToken: 2.8e-9, // $0.0028 per MTok
|
||||
SupportsCacheBreakdown: false,
|
||||
}
|
||||
|
||||
// Codex 族兜底统一按 GPT-5.3 Codex 价格计费
|
||||
s.fallbackPrices["gpt-5.3-codex"] = &ModelPricing{
|
||||
InputPricePerToken: 1.5e-6, // $1.5 per MTok
|
||||
@@ -344,6 +362,18 @@ func (s *BillingService) getFallbackPricing(model string) *ModelPricing {
|
||||
return s.fallbackPrices["gemini-3.1-pro"]
|
||||
}
|
||||
|
||||
// DeepSeek V4 系列
|
||||
if strings.Contains(modelLower, "deepseek-v4-flash") {
|
||||
return s.fallbackPrices["deepseek-v4-flash"]
|
||||
}
|
||||
if strings.Contains(modelLower, "deepseek-v4-pro") {
|
||||
return s.fallbackPrices["deepseek-v4-pro"]
|
||||
}
|
||||
// deepseek-chat / deepseek-reasoner → V4 Flash(官方兼容别名)
|
||||
if strings.Contains(modelLower, "deepseek-chat") || strings.Contains(modelLower, "deepseek-reasoner") {
|
||||
return s.fallbackPrices["deepseek-v4-flash"]
|
||||
}
|
||||
|
||||
// OpenAI 仅匹配已知 GPT-5/Codex 族,避免未知 OpenAI 型号误计价。
|
||||
if normalized := normalizeKnownOpenAICodexModel(modelLower); normalized != "" {
|
||||
switch normalized {
|
||||
|
||||
@@ -352,6 +352,10 @@ func TestGetFallbackPricing_FamilyMatching(t *testing.T) {
|
||||
{name: "openai legacy gpt5.1 codex falls back to gpt5.3 codex", model: "gpt-5.1-codex", expectedInput: 1.5e-6},
|
||||
{name: "openai legacy codex mini latest falls back to gpt5.3 codex", model: "codex-mini-latest", expectedInput: 1.5e-6},
|
||||
{name: "openai unknown no fallback", model: "gpt-unknown-model", expectNilPricing: true},
|
||||
{name: "deepseek v4 pro", model: "deepseek-v4-pro", expectedInput: 4.35e-7},
|
||||
{name: "deepseek v4 flash", model: "deepseek-v4-flash", expectedInput: 1.4e-7},
|
||||
{name: "deepseek chat alias → flash", model: "deepseek-chat", expectedInput: 1.4e-7},
|
||||
{name: "deepseek reasoner alias → flash", model: "deepseek-reasoner", expectedInput: 1.4e-7},
|
||||
{name: "non supported family", model: "qwen-max", expectNilPricing: true},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user