Open History to see the last commit
1import nativeSdk from '../fixtures/bedrock-converse-native-sdk.json'
2import nativeThinkingGuides from '../fixtures/bedrock-native-thinking-guides.json'
3
4import { afterEach, describe, expect, it } from 'vitest'
5
6import { price } from '@modelschemas/rate-card'
7import type { RateCard } from '@modelschemas/rate-card'
8
9import {
10 BEDROCK_CARDS_URL,
11 bedrockCardPrice,
12 bedrockReasoning,
13 parseBedrockCard,
14} from '../bedrock-cards.ts'
15import {
16 BEDROCK_METERED_URL,
17 BEDROCK_PRICE_LIST_URL,
18 BEDROCK_PRICING_PAGE_URL,
19} from '../bedrock-pricing.ts'
20import { BEDROCK_SDK_MODEL_URL } from '../bedrock-sdk-spec.ts'
21import { sha256Text } from '../types.ts'
22import { provider } from './amazon-bedrock.ts'
23
24const DOCS = 'https://docs.aws.amazon.com/bedrock/latest/userguide/'
25const YES = ``
26const NO = ``
27
28// AWS ends every table line with `| ` — the trailing space is deliberate.
29const INDEX = `# Models at a glance
30| Logo | Provider | Supported models |
31| --- | --- | --- |
32| x | [Anthropic](model-cards-anthropic.md) | [Claude Sonnet 4.5](model-card-anthropic-claude-sonnet-4-5.md) |
33| x | [OpenAI](model-cards-openai.md) | [GPT-6 Sol](model-card-openai-gpt-6-sol.md), [GPT-5.4](model-card-openai-gpt-54.md) |
34`
35
36/** Older layout: two-column modalities, an API table per endpoint. */
37const SONNET = `# Claude Sonnet 4.5
38
39## Model Details
40+ **Model launch date:** Sep 30, 2025
41+ **Model lifecycle:** Legacy
42+ **Context window:** 200K tokens
43+ **Max output tokens:** 64K
44+ **Reasoning:** Supported
45
46| **Input Modalities** | **Output Modalities** |
47| --- | --- |
48| ${YES} Image | ${NO} Image |
49| ${NO} Speech | ${NO} Speech |
50| ${YES} Text | ${YES} Text |
51
52**APIs supported on bedrock-runtime endpoint**
53
54| **Messages** | **Responses** | **Chat Completions** | **Converse** | **Invoke** |
55| --- | --- | --- | --- | --- |
56| ${NO} | ${NO} | ${NO} | ${YES} | ${YES} |
57
58## Pricing
59For pricing, see the [Amazon Bedrock Pricing](https://aws.amazon.com/bedrock/pricing/) page.
60
61## Programmatic Access
62
63| **Endpoint** | **Model ID** | **In-Region endpoint URL** | **Geo inference ID** | **Global inference ID** |
64| --- | --- | --- | --- | --- |
65| bedrock-runtime | anthropic.claude-sonnet-4-5-20250929-v1:0 | N/A | us.anthropic.claude-sonnet-4-5-20250929-v1:0<br />eu.anthropic.claude-sonnet-4-5-20250929-v1:0 | global.anthropic.claude-sonnet-4-5-20250929-v1:0 |
66
67## Regional Availability
68`
69
70const PRICE_HEAD = `| **Inference option** | **Input** | **Input — cache write** | **Input — cache read** | **Output** |
71| --- | --- | --- | --- | --- | `
72
73/** Priced, and the global profile bills less than the in-Region id. */
74const GPT6 = `# GPT-6 Sol
75
76## Model details
77+ **Model launch date:** September 22, 2026
78+ **Model lifecycle:** Active
79+ **Context window:** 1,050,000 tokens
80+ **Max output tokens:** 128,000
81
82| **Input modalities** | **Output modalities** |
83| --- | --- |
84| ${YES} Text | ${YES} Text |
85
86Set \`prompt_cache_options.ttl\` to \`30m\`, the only supported TTL and the default.
87
88## Pricing
89
90All prices are in USD per 1 million tokens for the Standard tier.
91
92### Commercial Regions — short context (272K input tokens or fewer)
93
94${PRICE_HEAD}
95| Mantle in-Region | $2.20 | $2.75 | $0.22 | $11.00 |
96| Global CRIS | $2.00 | $2.50 | $0.20 | $10.00 |
97
98### Commercial Regions — long context (more than 272K input tokens)
99
100${PRICE_HEAD}
101| Mantle in-Region | $4.40 | $5.50 | $0.44 | $16.50 |
102| Global CRIS | $4.00 | $5.00 | $0.40 | $15.00 |
103
104## Call the model
105
106| **Endpoint** | **Model ID** | **In-Region endpoint URL** | **Geo inference ID** | **Global inference ID** |
107| --- | --- | --- | --- | --- |
108| bedrock-runtime | openai.gpt-6-sol | Not supported | us.openai.gpt-6-sol | global.openai.gpt-6-sol |
109| bedrock-mantle | openai.gpt-6-sol | https://bedrock-mantle.{region}.api.aws/openai/v1 | Not supported | Not supported |
110
111## Service tiers
112`
113
114/** Prices only a cross-Region profile: the base id gets no card. */
115const GPT54 = `# GPT-5.4
116
117## Model details
118+ **Model lifecycle:** Active
119
120| **Input Modalities** | **Output Modalities** | **[APIs supported](apis.html)** | **[Endpoints supported](endpoints.html)** |
121| --- | --- | --- | --- |
122| ${YES} Text | ${YES} Text | ${YES} Converse | ${YES} bedrock-runtime |
123
124## Pricing
125
126| **Inference option** | **Input** | **Output** |
127| --- | --- | --- |
128| Global CRIS | $2.00 | $6.00 |
129
130*All prices are per 1 million tokens.*
131
132## Programmatic Access
133
134| **Endpoint** | **Model ID** | **In-Region endpoint URL** | **Geo inference ID** | **Global inference ID** |
135| --- | --- | --- | --- | --- |
136| bedrock-runtime | openai.gpt-5.4 | N/A | Not supported | global.openai.gpt-5.4 |
137
138## Service Tiers
139`
140
141const SDK_MODEL = {
142 operations: {
143 Converse: {
144 http: { method: 'POST', requestUri: '/model/{modelId}/converse' },
145 input: { shape: 'ConverseRequest' },
146 output: { shape: 'ConverseResponse' },
147 documentation: '<p>Sends messages to the model.</p>',
148 },
149 },
150 shapes: {
151 ConverseRequest: {
152 type: 'structure',
153 required: ['modelId', 'messages'],
154 members: {
155 modelId: { shape: 'ModelId', location: 'uri' },
156 messages: { shape: 'Messages', documentation: '<p>The messages.</p>' },
157 },
158 },
159 ConverseResponse: {
160 type: 'structure',
161 members: { stopReason: { shape: 'StopReason' } },
162 },
163 ModelId: { type: 'string', pattern: '(?<bad' },
164 Messages: { type: 'list', member: { shape: 'ContentBlock' }, min: 1 },
165 ContentBlock: {
166 type: 'structure',
167 union: true,
168 members: { text: { shape: 'Text' }, json: { shape: 'Document' } },
169 },
170 Text: { type: 'string', max: 10 },
171 Document: { type: 'structure', members: {}, document: true },
172 StopReason: { type: 'string', enum: ['end_turn', 'max_tokens'] },
173 Throttled: { type: 'structure', members: {}, exception: true },
174 },
175}
176
177const PRICE_OFFER = {
178 products: {
179 input: {
180 attributes: {
181 usagetype: 'USE1-example.model-mantle-input-tokens-standard',
182 inferenceType: 'Input tokens',
183 service_tier: 'standard',
184 feature: '',
185 model: 'Example Model',
186 },
187 },
188 output: {
189 attributes: {
190 usagetype: 'USE1-example.model-mantle-output-tokens-standard',
191 inferenceType: 'Output tokens',
192 service_tier: 'standard',
193 feature: '',
194 model: 'Example Model',
195 },
196 },
197 },
198 terms: {
199 OnDemand: {
200 input: {
201 t: {
202 priceDimensions: {
203 d: {
204 unit: '1M tokens',
205 beginRange: '0',
206 endRange: 'Inf',
207 pricePerUnit: { USD: '3' },
208 },
209 },
210 },
211 },
212 output: {
213 t: {
214 priceDimensions: {
215 d: {
216 unit: '1M tokens',
217 beginRange: '0',
218 endRange: 'Inf',
219 pricePerUnit: { USD: '9' },
220 },
221 },
222 },
223 },
224 },
225 },
226}
227
228const PRICE_PAGE = `<h2>Geo and In-region Cross-region Inference</h2>
229<table><thead><tr><th>Models</th><th>Price per 1M input tokens</th><th>Price per 1M output tokens</th></tr></thead>
230<tbody><tr><td>Page Only</td><td>$2.00</td><td>$4.00</td></tr></tbody></table>`
231
232const PAGES: Record<string, string> = {
233 ...nativeThinkingGuides,
234 [BEDROCK_CARDS_URL]: INDEX,
235 [`${DOCS}model-card-anthropic-claude-sonnet-4-5.md`]: SONNET,
236 [`${DOCS}model-card-openai-gpt-6-sol.md`]: GPT6,
237 [`${DOCS}model-card-openai-gpt-54.md`]: GPT54,
238 [BEDROCK_SDK_MODEL_URL]: JSON.stringify(nativeSdk),
239 [BEDROCK_PRICE_LIST_URL]: JSON.stringify(PRICE_OFFER),
240 [BEDROCK_PRICING_PAGE_URL]: PRICE_PAGE,
241 [BEDROCK_METERED_URL]: JSON.stringify({
242 regions: { 'US East (N. Virginia)': {} },
243 }),
244}
245
246const originalFetch = globalThis.fetch
247let urls: Array<string> = []
248
249function serve(pages: Record<string, string>): void {
250 urls = []
251 globalThis.fetch = ((input: string, init?: RequestInit) => {
252 const url = String(input)
253 urls.push(url)
254 // docs.aws.amazon.com answers 403 without a User-Agent.
255 const agent = new Headers(init?.headers).has('User-Agent')
256 const body = url.startsWith(DOCS) && !agent ? undefined : pages[url]
257 return Promise.resolve(
258 body === undefined
259 ? new Response('missing', { status: 404 })
260 : new Response(body),
261 )
262 }) as typeof fetch
263}
264
265afterEach(() => {
266 globalThis.fetch = originalFetch
267})
268
269it('keeps native reasoning capability ticks while leaving the control unknown', () => {
270 const source = {
271 url: 'https://docs.aws.amazon.com/bedrock/latest/userguide/native-test.md',
272 hash: 'hash',
273 extractedAt: '2026-10-09T00:00:00Z',
274 }
275 const card = SONNET.replace('+ **Reasoning:** Supported', '').concat(
276 `\n${YES} [Reasoning](reasoning.html)\n`,
277 )
278 expect(parseBedrockCard(card, source)?.capabilities).toContain('reasoning')
279 expect(parseBedrockCard(card, source)?.reasoning).toBeNull()
280})
281
282describe('amazon-bedrock', () => {
283 it('lists models from the model cards and nothing else', async () => {
284 serve(PAGES)
285 const { models, skipped } = await provider.listModels({})
286
287 expect(skipped).toBeUndefined()
288 expect(urls.filter((url) => !url.startsWith(DOCS)).sort()).toEqual(
289 [
290 BEDROCK_METERED_URL,
291 BEDROCK_SDK_MODEL_URL,
292 'https://docs.aws.amazon.com/nova/latest/nova2-userguide/using-converse-api.md',
293 BEDROCK_PRICE_LIST_URL,
294 BEDROCK_PRICING_PAGE_URL,
295 ].sort(),
296 )
297 expect(models.map((model) => model.rawId)).toEqual([
298 'anthropic.claude-sonnet-4-5-20250929-v1:0',
299 'openai.gpt-6-sol',
300 'openai.gpt-5.4',
301 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',
302 'eu.anthropic.claude-sonnet-4-5-20250929-v1:0',
303 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
304 'us.openai.gpt-6-sol',
305 'global.openai.gpt-6-sol',
306 'global.openai.gpt-5.4',
307 ])
308 const cardUrl = `${DOCS}model-card-anthropic-claude-sonnet-4-5.md`
309 const source = {
310 derivation: 'docs-derived' as const,
311 sourceUrl: cardUrl,
312 sourceHash: await sha256Text(SONNET),
313 }
314 expect(models[0]).toEqual({
315 rawId: 'anthropic.claude-sonnet-4-5-20250929-v1:0',
316 displayName: 'Claude Sonnet 4.5',
317 activity: 'chat',
318 contextWindow: 200_000,
319 maxOutput: 64_000,
320 modalities: { input: ['image', 'text'], output: ['text'] },
321 // The card names no dollar amount, and the fixtures do not price it.
322 pricing: null,
323 capabilities: ['reasoning'],
324 reasoning: { mode: 'budget', mandatory: null },
325 // Converse roles are user, assistant, system. No reasoning_effort.
326 requestMap: {
327 thinking: null,
328 maxTokensField: null,
329 developerRole: false,
330 replayReasoningContent: null,
331 store: null,
332 strictTools: null,
333 sessionAffinity: null,
334 cacheControl: null,
335 toolStream: null,
336 reasoningEffort: false,
337 },
338 schemaEndpointId: 'model/{modelId}/converse',
339 aliases: [],
340 deprecated: true,
341 releasedAt: Date.UTC(2025, 8, 30) / 1000,
342 factSources: {
343 schemaEndpointId: {
344 derivation: 'docs-derived',
345 sourceUrl: cardUrl,
346 sourceHash: await sha256Text(SONNET),
347 path: 'Programmatic Access: bedrock-runtime model ID; APIs supported: Converse',
348 },
349 requestMap: {
350 derivation: 'generated',
351 sourceUrl: BEDROCK_SDK_MODEL_URL,
352 sourceHash: await sha256Text(JSON.stringify(nativeSdk)),
353 path: '#/operations/Converse/input',
354 },
355 reasoning: {
356 derivation: 'docs-derived',
357 sourceUrl: `${DOCS}claude-messages-extended-thinking.md`,
358 sourceHash: await sha256Text(
359 nativeThinkingGuides[
360 `${DOCS}claude-messages-extended-thinking.md` as keyof typeof nativeThinkingGuides
361 ],
362 ),
363 path: 'reasoning',
364 },
365 contextWindow: { ...source, path: 'contextWindow' },
366 maxOutput: { ...source, path: 'maxOutput' },
367 modalities: { ...source, path: 'modalities' },
368 capabilities: {
369 reasoning: { ...source, path: 'capabilities.reasoning' },
370 },
371 },
372 })
373 })
374
375 it('prices the base id at the in-Region rate with the long-context tier', async () => {
376 serve(PAGES)
377 const { models } = await provider.listModels({})
378 const sol = models[1]
379 const card = sol?.pricing as RateCard
380
381 expect(
382 price(card, {}, { input_tokens: 1e5, output_tokens: 1e6 }),
383 ).toBeCloseTo(0.1 * 2.2 + 11)
384 expect(
385 price(card, {}, { input_tokens: 3e5, output_tokens: 1e6 }),
386 ).toBeCloseTo(0.3 * 4.4 + 16.5)
387 // The column says "cache write". The card's only TTL is 30m, so the
388 // 5-minute lever stays empty. Cache read stays.
389 expect(card.inputs.cache_write_tokens).toBeUndefined()
390 expect(card.inputs.cache_write_1h_tokens).toBeUndefined()
391 expect(card.inputs.cache_read_tokens).toBeDefined()
392 // The global profile bills less, so it must not resolve to this card.
393 expect(sol?.aliases).toEqual([])
394 expect(sol?.releasedAt).toBe(Date.UTC(2026, 8, 22) / 1000)
395 // Only a cross-Region profile is priced: no card for the base id.
396 expect(models[2]?.pricing).toBeNull()
397 expect(models[2]?.aliases).toEqual([])
398 expect(models[2]?.schemaEndpointId).toBe('model/{modelId}/converse')
399 })
400
401 it('keeps native profiles distinct and prices global from its own card table', async () => {
402 serve(PAGES)
403 const { models } = await provider.listModels({})
404 const global = models.find(
405 (model) => model.rawId === 'global.openai.gpt-6-sol',
406 )
407 const card = global?.pricing as RateCard
408 expect(global?.aliases).toEqual([])
409 expect(
410 price(card, {}, { input_tokens: 100_000, output_tokens: 1_000_000 }),
411 ).toBeCloseTo(10.2)
412 expect(
413 price(card, {}, { input_tokens: 300_000, output_tokens: 1_000_000 }),
414 ).toBeCloseTo(16.2)
415 expect(global?.factSources?.pricing?.sourceUrl).toBe(
416 `${DOCS}model-card-openai-gpt-6-sol.md`,
417 )
418 const eu = models.find(
419 (model) => model.rawId === 'eu.anthropic.claude-sonnet-4-5-20250929-v1:0',
420 )
421 expect(eu).toMatchObject({
422 pricing: null,
423 aliases: [],
424 absent: { pricing: 'cleared' },
425 })
426 expect(eu?.factSources?.pricing).toBeUndefined()
427 const unpricedGlobal = models.find(
428 (model) =>
429 model.rawId === 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
430 )
431 expect(unpricedGlobal).toMatchObject({
432 pricing: null,
433 absent: { pricing: 'cleared' },
434 })
435 expect(unpricedGlobal?.factSources?.pricing).toBeUndefined()
436 expect(
437 models.find((model) => model.rawId === 'global.openai.gpt-5.4')?.pricing,
438 ).not.toBeNull()
439 })
440
441 it('prices a documented global profile from the global page, never the geo row', async () => {
442 serve({
443 ...PAGES,
444 [BEDROCK_PRICING_PAGE_URL]: `<h2>Global Cross-region Inference</h2>
445<table><tr><th>Models</th><th>Price per 1M input tokens</th><th>Price per 1M output tokens</th></tr>
446<tr><td>Claude Sonnet 4.5</td><td>$7</td><td>$21</td></tr></table>
447<h2>Geo and In-region Cross-region Inference</h2>
448<table><tr><th>Models</th><th>Price per 1M input tokens</th><th>Price per 1M output tokens</th></tr>
449<tr><td>Claude Sonnet 4.5</td><td>$9</td><td>$27</td></tr></table>`,
450 })
451 const { models } = await provider.listModels({})
452 const base = models.find(
453 (model) => model.rawId === 'anthropic.claude-sonnet-4-5-20250929-v1:0',
454 )
455 const global = models.find(
456 (model) =>
457 model.rawId === 'global.anthropic.claude-sonnet-4-5-20250929-v1:0',
458 )
459 expect((base?.pricing as RateCard).tables.rate?.base).toMatchObject({
460 input_tokens: 9 / 1e6,
461 })
462 expect((global?.pricing as RateCard).tables.rate?.base).toMatchObject({
463 input_tokens: 7 / 1e6,
464 })
465 expect(global?.factSources?.pricing?.sourceUrl).toBe(
466 BEDROCK_PRICING_PAGE_URL,
467 )
468 })
469
470 it('fails the poll when most cards stop stating a model id', async () => {
471 const blank = '# Card\n'
472 serve({
473 ...PAGES,
474 [`${DOCS}model-card-openai-gpt-6-sol.md`]: blank,
475 [`${DOCS}model-card-openai-gpt-54.md`]: blank,
476 })
477 await expect(provider.listModels({})).rejects.toThrow(
478 '1 of 3 cards state a model id',
479 )
480 })
481
482 it('reads the reasoning control a card names', () => {
483 expect(bedrockReasoning('Supported')).toBeNull()
484 expect(
485 bedrockReasoning('Supported (configurable: none, low, medium, high)'),
486 ).toEqual({
487 mode: 'effort',
488 mandatory: null,
489 efforts: ['none', 'low', 'medium', 'high'],
490 })
491 expect(
492 bedrockReasoning(
493 'Supported (adaptive thinking is always on and cannot be disabled; effort level is configurable)',
494 ),
495 ).toEqual({ mode: 'adaptive', mandatory: true })
496 expect(
497 bedrockReasoning(
498 'Supported (adaptive thinking is always on and cannot be disabled; effort level configurable — low, medium, high, xhigh, max; default: high)',
499 ),
500 ).toEqual({
501 mode: 'adaptive',
502 mandatory: true,
503 efforts: ['low', 'medium', 'high', 'xhigh', 'max'],
504 })
505 })
506
507 it('reads a two-space limit bullet and ignores the GovCloud table', () => {
508 const card = parseBedrockCard(
509 `# GPT
510+ **Context window:** 1M tokens
511+ **Max output tokens:** 131,072
512
513| **Endpoint** | **Model ID** | **In-Region endpoint URL** | **Geo inference ID** | **Global inference ID** |
514| --- | --- | --- | --- | --- |
515| bedrock-runtime | openai.gpt-6.1-sol | https://example | Not supported | Not supported |
516`,
517 { url: 'https://example.test/card', hash: 'h', extractedAt: 't' },
518 )
519 expect(card?.contextWindow).toBe(1_000_000)
520 expect(card?.maxOutput).toBe(131_072)
521 expect(card?.requestMap).toBeNull()
522
523 const priced = `
524## Pricing
525| **Inference option** | **Input** | **Output** | **Cache read** |
526| --- | --- | --- | --- |
527| In-Region | $1.25 | $2.50 | $0.20 |
528
529**AWS GovCloud (US-West)**
530
531| **Inference option** | **Input** | **Output** | **Cache read** |
532| --- | --- | --- | --- |
533| In-Region | $1.50 | $3.00 | $0.24 |
534
535*All prices are per 1 million tokens.*
536`
537 const govPrice = bedrockCardPrice(priced)
538 expect(govPrice?.uniform).toBe(true)
539 expect(govPrice?.base.input_tokens).toBeCloseTo(1.25 / 1e6)
540 expect(govPrice?.base.cache_read_tokens).toBeCloseTo(0.2 / 1e6)
541 })
542
543 it('prices GPT-6 Astra standard in-region and drops 30-minute writes and Ultrafast', () => {
544 // Published rows from model-card-openai-gpt-6-astra.md.
545 const card = bedrockCardPrice(`
546## Pricing
547
548All prices are in USD per 1 million tokens. The following tables list Standard and Ultrafast prices.
549
550### Standard — Commercial Regions, short context (272K input tokens or fewer)
551
552| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
553| --- | --- | --- | --- | --- |
554| In-Region | $11.00 | $13.75 | $1.10 | $55.00 |
555| Geo CRIS | $11.00 | $13.75 | $1.10 | $55.00 |
556| Global CRIS | $10.00 | $12.50 | $1.00 | $50.00 |
557
558### Standard — Commercial Regions, long context (more than 272K input tokens)
559
560| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
561| --- | --- | --- | --- | --- |
562| In-Region | $22.00 | $27.50 | $2.20 | $82.50 |
563| Geo CRIS | $22.00 | $27.50 | $2.20 | $82.50 |
564| Global CRIS | $20.00 | $25.00 | $2.00 | $75.00 |
565
566### Ultrafast — Commercial Regions, short context (272K input tokens or fewer)
567
568| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
569| --- | --- | --- | --- | --- |
570| In-Region (us-east-1) | $66.00 | $82.50 | $6.60 | $330.00 |
571| Global CRIS | $60.00 | $75.00 | $6.00 | $300.00 |
572
573### Ultrafast — Commercial Regions, long context (more than 272K input tokens)
574
575| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
576| --- | --- | --- | --- | --- |
577| In-Region (us-east-1) | $132.00 | $165.00 | $13.20 | $495.00 |
578| Global CRIS | $120.00 | $150.00 | $12.00 | $450.00 |
579`)
580 expect(card?.base).toEqual({
581 input_tokens: 11 / 1e6,
582 output_tokens: 55 / 1e6,
583 cache_read_tokens: 1.1 / 1e6,
584 })
585 expect(card?.tiers).toEqual([
586 {
587 minPromptTokens: 272_000,
588 rates: {
589 input_tokens: 22 / 1e6,
590 output_tokens: 82.5 / 1e6,
591 cache_read_tokens: 2.2 / 1e6,
592 },
593 },
594 ])
595 })
596
597 it('leaves a 30-minute cache-write column empty', () => {
598 // Published rows from model-card-openai-gpt-56-sol.md. The write is
599 // $5.50 on the $4.40 tier and $11.00 on the long tier.
600 const card = bedrockCardPrice(`
601## Pricing
602
603All prices are in USD per 1 million tokens for the Standard tier.
604
605### Commercial Regions — short context (272K input tokens or fewer)
606
607| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
608| --- | --- | --- | --- | --- |
609| In-Region | $4.40 | $5.50 | $0.44 | $22.00 |
610| Global CRIS | $4.00 | $5.00 | $0.40 | $20.00 |
611
612### Commercial Regions — long context (more than 272K input tokens)
613
614| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
615| --- | --- | --- | --- | --- |
616| In-Region | $8.80 | $11.00 | $0.88 | $33.00 |
617| Global CRIS | $8.00 | $10.00 | $0.80 | $30.00 |
618
619### AWS GovCloud (US-East and US-West)
620
621#### Long context (more than 272K input tokens)
622
623| **Inference option** | **Input** | **Input — 30m cache write** | **Input — cache read** | **Output** |
624| --- | --- | --- | --- | --- |
625| In-Region | $5.40 | $6.75 | $0.54 | $24.30 |
626`)
627 expect(card?.base).toEqual({
628 input_tokens: 4.4 / 1e6,
629 output_tokens: 22 / 1e6,
630 cache_read_tokens: 0.44 / 1e6,
631 })
632 expect(card?.tiers).toEqual([
633 {
634 minPromptTokens: 272_000,
635 rates: {
636 input_tokens: 8.8 / 1e6,
637 output_tokens: 33 / 1e6,
638 cache_read_tokens: 0.88 / 1e6,
639 },
640 },
641 ])
642 })
643
644 it('maps a 5-minute write, a 1-hour write, and a bare write with no TTL', () => {
645 const named = bedrockCardPrice(`
646## Pricing
647
648All prices are in USD per 1 million tokens.
649
650| **Inference option** | **Input** | **Input — 5m cache write** | **Input — 1h cache write** | **Input — cache read** | **Output** |
651| --- | --- | --- | --- | --- | --- |
652| In-Region | $1.00 | $1.25 | $2.00 | $0.10 | $5.00 |
653`)
654 expect(named?.base).toEqual({
655 input_tokens: 1 / 1e6,
656 cache_write_tokens: 1.25 / 1e6,
657 cache_write_1h_tokens: 2 / 1e6,
658 cache_read_tokens: 0.1 / 1e6,
659 output_tokens: 5 / 1e6,
660 })
661
662 const bare = bedrockCardPrice(`
663## Pricing
664
665All prices are in USD per 1 million tokens.
666
667| **Inference option** | **Input** | **Input — cache write** | **Output** |
668| --- | --- | --- | --- |
669| In-Region | $2.00 | $2.50 | $6.00 |
670`)
671 expect(bare?.base.cache_write_tokens).toBeCloseTo(2.5 / 1e6)
672 })
673
674 it('reads named reasoning levels from the effort section', () => {
675 const card = parseBedrockCard(
676 `# Model
677
678**Reasoning effort**
679
680Set reasoning effort to \`none\`, \`low\`, \`medium\`, \`high\`, \`xhigh\`, or \`max\`.
681
682| **Endpoint** | **Model ID** | **In-Region endpoint URL** | **Geo inference ID** | **Global inference ID** |
683| --- | --- | --- | --- | --- |
684| bedrock-runtime | openai.gpt-6-sol | https://example | Not supported | Not supported |
685`,
686 { url: 'https://example.test/card', hash: 'h', extractedAt: 't' },
687 )
688 expect(card?.reasoning).toEqual({
689 mode: 'effort',
690 mandatory: null,
691 efforts: ['none', 'low', 'medium', 'high', 'xhigh', 'max'],
692 })
693 expect(card?.capabilities).toEqual(['reasoning'])
694 })
695
696 it('generates the Converse schema from the SDK service model', async () => {
697 serve({ ...PAGES, [BEDROCK_SDK_MODEL_URL]: JSON.stringify(SDK_MODEL) })
698 const spec = await provider.fetchSpec({})
699 const doc = spec.specs[0]
700
701 expect(urls).toEqual([BEDROCK_SDK_MODEL_URL])
702 expect(spec.skipped).toBeUndefined()
703 expect(Object.keys(doc?.paths ?? {})).toEqual(['/model/{modelId}/converse'])
704 expect(provider.classify('/model/{modelId}/converse', {})).toBe('chat')
705 expect(doc?.components?.schemas).toEqual({
706 // modelId rides the path; the body schema leaves it out.
707 ConverseRequest: {
708 type: 'object',
709 properties: {
710 messages: {
711 $ref: '#/components/schemas/Messages',
712 description: 'The messages.',
713 },
714 },
715 required: ['messages'],
716 },
717 ConverseResponse: {
718 type: 'object',
719 properties: { stopReason: { $ref: '#/components/schemas/StopReason' } },
720 },
721 ModelId: { type: 'string' },
722 Messages: {
723 type: 'array',
724 items: { $ref: '#/components/schemas/ContentBlock' },
725 minItems: 1,
726 },
727 ContentBlock: {
728 type: 'object',
729 properties: {
730 text: { $ref: '#/components/schemas/Text' },
731 json: { $ref: '#/components/schemas/Document' },
732 },
733 minProperties: 1,
734 maxProperties: 1,
735 },
736 Text: { type: 'string', maxLength: 10 },
737 Document: {},
738 StopReason: { type: 'string', enum: ['end_turn', 'max_tokens'] },
739 })
740 })
741})
742
743// A published current quote is not source silence when its markup is unreadable.
744describe('Bedrock malformed current quotes', () => {
745 it('rejects an unreadable Global long-context tier without a flat substitute', () => {
746 const malformed = GPT6.replace(
747 '| Global CRIS | $4.00 | $5.00 | $0.40 | $15.00 |',
748 '| Global CRIS | unreadable | unreadable | unreadable | unreadable |',
749 )
750 expect(() => bedrockCardPrice(malformed, 'global')).toThrow(
751 'amazon-bedrock model card pricing: unreadable long-context tier',
752 )
753 })
754 it('rejects a malformed Global card quote rather than inheriting in-Region', () => {
755 expect(() =>
756 bedrockCardPrice(GPT54.replace('$2.00', '$unreadable'), 'global'),
757 ).toThrow('amazon-bedrock model card pricing: unreadable quote')
758 })
759})