diff --git a/src/server/providers/adapters/amazon-bedrock.test.ts b/src/server/providers/adapters/amazon-bedrock.test.ts index f976e735..136601f0 100644 --- a/src/server/providers/adapters/amazon-bedrock.test.ts +++ b/src/server/providers/adapters/amazon-bedrock.test.ts @@ -563,6 +563,71 @@ describe('amazon-bedrock', () => { ) }) + it('clears an Anthropic chat model the pricing page no longer names', async () => { + const dropped = (title: string, rawId: string) => + SONNET.replace('# Claude Sonnet 4.5', `# ${title}`).replaceAll( + 'anthropic.claude-sonnet-4-5-20250929-v1:0', + rawId, + ) + serve({ + ...PAGES, + [BEDROCK_CARDS_URL]: `# Models at a glance +| Logo | Provider | Supported models | +| --- | --- | --- | +| x | [Anthropic](model-cards-anthropic.md) | [Claude Haiku 4.5](model-card-anthropic-claude-haiku-4-5.md), [Claude Sonnet 4.5](model-card-anthropic-claude-sonnet-4-5.md), [Claude Sonnet 4](model-card-anthropic-claude-sonnet-4.md), [Claude 3 Haiku](model-card-anthropic-claude-3-haiku.md) | +`, + [`${DOCS}model-card-anthropic-claude-haiku-4-5.md`]: dropped( + 'Claude Haiku 4.5', + 'anthropic.claude-haiku-4-5-20251001-v1:0', + ), + [`${DOCS}model-card-anthropic-claude-sonnet-4-5.md`]: dropped( + 'Claude Sonnet 4.5', + 'anthropic.claude-sonnet-4-5-20250929-v1:0', + ), + [`${DOCS}model-card-anthropic-claude-sonnet-4.md`]: dropped( + 'Claude Sonnet 4', + 'anthropic.claude-sonnet-4-20250514-v1:0', + ), + [`${DOCS}model-card-anthropic-claude-3-haiku.md`]: dropped( + 'Claude 3 Haiku', + 'anthropic.claude-3-haiku-20240307-v1:0', + ), + [BEDROCK_PRICING_PAGE_URL]: `

Pricing examples

+

Model evaluation example 1:

+ +
ItemPrice per 1M input tokensPrice per 1M output tokens
Claude 3 Haiku$0.25$1.25
+

Anthropic

+ + + +
Anthropic modelsPrice per 1M input tokensPrice per 1M output tokens
Claude Haiku 4.5$1.00$5.00
Claude Sonnet 4.5{priceOf!bedrock/bedrock!missing}{priceOf!bedrock/bedrock!missing}
`, + }) + const { models } = await provider.listModels({}) + const row = (rawId: string) => models.find((model) => model.rawId === rawId) + const haiku = row('anthropic.claude-haiku-4-5-20251001-v1:0') + expect( + price( + haiku?.pricing as RateCard, + {}, + { input_tokens: 1e6, output_tokens: 1e6 }, + ), + ).toBeCloseTo(6) + expect(haiku?.absent?.pricing).toBeUndefined() + // Still named in the table; the meter did not resolve. Keep a stored card. + const stillNamed = row('anthropic.claude-sonnet-4-5-20250929-v1:0') + expect(stillNamed?.pricing).toBeNull() + expect(stillNamed?.absent?.pricing).toBeUndefined() + for (const rawId of [ + 'anthropic.claude-sonnet-4-20250514-v1:0', + 'anthropic.claude-3-haiku-20240307-v1:0', + ]) { + expect(row(rawId)).toMatchObject({ + pricing: null, + absent: { pricing: 'cleared' }, + }) + } + }) + it('fails the poll when most cards stop stating a model id', async () => { const blank = '# Card\n' serve({ diff --git a/src/server/providers/bedrock-cards.ts b/src/server/providers/bedrock-cards.ts index 1738d603..1962752a 100644 --- a/src/server/providers/bedrock-cards.ts +++ b/src/server/providers/bedrock-cards.ts @@ -4,8 +4,11 @@ * inference-profile ids, limits, modalities, lifecycle, and reasoning. A few * cards (OpenAI, xAI, Moonshot) also state token prices. A card with no * dollars is filled from the AWS price list, then the pricing page - * (`bedrock-pricing.ts`). Every card is fetched as the `.md` twin AWS - * publishes next to the HTML. + * (`bedrock-pricing.ts`). An Anthropic chat model the page's Claude + * tables do not name is cleared: the row was removed, and a stored + * card must not be kept. A name the table still lists, with a meter + * that does not resolve, stays a parser miss. Every card is fetched + * as the `.md` twin AWS publishes next to the HTML. */ import { compileTokenCard } from '@modelschemas/rate-card' import type { TokenRateTier } from '@modelschemas/rate-card' @@ -641,7 +644,26 @@ export async function bedrockCardListing( model.rawId, model.displayName ?? null, ) - if (!hit) continue + if (!hit) { + // The Claude tables parsed, and this name is not in them. EOL + // rows (Claude Sonnet 4, Claude 3 Haiku) left the page; the + // us-east-1 offer has no complete rate either (#775). + const mentioned = book.pageMentioned + const name = bedrockNameKey(model.displayName ?? '') + const claudeTablesRead = [...(mentioned ?? [])].some((key) => + key.startsWith('claude '), + ) + if ( + model.activity === 'chat' && + model.rawId.startsWith('anthropic.') && + name.startsWith('claude ') && + claudeTablesRead && + mentioned?.has(name) === false + ) { + model.absent = { ...model.absent, pricing: 'cleared' } + } + continue + } const pricing = compileTokenCard(hit.rates, [], { url: hit.url, hash: hit.hash, diff --git a/src/server/providers/bedrock-pricing.test.ts b/src/server/providers/bedrock-pricing.test.ts index cbb4075a..c60c8b24 100644 --- a/src/server/providers/bedrock-pricing.test.ts +++ b/src/server/providers/bedrock-pricing.test.ts @@ -621,3 +621,30 @@ it('resolves Global prices from provider-published encoded public meter paths', ), ).toEqual({ input_tokens: 7 / 1e6, output_tokens: 19 / 1e6 }) }) + +it('remembers a Claude row whose meter does not resolve, and ignores example prose', () => { + const html = `

Pricing examples

+

Model evaluation example 1:

+ +
ItemPrice per 1M input tokensPrice per 1M output tokens
Claude 3 Haiku$0.25$1.25
+

Anthropic

+ + + +
Anthropic modelsPrice per 1M input tokensPrice per 1M output tokens
Claude Haiku 4.5$1$5
Claude Sonnet 4.5{priceOf!bedrock/bedrock!missing}{priceOf!bedrock/bedrock!missing}
` + const mentioned = new Set() + const page = parseBedrockPricingPage( + html, + { regions: { 'US East (N. Virginia)': {} } }, + 'regional', + mentioned, + ) + expect(page.get(bedrockNameKey('Claude Haiku 4.5'))).toEqual({ + input_tokens: 1 / 1e6, + output_tokens: 5 / 1e6, + }) + expect(page.has(bedrockNameKey('Claude Sonnet 4.5'))).toBe(false) + expect(mentioned.has(bedrockNameKey('Claude Sonnet 4.5'))).toBe(true) + expect(mentioned.has(bedrockNameKey('Claude 3 Haiku'))).toBe(false) + expect(mentioned.has(bedrockNameKey('Claude Sonnet 4'))).toBe(false) +}) diff --git a/src/server/providers/bedrock-pricing.ts b/src/server/providers/bedrock-pricing.ts index a87a3738..4a71fd81 100644 --- a/src/server/providers/bedrock-pricing.ts +++ b/src/server/providers/bedrock-pricing.ts @@ -61,6 +61,11 @@ export interface BedrockPriceBook { pageByName: Map> /** Only prices explicitly published for global cross-region inference. */ globalPageByName?: Map> + /** + * Model names in a standard token table, including a row whose meter + * did not resolve. A name that is absent was removed, not misread. + */ + pageMentioned?: Set offerHash: string pageHash: string } @@ -370,6 +375,7 @@ export function parseBedrockPricingPage( html: string, meter: MeterFile, scope: 'regional' | 'global' = 'regional', + mentioned?: Set, ): Map> { const region = meter.regions?.[USE1] if (!region) { @@ -440,6 +446,8 @@ export function parseBedrockPricingPage( } // A tab names the model. Rows are tiers. US CRIS is the standard rate. if (head.some((cell) => /inference option/i.test(cell))) { + const labelKey = bedrockNameKey(pendingLabel) + if (labelKey) mentioned?.add(labelKey) const chosen = rows.slice(1).find((row) => { const tier = row[0] ?? '' return scope === 'global' @@ -465,6 +473,7 @@ export function parseBedrockPricingPage( if (!name || /long context/i.test(name)) continue const rates = ratesOf(row) const key = bedrockNameKey(name) + if (key) mentioned?.add(key) if (scope === 'global' && !complete(rates)) { throw new Error( `amazon-bedrock global pricing: unreadable quote ${key}`, @@ -568,14 +577,21 @@ export async function fetchBedrockPriceBook(): Promise { ]) const offer = parseBedrockOffer(JSON.parse(offerText) as OfferFile) const meter = JSON.parse(meterText) as MeterFile - const page = parseBedrockPricingPage(html, meter) - const globalPage = parseBedrockPricingPage(html, meter, 'global') + const pageMentioned = new Set() + const page = parseBedrockPricingPage(html, meter, 'regional', pageMentioned) + const globalPage = parseBedrockPricingPage( + html, + meter, + 'global', + pageMentioned, + ) return { offerById: offer.byId, offerByName: offer.byName, offerBySlug: offer.bySlug, pageByName: page, globalPageByName: globalPage, + pageMentioned, offerHash: await sha256Text(offerText), pageHash: await sha256Text(`${html}\n${meterText}`), }