Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
cc7e67b0
Commit
cc7e67b0
authored
Feb 02, 2026
by
Wesley Liddick
Committed by
shaw
Feb 02, 2026
Browse files
Merge pull request #445 from touwaeriol/fix/gemini-cache-token-billing
fix(billing): 修复 Gemini 接口缓存 token 统计
parents
6999a9c0
4bfeeecb
Changes
1
Show whitespace changes
Inline
Side-by-side
backend/internal/service/gemini_messages_compat_service.go
View file @
cc7e67b0
...
@@ -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
,
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment