@@ -17,11 +17,30 @@ type modelPricingRule struct {
1717 pricing ModelPricing
1818}
1919
20+ type costBreakdown struct {
21+ InputCost float64
22+ OutputCost float64
23+ CacheReadCost float64
24+ TotalCost float64
25+ InputPricePerMToken float64
26+ OutputPricePerMToken float64
27+ CacheReadPricePerMToken float64
28+ ServiceTierCostMultiplier float64
29+ }
30+
2031var (
2132 defaultModelPricing = & ModelPricing {InputPricePerMToken : 1.0 , OutputPricePerMToken : 2.0 }
2233
2334 modelPricingRules = []modelPricingRule {
2435 // Codex/GPT-5 系列,参考 sub2api 的本地 fallback 定价。
36+ {model : "gpt-5.5" , pricing : ModelPricing {
37+ InputPricePerMToken : 5.0 ,
38+ InputPricePerMTokenPriority : 10.0 ,
39+ OutputPricePerMToken : 30.0 ,
40+ OutputPricePerMTokenPriority : 60.0 ,
41+ CacheReadPricePerMToken : 0.5 ,
42+ CacheReadPricePerMTokenPriority : 1.0 ,
43+ }},
2544 {model : "gpt-5.4-mini" , pricing : ModelPricing {InputPricePerMToken : 0.75 , OutputPricePerMToken : 4.5 , CacheReadPricePerMToken : 0.075 }},
2645 {model : "gpt-5.4-nano" , pricing : ModelPricing {InputPricePerMToken : 0.2 , OutputPricePerMToken : 1.25 , CacheReadPricePerMToken : 0.02 }},
2746 {model : "gpt-5.4" , pricing : ModelPricing {
@@ -91,6 +110,10 @@ func getModelPricing(model string) *ModelPricing {
91110// model: 模型名称
92111// 返回:账号计费金额(美元)
93112func calculateCost (inputTokens , outputTokens , cachedTokens int , model string , serviceTier string ) float64 {
113+ return calculateCostBreakdown (inputTokens , outputTokens , cachedTokens , model , serviceTier ).TotalCost
114+ }
115+
116+ func calculateCostBreakdown (inputTokens , outputTokens , cachedTokens int , model string , serviceTier string ) costBreakdown {
94117 pricing := getModelPricing (model )
95118 inputPrice := pricing .InputPricePerMToken
96119 outputPrice := pricing .OutputPricePerMToken
@@ -126,7 +149,16 @@ func calculateCost(inputTokens, outputTokens, cachedTokens int, model string, se
126149 cacheReadCost := float64 (cachedTokens ) / 1000000.0 * cacheReadPrice
127150 outputCost := float64 (outputTokens ) / 1000000.0 * outputPrice
128151
129- return (inputCost + cacheReadCost + outputCost ) * tierMultiplier
152+ return costBreakdown {
153+ InputCost : inputCost * tierMultiplier ,
154+ OutputCost : outputCost * tierMultiplier ,
155+ CacheReadCost : cacheReadCost * tierMultiplier ,
156+ TotalCost : (inputCost + cacheReadCost + outputCost ) * tierMultiplier ,
157+ InputPricePerMToken : inputPrice * tierMultiplier ,
158+ OutputPricePerMToken : outputPrice * tierMultiplier ,
159+ CacheReadPricePerMToken : cacheReadPrice * tierMultiplier ,
160+ ServiceTierCostMultiplier : tierMultiplier ,
161+ }
130162}
131163
132164func normalizeBillingModelName (model string ) string {
@@ -148,6 +180,8 @@ func normalizeBillingModelName(model string) string {
148180func normalizeCodexBillingModel (model string ) (string , bool ) {
149181 compact := strings .NewReplacer (" " , "-" , "_" , "-" ).Replace (model )
150182 switch {
183+ case strings .Contains (compact , "gpt-5.5" ) || strings .Contains (compact , "gpt5-5" ) || strings .Contains (compact , "gpt5.5" ):
184+ return "gpt-5.5" , true
151185 case strings .Contains (compact , "gpt-5.4-mini" ) || strings .Contains (compact , "gpt5-4-mini" ) || strings .Contains (compact , "gpt5.4-mini" ):
152186 return "gpt-5.4-mini" , true
153187 case strings .Contains (compact , "gpt-5.4-nano" ) || strings .Contains (compact , "gpt5-4-nano" ) || strings .Contains (compact , "gpt5.4-nano" ):
0 commit comments