Skip to content

Commit 83fcfc6

Browse files
fix(server): price bare Claude names listed only under Bedrock IDs
LiteLLM lists Claude Mythos 5.2 only under Bedrock IDs (anthropic., global., us./eu., us-gov., bedrock/us-gov-*/anthropic.), so the alias step, which only stripped text before the last slash, never created claude-mythos-5-2 and Usage showed it as Unpriced. Keys without a slash now also alias by dropping Bedrock's anthropic. prefix. Only that base ID qualifies: regional and GovCloud IDs carry markups and keep their own names. The base row ranks as a cloud candidate, so an exact bare row still wins, a first-party row still beats it, and a disagreeing same-priority candidate still leaves the alias unpriced. Fixes #33715 AI-assisted; verified with the tests and tools listed above.
1 parent 55af121 commit 83fcfc6

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/server/src/usage/usagePricing.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ export function parseRateTable(document: unknown): RateTable {
126126

127127
const aliasCandidates = new Map<string, { rate: ModelRate | null; firstParty: boolean }>();
128128
for (const [key, rate] of table) {
129-
const alias = bareModelName(key);
129+
const slash = key.indexOf("/");
130+
const alias = slash === -1 ? bedrockBaseModelName(key) : bareModelName(key);
130131
if (alias.length === 0 || alias === key || table.has(alias)) continue;
131-
const firstParty = FIRST_PARTY_PROVIDERS.has(key.slice(0, key.indexOf("/")));
132+
const firstParty = slash !== -1 && FIRST_PARTY_PROVIDERS.has(key.slice(0, slash));
132133
const held = aliasCandidates.get(alias);
133134
if (held === undefined || (firstParty && !held.firstParty)) {
134135
aliasCandidates.set(alias, { rate, firstParty });
@@ -180,6 +181,11 @@ function bareModelName(key: string): string {
180181
return slash === -1 ? key : key.slice(slash + 1);
181182
}
182183

184+
// Only Bedrock's base ID gives a bare alias; its regional (us., eu.) and GovCloud IDs carry markups.
185+
function bedrockBaseModelName(key: string): string {
186+
return key.startsWith("anthropic.") ? key.slice("anthropic.".length) : key;
187+
}
188+
183189
// Price Claude's bracketed context variants at the base tier, the only name the rate table knows.
184190
function stripVariantSuffix(key: string): string {
185191
const bracket = key.indexOf("[");

0 commit comments

Comments
 (0)