|
|
@@ -330,6 +330,7 @@ func PostTextConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, us
|
|
|
summary := calculateTextQuotaSummary(ctx, relayInfo, usage)
|
|
|
|
|
|
var tieredResult *billingexpr.TieredResult
|
|
|
+ tieredBillingApplied := false
|
|
|
if originUsage != nil {
|
|
|
var tieredUsedVars map[string]bool
|
|
|
if snap := relayInfo.TieredBillingSnapshot; snap != nil {
|
|
|
@@ -337,6 +338,7 @@ func PostTextConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, us
|
|
|
}
|
|
|
tieredOk, tieredQuota, tieredRes := TryTieredSettle(relayInfo, BuildTieredTokenParams(usage, summary.IsClaudeUsageSemantic, tieredUsedVars))
|
|
|
if tieredOk {
|
|
|
+ tieredBillingApplied = true
|
|
|
tieredResult = tieredRes
|
|
|
summary.Quota = composeTieredTextQuota(relayInfo, summary, tieredQuota, tieredRes)
|
|
|
}
|
|
|
@@ -451,7 +453,7 @@ func PostTextConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, us
|
|
|
// prompt/cache fields here, otherwise old upstream payloads may be double-counted.
|
|
|
other["input_tokens_total"] = usage.InputTokens
|
|
|
}
|
|
|
- if tieredResult != nil {
|
|
|
+ if tieredBillingApplied {
|
|
|
InjectTieredBillingInfo(other, relayInfo, tieredResult)
|
|
|
}
|
|
|
|