"backend/internal/pkg/vscode:/vscode.git/clone" did not exist on "77ba9e728d51ed5f8395d8bed3fddf3816660602"
Commit cc7e67b0 authored by Wesley Liddick's avatar Wesley Liddick Committed by shaw
Browse files

Merge pull request #445 from touwaeriol/fix/gemini-cache-token-billing

fix(billing): 修复 Gemini 接口缓存 token 统计
parents 6999a9c0 4bfeeecb
...@@ -2522,9 +2522,13 @@ func extractGeminiUsage(geminiResp map[string]any) *ClaudeUsage { ...@@ -2522,9 +2522,13 @@ func extractGeminiUsage(geminiResp map[string]any) *ClaudeUsage {
} }
prompt, _ := asInt(usageMeta["promptTokenCount"]) prompt, _ := asInt(usageMeta["promptTokenCount"])
cand, _ := asInt(usageMeta["candidatesTokenCount"]) cand, _ := asInt(usageMeta["candidatesTokenCount"])
cached, _ := asInt(usageMeta["cachedContentTokenCount"])
// 注意:Gemini 的 promptTokenCount 包含 cachedContentTokenCount,
// 但 Claude 的 input_tokens 不包含 cache_read_input_tokens,需要减去
return &ClaudeUsage{ return &ClaudeUsage{
InputTokens: prompt, InputTokens: prompt - cached,
OutputTokens: cand, OutputTokens: cand,
CacheReadInputTokens: cached,
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment