Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1cf5d77
authored
Jul 16, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: usage cost(any) to support claude and gemini
parent
31adc393
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
dto/openai_response.go
+1
-1
service/quota.go
+1
-1
No files found.
dto/openai_response.go
View file @
b1cf5d77
...
@@ -182,7 +182,7 @@ type Usage struct {
...
@@ -182,7 +182,7 @@ type Usage struct {
OutputTokens
int
`json:"output_tokens"`
OutputTokens
int
`json:"output_tokens"`
InputTokensDetails
*
InputTokenDetails
`json:"input_tokens_details"`
InputTokensDetails
*
InputTokenDetails
`json:"input_tokens_details"`
// OpenRouter Params
// OpenRouter Params
Cost
float64
`json:"cost,omitempty"`
Cost
any
`json:"cost,omitempty"`
}
}
type
InputTokenDetails
struct
{
type
InputTokenDetails
struct
{
...
...
service/quota.go
View file @
b1cf5d77
...
@@ -326,7 +326,7 @@ func CalcOpenRouterCacheCreateTokens(usage dto.Usage, priceData helper.PriceData
...
@@ -326,7 +326,7 @@ func CalcOpenRouterCacheCreateTokens(usage dto.Usage, priceData helper.PriceData
promptCacheReadPrice
:=
quotaPrice
*
priceData
.
CacheRatio
promptCacheReadPrice
:=
quotaPrice
*
priceData
.
CacheRatio
completionPrice
:=
quotaPrice
*
priceData
.
CompletionRatio
completionPrice
:=
quotaPrice
*
priceData
.
CompletionRatio
cost
:=
usage
.
Cost
cost
,
_
:=
usage
.
Cost
.
(
float64
)
totalPromptTokens
:=
float64
(
usage
.
PromptTokens
)
totalPromptTokens
:=
float64
(
usage
.
PromptTokens
)
completionTokens
:=
float64
(
usage
.
CompletionTokens
)
completionTokens
:=
float64
(
usage
.
CompletionTokens
)
promptCacheReadTokens
:=
float64
(
usage
.
PromptTokensDetails
.
CachedTokens
)
promptCacheReadTokens
:=
float64
(
usage
.
PromptTokensDetails
.
CachedTokens
)
...
...
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