fix: 根据OpenAI最新的计费规则,更新其Web Search Tools价格

This commit is contained in:
ZhangYichi
2025-07-20 18:25:43 +08:00
parent f87054895e
commit 7d50e432b5

View File

@@ -4,12 +4,12 @@ import "strings"
const ( const (
// Web search // Web search
WebSearchHighTierModelPriceLow = 30.00 WebSearchHighTierModelPriceLow = 10.00
WebSearchHighTierModelPriceMedium = 35.00 WebSearchHighTierModelPriceMedium = 10.00
WebSearchHighTierModelPriceHigh = 50.00 WebSearchHighTierModelPriceHigh = 10.00
WebSearchPriceLow = 25.00 WebSearchPriceLow = 25.00
WebSearchPriceMedium = 27.50 WebSearchPriceMedium = 25.00
WebSearchPriceHigh = 30.00 WebSearchPriceHigh = 25.00
// File search // File search
FileSearchPrice = 2.5 FileSearchPrice = 2.5
) )
@@ -35,9 +35,12 @@ func GetClaudeWebSearchPricePerThousand() float64 {
func GetWebSearchPricePerThousand(modelName string, contextSize string) float64 { func GetWebSearchPricePerThousand(modelName string, contextSize string) float64 {
// 确定模型类型 // 确定模型类型
// https://platform.openai.com/docs/pricing Web search 价格按模型类型和 search context size 收费 // https://platform.openai.com/docs/pricing Web search 价格按模型类型和 search context size 收费
// gpt-4.1, gpt-4o, or gpt-4o-search-preview 更贵gpt-4.1-mini, gpt-4o-mini, gpt-4o-mini-search-preview 更便宜 // 新版计费规则不再关联 search context size故在const区域将各size的价格设为一致。
isHighTierModel := (strings.HasPrefix(modelName, "gpt-4.1") || strings.HasPrefix(modelName, "gpt-4o")) && // gpt-4o and gpt-4.1 models (including mini models) 等普通模型更贵o3, o4-mini, o3-pro, and deep research models 等高级模型更便宜
!strings.Contains(modelName, "mini") isHighTierModel :=
strings.HasPrefix(modelName, "o3") ||
strings.HasPrefix(modelName, "o4") ||
strings.Contains(modelName, "deep-research")
// 确定 search context size 对应的价格 // 确定 search context size 对应的价格
var priceWebSearchPerThousandCalls float64 var priceWebSearchPerThousandCalls float64
switch contextSize { switch contextSize {