@devries-cameron20 / t3code-1 / commits / 0ca73a19f0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): usage prices Claude Mythos 5.2 from its Bedrock rate (#33721)

Julius Marminge committed Nov 10, 2026 at 02:08 UTC 0ca73a19f06bc82d729f6d1c1c8903aa22d78868
2 files changed +39 -2
apps/server/src/usage/usagePricing.test.ts
+31
@@ -277,6 +277,37 @@ describe("usage pricing", () => {
277 }
278 });
279
280 + it("prices a bare name listed only under Bedrock IDs at the base anthropic rate", () => {
281 + const bedrock = (input: number, output: number, cacheRead: number, cacheCreation: number) => ({
282 + input_cost_per_token: input,
283 + output_cost_per_token: output,
284 + cache_read_input_token_cost: cacheRead,
285 + cache_creation_input_token_cost: cacheCreation,
286 + });
287 + const base = bedrock(8e-6, 4e-5, 2e-7, 1e-5);
288 + const regional = bedrock(8.8e-6, 4.4e-5, 2.2e-7, 1.1e-5);
289 + const govCloud = bedrock(9.6e-6, 4.8e-5, 2.4e-7, 1.2e-5);
290 + const rows = [
291 + ["anthropic.claude-mythos-5-2", base],
292 + ["global.anthropic.claude-mythos-5-2", base],
293 + ["us.anthropic.claude-mythos-5-2", regional],
294 + ["eu.anthropic.claude-mythos-5-2", regional],
295 + ["us-gov.anthropic.claude-mythos-5-2", govCloud],
296 + ["bedrock/us-gov-east-1/anthropic.claude-mythos-5-2", govCloud],
297 + ["bedrock/us-gov-west-1/anthropic.claude-mythos-5-2", govCloud],
298 + ] as const;
299 +
300 + for (const entries of [rows, rows.toReversed()]) {
301 + const table = parseRateTable(Object.fromEntries(entries));
302 + expect(lookupRate(table, "claude-mythos-5-2")).toMatchObject({
303 + inputCostPerToken: 8e-6,
304 + outputCostPerToken: 4e-5,
305 + cacheReadCostPerToken: 2e-7,
306 + cacheCreationCostPerToken: 1e-5,
307 + });
308 + }
309 + });
310 +
311 it("leaves a bare name unpriced when model makers' own entries disagree", () => {
312 const table = parseRateTable({
313 "openai/example-model": rate(1),
apps/server/src/usage/usagePricing.ts
+8 -2
@@ -126,9 +126,10 @@ export function parseRateTable(document: unknown): RateTable {
126
127 const aliasCandidates = new Map<string, { rate: ModelRate | null; firstParty: boolean }>();
128 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);
131 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));
133 const held = aliasCandidates.get(alias);
134 if (held === undefined || (firstParty && !held.firstParty)) {
135 aliasCandidates.set(alias, { rate, firstParty });
@@ -180,6 +181,11 @@ function bareModelName(key: string): string {
181 return slash === -1 ? key : key.slice(slash + 1);
182 }
183
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 +
189 // Price Claude's bracketed context variants at the base tier, the only name the rate table knows.
190 function stripVariantSuffix(key: string): string {
191 const bracket = key.indexOf("[");