feat: update pricing schema for models to ensure more accurate cost tracking (#27184)

This commit is contained in:
Aiden Cline
2026-05-12 20:44:06 -05:00
committed by GitHub
parent d1356f509e
commit c2b1ebd9dc
6 changed files with 114570 additions and 62322 deletions

View File

@@ -418,10 +418,14 @@ export const getUsage = (input: { model: Provider.Model; usage: LanguageModelUsa
},
}
const contextTokens = inputTokens
const costInfo =
input.model.cost?.experimentalOver200K && tokens.input + tokens.cache.read > 200_000
input.model.cost?.tiers
?.filter((item) => item.tier.type === "context" && contextTokens > item.tier.size)
.sort((a, b) => b.tier.size - a.tier.size)[0] ??
(input.model.cost?.experimentalOver200K && contextTokens > 200_000
? input.model.cost.experimentalOver200K
: input.model.cost
: input.model.cost)
return {
cost: safe(
new Decimal(0)