fix: correct account stats pricing priority order

Priority was wrong:
- Before: custom rules → LiteLLM (when ApplyPricingToAccountStats) → nil
- After:  custom rules → totalCost (when ApplyPricingToAccountStats) → LiteLLM → nil

When ApplyPricingToAccountStats is enabled, use the request's actual
client billing cost (before multiplier) as account_stats_cost, instead
of recalculating from LiteLLM per-token prices which produced incorrect
values for per-request billing mode.

LiteLLM model pricing is now the final fallback (priority 3), used only
when neither custom rules nor ApplyPricingToAccountStats apply.
This commit is contained in:
erio
2026-04-13 16:45:10 +08:00
parent 42f8ef3315
commit 98c9d51791
4 changed files with 19 additions and 6 deletions

View File

@@ -7598,6 +7598,7 @@ func (s *GatewayService) recordUsageCore(ctx context.Context, input *recordUsage
ImageOutputTokens: result.Usage.ImageOutputTokens,
},
1, // requestCount
cost.TotalCost,
)
}