2025-05-06 23:25:16 +08:00
|
|
|
|
package operation_setting
|
|
|
|
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
2025-05-06 23:57:22 +08:00
|
|
|
|
// Web search
|
2025-07-20 18:25:43 +08:00
|
|
|
|
WebSearchHighTierModelPriceLow = 10.00
|
|
|
|
|
|
WebSearchHighTierModelPriceMedium = 10.00
|
|
|
|
|
|
WebSearchHighTierModelPriceHigh = 10.00
|
2025-05-06 23:25:16 +08:00
|
|
|
|
WebSearchPriceLow = 25.00
|
2025-07-20 18:25:43 +08:00
|
|
|
|
WebSearchPriceMedium = 25.00
|
|
|
|
|
|
WebSearchPriceHigh = 25.00
|
2025-05-06 23:57:22 +08:00
|
|
|
|
// File search
|
|
|
|
|
|
FileSearchPrice = 2.5
|
2025-05-06 23:25:16 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-06-07 12:26:23 +08:00
|
|
|
|
const (
|
|
|
|
|
|
// Gemini Audio Input Price
|
|
|
|
|
|
Gemini25FlashPreviewInputAudioPrice = 1.00
|
2025-06-18 03:25:59 +08:00
|
|
|
|
Gemini25FlashProductionInputAudioPrice = 1.00 // for `gemini-2.5-flash`
|
2025-06-18 03:38:58 +08:00
|
|
|
|
Gemini25FlashLitePreviewInputAudioPrice = 0.50
|
2025-06-07 12:26:23 +08:00
|
|
|
|
Gemini25FlashNativeAudioInputAudioPrice = 3.00
|
|
|
|
|
|
Gemini20FlashInputAudioPrice = 0.70
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-07-15 18:57:22 +08:00
|
|
|
|
const (
|
|
|
|
|
|
// Claude Web search
|
|
|
|
|
|
ClaudeWebSearchPrice = 10.00
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func GetClaudeWebSearchPricePerThousand() float64 {
|
|
|
|
|
|
return ClaudeWebSearchPrice
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 23:25:16 +08:00
|
|
|
|
func GetWebSearchPricePerThousand(modelName string, contextSize string) float64 {
|
|
|
|
|
|
// 确定模型类型
|
|
|
|
|
|
// https://platform.openai.com/docs/pricing Web search 价格按模型类型和 search context size 收费
|
2025-07-20 18:25:43 +08:00
|
|
|
|
// 新版计费规则不再关联 search context size,故在const区域将各size的价格设为一致。
|
|
|
|
|
|
// gpt-4o and gpt-4.1 models (including mini models) 等普通模型更贵,o3, o4-mini, o3-pro, and deep research models 等高级模型更便宜
|
|
|
|
|
|
isHighTierModel :=
|
|
|
|
|
|
strings.HasPrefix(modelName, "o3") ||
|
|
|
|
|
|
strings.HasPrefix(modelName, "o4") ||
|
|
|
|
|
|
strings.Contains(modelName, "deep-research")
|
2025-05-06 23:25:16 +08:00
|
|
|
|
// 确定 search context size 对应的价格
|
|
|
|
|
|
var priceWebSearchPerThousandCalls float64
|
|
|
|
|
|
switch contextSize {
|
|
|
|
|
|
case "low":
|
|
|
|
|
|
if isHighTierModel {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceLow
|
|
|
|
|
|
} else {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchPriceLow
|
|
|
|
|
|
}
|
|
|
|
|
|
case "medium":
|
|
|
|
|
|
if isHighTierModel {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceMedium
|
|
|
|
|
|
} else {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchPriceMedium
|
|
|
|
|
|
}
|
|
|
|
|
|
case "high":
|
|
|
|
|
|
if isHighTierModel {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceHigh
|
|
|
|
|
|
} else {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchPriceHigh
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
// search context size 默认为 medium
|
|
|
|
|
|
if isHighTierModel {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceMedium
|
|
|
|
|
|
} else {
|
|
|
|
|
|
priceWebSearchPerThousandCalls = WebSearchPriceMedium
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return priceWebSearchPerThousandCalls
|
|
|
|
|
|
}
|
2025-05-06 23:57:22 +08:00
|
|
|
|
|
|
|
|
|
|
func GetFileSearchPricePerThousand() float64 {
|
|
|
|
|
|
return FileSearchPrice
|
|
|
|
|
|
}
|
2025-06-07 12:26:23 +08:00
|
|
|
|
|
|
|
|
|
|
func GetGeminiInputAudioPricePerMillionTokens(modelName string) float64 {
|
2025-06-18 03:25:59 +08:00
|
|
|
|
if strings.HasPrefix(modelName, "gemini-2.5-flash-preview-native-audio") {
|
2025-06-07 12:26:23 +08:00
|
|
|
|
return Gemini25FlashNativeAudioInputAudioPrice
|
2025-06-18 03:38:58 +08:00
|
|
|
|
} else if strings.HasPrefix(modelName, "gemini-2.5-flash-preview-lite") {
|
|
|
|
|
|
return Gemini25FlashLitePreviewInputAudioPrice
|
2025-06-18 03:25:59 +08:00
|
|
|
|
} else if strings.HasPrefix(modelName, "gemini-2.5-flash-preview") {
|
|
|
|
|
|
return Gemini25FlashPreviewInputAudioPrice
|
|
|
|
|
|
} else if strings.HasPrefix(modelName, "gemini-2.5-flash") {
|
|
|
|
|
|
return Gemini25FlashProductionInputAudioPrice
|
2025-06-07 12:26:23 +08:00
|
|
|
|
} else if strings.HasPrefix(modelName, "gemini-2.0-flash") {
|
|
|
|
|
|
return Gemini20FlashInputAudioPrice
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0
|
|
|
|
|
|
}
|