feat(openai): 增加 gpt-5.4-mini/nano 模型支持与定价配置

- 接入 gpt-5.4-mini/nano 模型识别与规范化,补充默认模型列表
- 增加 gpt-5.4-mini/nano 输入/缓存命中/输出价格与计费兜底逻辑
- 同步前端模型白名单与 OpenCode 配置
- 补充 service tier(priority/flex) 计费回归测试
This commit is contained in:
Remx
2026-03-19 19:00:22 +08:00
committed by InCerry
parent 4f7629a4cb
commit c810cad7c8
12 changed files with 310 additions and 1 deletions

View File

@@ -98,6 +98,36 @@ func TestGetModelPricing_Gpt54UsesStaticFallbackWhenRemoteMissing(t *testing.T)
require.InDelta(t, 1.5, got.LongContextOutputCostMultiplier, 1e-12)
}
func TestGetModelPricing_Gpt54MiniUsesDedicatedStaticFallbackWhenRemoteMissing(t *testing.T) {
svc := &PricingService{
pricingData: map[string]*LiteLLMModelPricing{
"gpt-5.1-codex": {InputCostPerToken: 1.25e-6},
},
}
got := svc.GetModelPricing("gpt-5.4-mini")
require.NotNil(t, got)
require.InDelta(t, 7.5e-7, got.InputCostPerToken, 1e-12)
require.InDelta(t, 4.5e-6, got.OutputCostPerToken, 1e-12)
require.InDelta(t, 7.5e-8, got.CacheReadInputTokenCost, 1e-12)
require.Zero(t, got.LongContextInputTokenThreshold)
}
func TestGetModelPricing_Gpt54NanoUsesDedicatedStaticFallbackWhenRemoteMissing(t *testing.T) {
svc := &PricingService{
pricingData: map[string]*LiteLLMModelPricing{
"gpt-5.1-codex": {InputCostPerToken: 1.25e-6},
},
}
got := svc.GetModelPricing("gpt-5.4-nano")
require.NotNil(t, got)
require.InDelta(t, 2e-7, got.InputCostPerToken, 1e-12)
require.InDelta(t, 1.25e-6, got.OutputCostPerToken, 1e-12)
require.InDelta(t, 2e-8, got.CacheReadInputTokenCost, 1e-12)
require.Zero(t, got.LongContextInputTokenThreshold)
}
func TestParsePricingData_PreservesPriorityAndServiceTierFields(t *testing.T) {
raw := map[string]any{
"gpt-5.4": map[string]any{