mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
test(billing): 图片输出按 output 子集计价
上一条改用统一定价管线后,TestTryModelFilePricing_WithImageOutput 挂在 0.3 vs 0.28:原算式把 ImageOutputTokens 当 OutputTokens 之外的额外量叠加,等于按文本 output 价和图片价各收一次,测试固化了这个重复计费。 ImageOutputTokens 本就是 OutputTokens 的子集(Gemini 取自 candidatesTokensDetails 的 IMAGE 档,OpenAI 取自 output_tokens_details),统一管线先扣除再按图片单价计, 未配图片价时回退到 output 价、总额不变,正是这个语义。期望改为 0.28。 影响:涉及图片输出的模型,账号统计成本会降低"图片 token × 文本 output 单价"。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -594,8 +594,9 @@ func TestTryModelFilePricing_WithImageOutput(t *testing.T) {
|
||||
}
|
||||
result := tryModelFilePricing(bs, "claude-sonnet-4", tokens, "")
|
||||
require.NotNil(t, result)
|
||||
// 100*0.001 + 50*0.002 + 10*0.01 = 0.1 + 0.1 + 0.1 = 0.3
|
||||
require.InDelta(t, 0.3, *result, 1e-12)
|
||||
// ImageOutputTokens 是 OutputTokens 的子集,先扣除再按图片单价计。
|
||||
// 100*0.001 + (50-10)*0.002 + 10*0.01 = 0.1 + 0.08 + 0.1 = 0.28
|
||||
require.InDelta(t, 0.28, *result, 1e-12)
|
||||
}
|
||||
|
||||
func TestTryModelFilePricing_WithCacheTokens(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user