openlayer 0.15.2 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/lib/core/cli.d.ts +1 -1
  3. package/lib/core/cli.d.ts.map +1 -1
  4. package/lib/core/cli.js +1 -1
  5. package/lib/core/cli.js.map +1 -1
  6. package/lib/core/cli.mjs +1 -1
  7. package/lib/core/cli.mjs.map +1 -1
  8. package/lib/integrations/bedrockAgentTracer.d.ts +2 -1
  9. package/lib/integrations/bedrockAgentTracer.d.ts.map +1 -1
  10. package/lib/integrations/bedrockAgentTracer.js +694 -3
  11. package/lib/integrations/bedrockAgentTracer.js.map +1 -1
  12. package/lib/integrations/bedrockAgentTracer.mjs +694 -3
  13. package/lib/integrations/bedrockAgentTracer.mjs.map +1 -1
  14. package/lib/integrations/openAiTracer.d.ts.map +1 -1
  15. package/lib/integrations/openAiTracer.js +0 -2
  16. package/lib/integrations/openAiTracer.js.map +1 -1
  17. package/lib/integrations/openAiTracer.mjs +0 -2
  18. package/lib/integrations/openAiTracer.mjs.map +1 -1
  19. package/lib/tracing/steps.d.ts +0 -2
  20. package/lib/tracing/steps.d.ts.map +1 -1
  21. package/lib/tracing/steps.js +0 -2
  22. package/lib/tracing/steps.js.map +1 -1
  23. package/lib/tracing/steps.mjs +0 -2
  24. package/lib/tracing/steps.mjs.map +1 -1
  25. package/lib/tracing/tracer.d.ts +2 -2
  26. package/lib/tracing/tracer.d.ts.map +1 -1
  27. package/lib/tracing/tracer.js +2 -2
  28. package/lib/tracing/tracer.js.map +1 -1
  29. package/lib/tracing/tracer.mjs +2 -2
  30. package/lib/tracing/tracer.mjs.map +1 -1
  31. package/package.json +1 -1
  32. package/src/lib/core/cli.ts +2 -2
  33. package/src/lib/integrations/bedrockAgentTracer.ts +839 -7
  34. package/src/lib/integrations/openAiTracer.ts +0 -2
  35. package/src/lib/tracing/steps.ts +0 -3
  36. package/src/lib/tracing/tracer.ts +3 -3
  37. package/src/version.ts +1 -1
  38. package/version.d.ts +1 -1
  39. package/version.js +1 -1
  40. package/version.mjs +1 -1
@@ -1,11 +1,25 @@
1
1
  import performanceNow from 'performance-now';
2
2
 
3
+ import {
4
+ BedrockAgentRuntimeClient,
5
+ InvokeAgentCommand,
6
+ InvokeAgentCommandInput,
7
+ InvokeAgentCommandOutput,
8
+ ResponseStream,
9
+ } from '@aws-sdk/client-bedrock-agent-runtime';
3
10
  import { addChatCompletionStepToTrace } from '../tracing/tracer';
4
11
 
5
- export function traceBedrockAgent(client: any, openlayerInferencePipelineId?: string): any {
12
+ export function traceBedrockAgent(
13
+ client: BedrockAgentRuntimeClient,
14
+ openlayerInferencePipelineId?: string,
15
+ ): BedrockAgentRuntimeClient {
6
16
  const originalSend = client.send.bind(client);
7
17
 
8
- client.send = async function (this: any, command: any, options?: any): Promise<any> {
18
+ client.send = async function (
19
+ this: any,
20
+ command: InvokeAgentCommand,
21
+ options?: any,
22
+ ): Promise<InvokeAgentCommandOutput & { completion: AsyncIterable<ResponseStream> | undefined }> {
9
23
  // Debug logging to see what we're receiving
10
24
  const hasInput = command?.input;
11
25
  const hasAgentId = typeof command?.input?.agentId === 'string';
@@ -24,7 +38,7 @@ export function traceBedrockAgent(client: any, openlayerInferencePipelineId?: st
24
38
 
25
39
  try {
26
40
  // Call the original send method
27
- const response = await originalSend(command, options);
41
+ const response: InvokeAgentCommandOutput = await originalSend(command, options);
28
42
 
29
43
  if (!response.completion) {
30
44
  throw new Error('Completion is undefined');
@@ -36,6 +50,7 @@ export function traceBedrockAgent(client: any, openlayerInferencePipelineId?: st
36
50
  input,
37
51
  startTime,
38
52
  openlayerInferencePipelineId,
53
+ client.config.region,
39
54
  );
40
55
 
41
56
  // Return the response with the traced completion
@@ -54,11 +69,12 @@ export function traceBedrockAgent(client: any, openlayerInferencePipelineId?: st
54
69
 
55
70
  // Create a traced completion that collects data while yielding original events
56
71
  function createTracedCompletion(
57
- originalCompletion: AsyncIterable<any>,
58
- input: any,
72
+ originalCompletion: AsyncIterable<ResponseStream>,
73
+ input: InvokeAgentCommandInput,
59
74
  startTime: number,
60
75
  openlayerInferencePipelineId?: string,
61
- ): AsyncIterable<any> {
76
+ region?: () => Promise<string>,
77
+ ): AsyncIterable<ResponseStream> {
62
78
  return {
63
79
  async *[Symbol.asyncIterator]() {
64
80
  let firstTokenTime: number | undefined;
@@ -162,6 +178,14 @@ function createTracedCompletion(
162
178
  };
163
179
  }
164
180
 
181
+ // Calculate cost based on tokens, model, and region
182
+ const cost = calculateCost(
183
+ promptTokens,
184
+ completionTokens,
185
+ agentModel,
186
+ typeof region === 'function' ? await region() : region || 'us-east-1',
187
+ );
188
+
165
189
  const traceStepData = {
166
190
  name: 'AWS Bedrock Agent Invocation',
167
191
  inputs: inputs,
@@ -170,9 +194,9 @@ function createTracedCompletion(
170
194
  tokens: totalTokens > 0 ? totalTokens : null,
171
195
  promptTokens: promptTokens > 0 ? promptTokens : null,
172
196
  completionTokens: completionTokens > 0 ? completionTokens : null,
197
+ cost: cost,
173
198
  model: agentModel || `${input.agentId}:${input.agentAliasId}`,
174
199
  modelParameters: extractModelParameters(input),
175
- rawOutput: JSON.stringify(rawOutputChunks, null, 2),
176
200
  metadata: metadata,
177
201
  provider: 'Bedrock',
178
202
  startTime: startTime,
@@ -303,3 +327,811 @@ function extractModelParameters(input: any): Record<string, any> {
303
327
 
304
328
  return params;
305
329
  }
330
+
331
+ // Bedrock pricing per 1K tokens by region and model ID (as of 2024)
332
+ // Source: https://aws.amazon.com/bedrock/pricing/
333
+ const BedrockPricing: { [region: string]: { [modelId: string]: { input: number; output: number } } } = {
334
+ 'us-east-1': {
335
+ // Anthropic models
336
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
337
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
338
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
339
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
340
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
341
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
342
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
343
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
344
+ 'anthropic.claude-sonnet-4': { input: 0.003, output: 0.015 },
345
+ 'anthropic.claude-opus-4': { input: 0.015, output: 0.075 },
346
+ 'anthropic.claude-haiku-4': { input: 0.00025, output: 0.00125 },
347
+
348
+ // Amazon models
349
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
350
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
351
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
352
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
353
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
354
+ 'amazon.nova-pro': { input: 0.003, output: 0.015 },
355
+ 'amazon.nova-express': { input: 0.00025, output: 0.00125 },
356
+
357
+ // AI21 models
358
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
359
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
360
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
361
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
362
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
363
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
364
+
365
+ // Meta models
366
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
367
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
368
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
369
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
370
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
371
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
372
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
373
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
374
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
375
+ 'meta.llama3.1-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
376
+ 'meta.llama3.1-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
377
+ 'meta.llama3.1-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
378
+
379
+ // Cohere models
380
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
381
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
382
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
383
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
384
+ 'cohere.command-r-v1:0': { input: 0.0015, output: 0.002 },
385
+ 'cohere.command-r-plus-v1:0': { input: 0.003, output: 0.015 },
386
+
387
+ // Mistral models
388
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
389
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
390
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
391
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
392
+ 'mistral.mistral-7b-instruct-v0:3': { input: 0.00015, output: 0.0002 },
393
+ 'mistral.mixtral-8x7b-instruct-v0:3': { input: 0.00045, output: 0.0007 },
394
+
395
+ // Stability AI models
396
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
397
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
398
+
399
+ // TwelveLabs models
400
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
401
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
402
+
403
+ // Writer models
404
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
405
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
406
+ },
407
+
408
+ 'us-east-2': {
409
+ // Anthropic models
410
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
411
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
412
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
413
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
414
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
415
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
416
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
417
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
418
+ 'anthropic.claude-sonnet-4': { input: 0.003, output: 0.015 },
419
+ 'anthropic.claude-opus-4': { input: 0.015, output: 0.075 },
420
+ 'anthropic.claude-haiku-4': { input: 0.00025, output: 0.00125 },
421
+
422
+ // Amazon models
423
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
424
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
425
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
426
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
427
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
428
+ 'amazon.nova-pro': { input: 0.003, output: 0.015 },
429
+ 'amazon.nova-express': { input: 0.00025, output: 0.00125 },
430
+
431
+ // AI21 models
432
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
433
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
434
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
435
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
436
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
437
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
438
+
439
+ // Meta models
440
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
441
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
442
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
443
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
444
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
445
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
446
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
447
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
448
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
449
+ 'meta.llama3.1-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
450
+ 'meta.llama3.1-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
451
+ 'meta.llama3.1-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
452
+
453
+ // Cohere models
454
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
455
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
456
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
457
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
458
+ 'cohere.command-r-v1:0': { input: 0.0015, output: 0.002 },
459
+ 'cohere.command-r-plus-v1:0': { input: 0.003, output: 0.015 },
460
+
461
+ // Mistral models
462
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
463
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
464
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
465
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
466
+ 'mistral.mistral-7b-instruct-v0:3': { input: 0.00015, output: 0.0002 },
467
+ 'mistral.mixtral-8x7b-instruct-v0:3': { input: 0.00045, output: 0.0007 },
468
+
469
+ // Stability AI models
470
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
471
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
472
+
473
+ // TwelveLabs models
474
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
475
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
476
+
477
+ // Writer models
478
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
479
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
480
+ },
481
+
482
+ 'us-west-2': {
483
+ // Anthropic models
484
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
485
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
486
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
487
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
488
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
489
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
490
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
491
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
492
+ 'anthropic.claude-sonnet-4': { input: 0.003, output: 0.015 },
493
+ 'anthropic.claude-opus-4': { input: 0.015, output: 0.075 },
494
+ 'anthropic.claude-haiku-4': { input: 0.00025, output: 0.00125 },
495
+
496
+ // Amazon models
497
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
498
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
499
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
500
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
501
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
502
+
503
+ // AI21 models
504
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
505
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
506
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
507
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
508
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
509
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
510
+
511
+ // Meta models
512
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
513
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
514
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
515
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
516
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
517
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
518
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
519
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
520
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
521
+
522
+ // Cohere models
523
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
524
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
525
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
526
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
527
+
528
+ // Mistral models
529
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
530
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
531
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
532
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
533
+
534
+ // Stability AI models
535
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
536
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
537
+
538
+ // TwelveLabs models
539
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
540
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
541
+
542
+ // Writer models
543
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
544
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
545
+ },
546
+
547
+ 'eu-west-1': {
548
+ // Anthropic models
549
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
550
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
551
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
552
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
553
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
554
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
555
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
556
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
557
+
558
+ // Amazon models
559
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
560
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
561
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
562
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
563
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
564
+
565
+ // AI21 models
566
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
567
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
568
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
569
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
570
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
571
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
572
+
573
+ // Meta models
574
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
575
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
576
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
577
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
578
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
579
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
580
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
581
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
582
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
583
+
584
+ // Cohere models
585
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
586
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
587
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
588
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
589
+
590
+ // Mistral models
591
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
592
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
593
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
594
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
595
+
596
+ // Stability AI models
597
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
598
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
599
+
600
+ // TwelveLabs models
601
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
602
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
603
+
604
+ // Writer models
605
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
606
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
607
+ },
608
+
609
+ 'ap-southeast-1': {
610
+ // Anthropic models
611
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
612
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
613
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
614
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
615
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
616
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
617
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
618
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
619
+
620
+ // Amazon models
621
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
622
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
623
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
624
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
625
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
626
+
627
+ // AI21 models
628
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
629
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
630
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
631
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
632
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
633
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
634
+
635
+ // Meta models
636
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
637
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
638
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
639
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
640
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
641
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
642
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
643
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
644
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
645
+
646
+ // Cohere models
647
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
648
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
649
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
650
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
651
+
652
+ // Mistral models
653
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
654
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
655
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
656
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
657
+
658
+ // Stability AI models
659
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
660
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
661
+
662
+ // TwelveLabs models
663
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
664
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
665
+
666
+ // Writer models
667
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
668
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
669
+ },
670
+
671
+ // Additional regions from AWS Bedrock pricing
672
+ 'us-west-1': {
673
+ // Anthropic models
674
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
675
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
676
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
677
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
678
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
679
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
680
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
681
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
682
+
683
+ // Amazon models
684
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
685
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
686
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
687
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
688
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
689
+
690
+ // AI21 models
691
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
692
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
693
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
694
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
695
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
696
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
697
+
698
+ // Meta models
699
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
700
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
701
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
702
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
703
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
704
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
705
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
706
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
707
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
708
+
709
+ // Cohere models
710
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
711
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
712
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
713
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
714
+
715
+ // Mistral models
716
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
717
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
718
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
719
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
720
+
721
+ // Stability AI models
722
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
723
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
724
+
725
+ // TwelveLabs models
726
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
727
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
728
+
729
+ // Writer models
730
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
731
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
732
+ },
733
+
734
+ 'eu-central-1': {
735
+ // Anthropic models
736
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
737
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
738
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
739
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
740
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
741
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
742
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
743
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
744
+
745
+ // Amazon models
746
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
747
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
748
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
749
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
750
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
751
+
752
+ // AI21 models
753
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
754
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
755
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
756
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
757
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
758
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
759
+
760
+ // Meta models
761
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
762
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
763
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
764
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
765
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
766
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
767
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
768
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
769
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
770
+
771
+ // Cohere models
772
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
773
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
774
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
775
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
776
+
777
+ // Mistral models
778
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
779
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
780
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
781
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
782
+
783
+ // Stability AI models
784
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
785
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
786
+
787
+ // TwelveLabs models
788
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
789
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
790
+
791
+ // Writer models
792
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
793
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
794
+ },
795
+
796
+ 'ap-northeast-1': {
797
+ // Anthropic models
798
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
799
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
800
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
801
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
802
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
803
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
804
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
805
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
806
+
807
+ // Amazon models
808
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
809
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
810
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
811
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
812
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
813
+
814
+ // AI21 models
815
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
816
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
817
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
818
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
819
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
820
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
821
+
822
+ // Meta models
823
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
824
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
825
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
826
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
827
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
828
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
829
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
830
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
831
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
832
+
833
+ // Cohere models
834
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
835
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
836
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
837
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
838
+
839
+ // Mistral models
840
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
841
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
842
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
843
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
844
+
845
+ // Stability AI models
846
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
847
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
848
+
849
+ // TwelveLabs models
850
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
851
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
852
+
853
+ // Writer models
854
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
855
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
856
+ },
857
+
858
+ 'ap-south-1': {
859
+ // Anthropic models
860
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
861
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
862
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
863
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
864
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
865
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
866
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
867
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
868
+
869
+ // Amazon models
870
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
871
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
872
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
873
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
874
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
875
+
876
+ // AI21 models
877
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
878
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
879
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
880
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
881
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
882
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
883
+
884
+ // Meta models
885
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
886
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
887
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
888
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
889
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
890
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
891
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
892
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
893
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
894
+
895
+ // Cohere models
896
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
897
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
898
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
899
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
900
+
901
+ // Mistral models
902
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
903
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
904
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
905
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
906
+
907
+ // Stability AI models
908
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
909
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
910
+
911
+ // TwelveLabs models
912
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
913
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
914
+
915
+ // Writer models
916
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
917
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
918
+ },
919
+
920
+ 'ca-central-1': {
921
+ // Anthropic models
922
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
923
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
924
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
925
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
926
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
927
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
928
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
929
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
930
+
931
+ // Amazon models
932
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
933
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
934
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
935
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
936
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
937
+
938
+ // AI21 models
939
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
940
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
941
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
942
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
943
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
944
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
945
+
946
+ // Meta models
947
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
948
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
949
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
950
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
951
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
952
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
953
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
954
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
955
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
956
+
957
+ // Cohere models
958
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
959
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
960
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
961
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
962
+
963
+ // Mistral models
964
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
965
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
966
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
967
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
968
+
969
+ // Stability AI models
970
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
971
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
972
+
973
+ // TwelveLabs models
974
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
975
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
976
+
977
+ // Writer models
978
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
979
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
980
+ },
981
+
982
+ 'sa-east-1': {
983
+ // Anthropic models
984
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
985
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
986
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
987
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
988
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
989
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
990
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
991
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
992
+
993
+ // Amazon models
994
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
995
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
996
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
997
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
998
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
999
+
1000
+ // AI21 models
1001
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
1002
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
1003
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
1004
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
1005
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
1006
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
1007
+
1008
+ // Meta models
1009
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
1010
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
1011
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
1012
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
1013
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
1014
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
1015
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
1016
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
1017
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
1018
+
1019
+ // Cohere models
1020
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
1021
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
1022
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
1023
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
1024
+
1025
+ // Mistral models
1026
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
1027
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
1028
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
1029
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
1030
+
1031
+ // Stability AI models
1032
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
1033
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
1034
+
1035
+ // TwelveLabs models
1036
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
1037
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
1038
+
1039
+ // Writer models
1040
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
1041
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
1042
+ },
1043
+
1044
+ 'ap-northeast-2': {
1045
+ // Anthropic models
1046
+ 'anthropic.claude-3-5-sonnet-20241022-v1:0': { input: 0.003, output: 0.015 },
1047
+ 'anthropic.claude-3-5-haiku-20241022-v1:0': { input: 0.00025, output: 0.00125 },
1048
+ 'anthropic.claude-3-opus-20240229-v1:0': { input: 0.015, output: 0.075 },
1049
+ 'anthropic.claude-3-sonnet-20240229-v1:0': { input: 0.003, output: 0.015 },
1050
+ 'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.00025, output: 0.00125 },
1051
+ 'anthropic.claude-v2:1': { input: 0.008, output: 0.024 },
1052
+ 'anthropic.claude-v2': { input: 0.008, output: 0.024 },
1053
+ 'anthropic.claude-instant-v1': { input: 0.00163, output: 0.00551 },
1054
+ 'anthropic.claude-sonnet-4': { input: 0.003, output: 0.015 },
1055
+ 'anthropic.claude-opus-4': { input: 0.015, output: 0.075 },
1056
+ 'anthropic.claude-haiku-4': { input: 0.00025, output: 0.00125 },
1057
+
1058
+ // Amazon models
1059
+ 'amazon.titan-text-express-v1': { input: 0.0008, output: 0.0016 },
1060
+ 'amazon.titan-text-lite-v1': { input: 0.0003, output: 0.0004 },
1061
+ 'amazon.titan-embed-text-v1': { input: 0.0001, output: 0 },
1062
+ 'amazon.titan-embed-image-v1': { input: 0.0001, output: 0 },
1063
+ 'amazon.titan-image-generator-v1': { input: 0.008, output: 0 },
1064
+
1065
+ // AI21 models
1066
+ 'ai21.j2-ultra-v1': { input: 0.0128, output: 0.0128 },
1067
+ 'ai21.j2-mid-v1': { input: 0.008, output: 0.008 },
1068
+ 'ai21.j2-light-v1': { input: 0.0006, output: 0.0006 },
1069
+ 'ai21.j2-ultra-v1:0': { input: 0.0128, output: 0.0128 },
1070
+ 'ai21.j2-mid-v1:0': { input: 0.008, output: 0.008 },
1071
+ 'ai21.j2-light-v1:0': { input: 0.0006, output: 0.0006 },
1072
+
1073
+ // Meta models
1074
+ 'meta.llama2-13b-chat-v1': { input: 0.00075, output: 0.001 },
1075
+ 'meta.llama2-70b-chat-v1': { input: 0.00195, output: 0.00256 },
1076
+ 'meta.llama2-7b-chat-v1': { input: 0.0006, output: 0.0006 },
1077
+ 'meta.llama2-13b-chat-v1:0': { input: 0.00075, output: 0.001 },
1078
+ 'meta.llama2-70b-chat-v1:0': { input: 0.00195, output: 0.00256 },
1079
+ 'meta.llama2-7b-chat-v1:0': { input: 0.0006, output: 0.0006 },
1080
+ 'meta.llama3-8b-instruct-v1:0': { input: 0.0002, output: 0.0002 },
1081
+ 'meta.llama3-70b-instruct-v1:0': { input: 0.0008, output: 0.0008 },
1082
+ 'meta.llama3-405b-instruct-v1:0': { input: 0.0012, output: 0.0012 },
1083
+
1084
+ // Cohere models
1085
+ 'cohere.command-text-v14': { input: 0.0015, output: 0.002 },
1086
+ 'cohere.command-light-text-v14': { input: 0.0003, output: 0.0006 },
1087
+ 'cohere.embed-english-v3': { input: 0.0001, output: 0 },
1088
+ 'cohere.embed-multilingual-v3': { input: 0.0001, output: 0 },
1089
+
1090
+ // Mistral models
1091
+ 'mistral.mistral-7b-instruct-v0:2': { input: 0.00015, output: 0.0002 },
1092
+ 'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.00045, output: 0.0007 },
1093
+ 'mistral.mistral-large-2402-v1:0': { input: 0.008, output: 0.024 },
1094
+ 'mistral.mistral-small-2402-v1:0': { input: 0.001, output: 0.003 },
1095
+
1096
+ // Stability AI models
1097
+ 'stability.stable-diffusion-xl-v1': { input: 0.036, output: 0 }, // per image
1098
+ 'stability.stable-diffusion-xl-v1:0': { input: 0.036, output: 0 }, // per image
1099
+
1100
+ // TwelveLabs models
1101
+ 'twelvelabs.pegasus-1.2': { input: 0.00049, output: 0.0075 }, // per second + per token
1102
+ 'twelvelabs.marengo-embed-2.7': { input: 0.0007, output: 0.00007 }, // per minute + per request
1103
+
1104
+ // Writer models
1105
+ 'writer.palmyra-x-5': { input: 0.003, output: 0.015 },
1106
+ 'writer.palmyra-x-5:0': { input: 0.003, output: 0.015 },
1107
+ },
1108
+ };
1109
+
1110
+ function calculateCost(
1111
+ promptTokens: number,
1112
+ completionTokens: number,
1113
+ model: string | null,
1114
+ region: string = 'us-east-1',
1115
+ ): number | null {
1116
+ if (!model || promptTokens <= 0 || completionTokens <= 0) {
1117
+ return null;
1118
+ }
1119
+
1120
+ const regionPricing = BedrockPricing[region];
1121
+ if (!regionPricing) {
1122
+ console.warn(`No pricing information available for region: ${region}`);
1123
+ return null;
1124
+ }
1125
+
1126
+ const pricing =
1127
+ regionPricing[model] ?? Object.entries(regionPricing).find(([key]) => model.startsWith(key))?.[1];
1128
+ if (!pricing) {
1129
+ console.warn(`No pricing information available for model: ${model} in region: ${region}`);
1130
+ return null;
1131
+ }
1132
+
1133
+ const inputCost = (promptTokens / 1000) * pricing['input'];
1134
+ const outputCost = (completionTokens / 1000) * pricing['output'];
1135
+
1136
+ return inputCost + outputCost;
1137
+ }