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
0fbc9a44
Commit
0fbc9a44
authored
Mar 30, 2026
by
erio
Browse files
fix(billing): 按次计费回退到默认 PerRequestPrice
ResolvedPricing 新增 DefaultPerRequestPrice,当无层级匹配时使用渠道的默认按次价格
parent
632035aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/billing_service.go
View file @
0fbc9a44
...
...
@@ -542,6 +542,11 @@ func (s *BillingService) calculatePerRequestCost(resolved *ResolvedPricing, inpu
unitPrice
=
input
.
Resolver
.
GetRequestTierPriceByContext
(
resolved
,
totalContext
)
}
// 回退到默认按次价格
if
unitPrice
==
0
{
unitPrice
=
resolved
.
DefaultPerRequestPrice
}
totalCost
:=
unitPrice
*
float64
(
count
)
actualCost
:=
totalCost
*
input
.
RateMultiplier
...
...
backend/internal/service/model_pricing_resolver.go
View file @
0fbc9a44
...
...
@@ -19,6 +19,9 @@ type ResolvedPricing struct {
// 按次/图片模式:分层定价
RequestTiers
[]
PricingInterval
// 按次/图片模式:默认价格(未命中层级时使用)
DefaultPerRequestPrice
float64
// 来源标识
Source
string
// "channel", "litellm", "fallback"
...
...
@@ -136,6 +139,9 @@ func (r *ModelPricingResolver) applyTokenOverrides(chPricing *ChannelModelPricin
// applyRequestTierOverrides 应用按次/图片模式的渠道覆盖
func
(
r
*
ModelPricingResolver
)
applyRequestTierOverrides
(
chPricing
*
ChannelModelPricing
,
resolved
*
ResolvedPricing
)
{
resolved
.
RequestTiers
=
chPricing
.
Intervals
if
chPricing
.
PerRequestPrice
!=
nil
{
resolved
.
DefaultPerRequestPrice
=
*
chPricing
.
PerRequestPrice
}
}
// GetIntervalPricing 根据 context token 数获取区间定价。
...
...
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