@ai-sdk/amazon-bedrock 5.0.0-beta.2 → 5.0.0-beta.20

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.
@@ -514,6 +514,37 @@ console.log(amazonResult.text); // text response
514
514
  See [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details
515
515
  on how to integrate reasoning into your chatbot.
516
516
 
517
+ ## Service Tiers
518
+
519
+ Amazon Bedrock supports selecting an inference service tier per request via the `serviceTier` provider option.
520
+
521
+ ```ts
522
+ import {
523
+ bedrock,
524
+ type AmazonBedrockLanguageModelOptions,
525
+ } from '@ai-sdk/amazon-bedrock';
526
+ import { generateText } from 'ai';
527
+
528
+ const result = await generateText({
529
+ model: bedrock('us.anthropic.claude-sonnet-4-20250514-v1:0'),
530
+ prompt: 'Summarize this support ticket backlog.',
531
+ providerOptions: {
532
+ bedrock: {
533
+ serviceTier: 'priority',
534
+ } satisfies AmazonBedrockLanguageModelOptions,
535
+ },
536
+ });
537
+ ```
538
+
539
+ Supported values are:
540
+
541
+ - `reserved`
542
+ - `priority`
543
+ - `default`
544
+ - `flex`
545
+
546
+ See the [Amazon Bedrock service tiers documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html) for model availability and behavior.
547
+
517
548
  ## Extended Context Window
518
549
 
519
550
  Claude Sonnet 4 models on Amazon Bedrock support an extended context window of up to 1 million tokens when using the `context-1m-2025-08-07` beta feature.
@@ -546,6 +577,11 @@ Via Anthropic, Amazon Bedrock provides three provider-defined tools that can be
546
577
 
547
578
  They are available via the `tools` property of the provider instance.
548
579
 
580
+ <Note>
581
+ Amazon Bedrock does not support strict mode on tool definitions. Setting
582
+ `strict: true` on a tool will be ignored and a warning will be emitted.
583
+ </Note>
584
+
549
585
  ### Bash Tool
550
586
 
551
587
  The Bash Tool allows running bash commands. Here's how to create and use it:
@@ -1375,6 +1411,16 @@ const { text } = await generateText({
1375
1411
  });
1376
1412
  ```
1377
1413
 
1414
+ ### Provider Options
1415
+
1416
+ The following optional provider options are available for Bedrock Anthropic models:
1417
+
1418
+ - `metadata` _object_
1419
+
1420
+ Optional. Metadata to include with the request. See the [Anthropic API documentation](https://platform.claude.com/docs/en/api/messages/create) for details.
1421
+
1422
+ - `userId` _string_ - An external identifier for the end-user.
1423
+
1378
1424
  ### Cache Control
1379
1425
 
1380
1426
  In the messages and message parts, you can use the `providerOptions` property to set cache control breakpoints.
@@ -1428,7 +1474,7 @@ They are available via the `tools` property of the provider instance.
1428
1474
 
1429
1475
  ```ts
1430
1476
  import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
1431
- import { generateText, stepCountIs } from 'ai';
1477
+ import { generateText, isStepCount } from 'ai';
1432
1478
 
1433
1479
  const result = await generateText({
1434
1480
  model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'),
@@ -1441,7 +1487,7 @@ const result = await generateText({
1441
1487
  }),
1442
1488
  },
1443
1489
  prompt: 'List the files in my directory.',
1444
- stopWhen: stepCountIs(2),
1490
+ stopWhen: isStepCount(2),
1445
1491
  });
1446
1492
  ```
1447
1493
 
@@ -1449,7 +1495,7 @@ const result = await generateText({
1449
1495
 
1450
1496
  ```ts
1451
1497
  import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
1452
- import { generateText, stepCountIs } from 'ai';
1498
+ import { generateText, isStepCount } from 'ai';
1453
1499
 
1454
1500
  const result = await generateText({
1455
1501
  model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'),
@@ -1462,7 +1508,7 @@ const result = await generateText({
1462
1508
  }),
1463
1509
  },
1464
1510
  prompt: 'Update my README file.',
1465
- stopWhen: stepCountIs(5),
1511
+ stopWhen: isStepCount(5),
1466
1512
  });
1467
1513
  ```
1468
1514
 
@@ -1470,7 +1516,7 @@ const result = await generateText({
1470
1516
 
1471
1517
  ```ts
1472
1518
  import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
1473
- import { generateText, stepCountIs } from 'ai';
1519
+ import { generateText, isStepCount } from 'ai';
1474
1520
  import fs from 'fs';
1475
1521
 
1476
1522
  const result = await generateText({
@@ -1505,7 +1551,7 @@ const result = await generateText({
1505
1551
  }),
1506
1552
  },
1507
1553
  prompt: 'Take a screenshot.',
1508
- stopWhen: stepCountIs(3),
1554
+ stopWhen: isStepCount(3),
1509
1555
  });
1510
1556
  ```
1511
1557
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.20",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -38,9 +38,9 @@
38
38
  "@smithy/eventstream-codec": "^4.0.1",
39
39
  "@smithy/util-utf8": "^4.0.0",
40
40
  "aws4fetch": "^1.0.20",
41
- "@ai-sdk/anthropic": "4.0.0-beta.2",
42
- "@ai-sdk/provider": "4.0.0-beta.0",
43
- "@ai-sdk/provider-utils": "5.0.0-beta.1"
41
+ "@ai-sdk/anthropic": "4.0.0-beta.16",
42
+ "@ai-sdk/provider": "4.0.0-beta.5",
43
+ "@ai-sdk/provider-utils": "5.0.0-beta.9"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "20.17.24",
@@ -74,9 +74,7 @@
74
74
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
75
75
  "build:watch": "pnpm clean && tsup --watch",
76
76
  "clean": "del-cli dist docs *.tsbuildinfo",
77
- "lint": "eslint \"./**/*.ts*\"",
78
77
  "type-check": "tsc --build",
79
- "prettier-check": "prettier --check \"./**/*.ts*\"",
80
78
  "test": "pnpm test:node && pnpm test:edge",
81
79
  "test:update": "pnpm test:node -u",
82
80
  "test:watch": "vitest --config vitest.node.config.js",
@@ -3,14 +3,40 @@ import {
3
3
  FetchFunction,
4
4
  safeParseJSON,
5
5
  } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
6
7
  import { createBedrockEventStreamDecoder } from '../bedrock-event-stream-decoder';
7
8
 
9
+ const bedrockErrorSchema = z.looseObject({
10
+ message: z.string().optional(),
11
+ });
12
+
8
13
  export function createBedrockAnthropicFetch(
9
14
  baseFetch: FetchFunction,
10
15
  ): FetchFunction {
11
16
  return async (url, options) => {
12
17
  const response = await baseFetch(url, options);
13
18
 
19
+ // Transform Bedrock error responses into Anthropic error format
20
+ // so that anthropicFailedResponseHandler can extract the message.
21
+ if (!response.ok) {
22
+ const text = await response.text();
23
+ const parsed = await safeParseJSON({ text, schema: bedrockErrorSchema });
24
+
25
+ const message =
26
+ parsed.success && parsed.value.message ? parsed.value.message : text;
27
+
28
+ const anthropicError = JSON.stringify({
29
+ type: 'error',
30
+ error: { type: 'error', message },
31
+ });
32
+
33
+ return new Response(anthropicError, {
34
+ status: response.status,
35
+ statusText: response.statusText,
36
+ headers: response.headers,
37
+ });
38
+ }
39
+
14
40
  const contentType = response.headers.get('content-type');
15
41
  if (
16
42
  contentType?.includes('application/vnd.amazon.eventstream') &&
@@ -1,7 +1,7 @@
1
1
  import {
2
- LanguageModelV3,
2
+ LanguageModelV4,
3
3
  NoSuchModelError,
4
- ProviderV3,
4
+ ProviderV4,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
7
  FetchFunction,
@@ -47,18 +47,22 @@ const BEDROCK_TOOL_BETA_MAP: Record<string, string> = {
47
47
  text_editor_20250728: 'computer-use-2025-01-24',
48
48
  computer_20250124: 'computer-use-2025-01-24',
49
49
  computer_20241022: 'computer-use-2024-10-22',
50
+ tool_search_tool_regex_20251119: 'tool-search-tool-2025-10-19',
51
+ // BM25 is not currently supported on Bedrock, but including the beta flag
52
+ // so that Bedrock returns a more useful error message if it's used.
53
+ tool_search_tool_bm25_20251119: 'tool-search-tool-2025-10-19',
50
54
  };
51
55
 
52
- export interface BedrockAnthropicProvider extends ProviderV3 {
56
+ export interface BedrockAnthropicProvider extends ProviderV4 {
53
57
  /**
54
58
  * Creates a model for text generation.
55
59
  */
56
- (modelId: BedrockAnthropicModelId): LanguageModelV3;
60
+ (modelId: BedrockAnthropicModelId): LanguageModelV4;
57
61
 
58
62
  /**
59
63
  * Creates a model for text generation.
60
64
  */
61
- languageModel(modelId: BedrockAnthropicModelId): LanguageModelV3;
65
+ languageModel(modelId: BedrockAnthropicModelId): LanguageModelV4;
62
66
 
63
67
  /**
64
68
  * Anthropic-specific computer use tool.
@@ -333,7 +337,7 @@ export function createBedrockAnthropic(
333
337
  return createChatModel(modelId);
334
338
  };
335
339
 
336
- provider.specificationVersion = 'v3' as const;
340
+ provider.specificationVersion = 'v4' as const;
337
341
  provider.languageModel = createChatModel;
338
342
  provider.chat = createChatModel;
339
343
  provider.messages = createChatModel;
@@ -13,6 +13,9 @@ export interface BedrockConverseInput {
13
13
  };
14
14
  additionalModelRequestFields?: Record<string, unknown>;
15
15
  additionalModelResponseFieldPaths?: string[];
16
+ serviceTier?: {
17
+ type: string;
18
+ };
16
19
  guardrailConfig?:
17
20
  | BedrockGuardrailConfiguration
18
21
  | BedrockGuardrailStreamConfiguration
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  JSONObject,
3
- LanguageModelV3,
4
- LanguageModelV3CallOptions,
5
- LanguageModelV3Content,
6
- LanguageModelV3FinishReason,
7
- LanguageModelV3FunctionTool,
8
- LanguageModelV3GenerateResult,
9
- LanguageModelV3Reasoning,
10
- LanguageModelV3StreamPart,
11
- LanguageModelV3StreamResult,
12
- SharedV3ProviderMetadata,
13
- SharedV3Warning,
3
+ LanguageModelV4,
4
+ LanguageModelV4CallOptions,
5
+ LanguageModelV4Content,
6
+ LanguageModelV4FinishReason,
7
+ LanguageModelV4FunctionTool,
8
+ LanguageModelV4GenerateResult,
9
+ LanguageModelV4Reasoning,
10
+ LanguageModelV4StreamPart,
11
+ LanguageModelV4StreamResult,
12
+ SharedV4ProviderMetadata,
13
+ SharedV4Warning,
14
14
  } from '@ai-sdk/provider';
15
15
  import {
16
16
  FetchFunction,
@@ -19,10 +19,14 @@ import {
19
19
  combineHeaders,
20
20
  createJsonErrorResponseHandler,
21
21
  createJsonResponseHandler,
22
+ isCustomReasoning,
23
+ mapReasoningToProviderBudget,
24
+ mapReasoningToProviderEffort,
22
25
  parseProviderOptions,
23
26
  postJsonToApi,
24
27
  resolve,
25
28
  } from '@ai-sdk/provider-utils';
29
+ import { getModelCapabilities } from '@ai-sdk/anthropic/internal';
26
30
  import { z } from 'zod/v4';
27
31
  import {
28
32
  BEDROCK_STOP_REASONS,
@@ -30,6 +34,7 @@ import {
30
34
  BedrockStopReason,
31
35
  } from './bedrock-api-types';
32
36
  import {
37
+ AmazonBedrockLanguageModelOptions,
33
38
  BedrockChatModelId,
34
39
  amazonBedrockLanguageModelOptions,
35
40
  } from './bedrock-chat-options';
@@ -48,8 +53,8 @@ type BedrockChatConfig = {
48
53
  generateId: () => string;
49
54
  };
50
55
 
51
- export class BedrockChatLanguageModel implements LanguageModelV3 {
52
- readonly specificationVersion = 'v3';
56
+ export class BedrockChatLanguageModel implements LanguageModelV4 {
57
+ readonly specificationVersion = 'v4';
53
58
  readonly provider = 'amazon-bedrock';
54
59
 
55
60
  constructor(
@@ -70,22 +75,23 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
70
75
  seed,
71
76
  tools,
72
77
  toolChoice,
78
+ reasoning,
73
79
  providerOptions,
74
- }: LanguageModelV3CallOptions): Promise<{
80
+ }: LanguageModelV4CallOptions): Promise<{
75
81
  command: BedrockConverseInput;
76
- warnings: SharedV3Warning[];
82
+ warnings: SharedV4Warning[];
77
83
  usesJsonResponseTool: boolean;
78
84
  betas: Set<string>;
79
85
  }> {
80
86
  // Parse provider options
81
- const bedrockOptions =
87
+ let bedrockOptions =
82
88
  (await parseProviderOptions({
83
89
  provider: 'bedrock',
84
90
  providerOptions,
85
91
  schema: amazonBedrockLanguageModelOptions,
86
92
  })) ?? {};
87
93
 
88
- const warnings: SharedV3Warning[] = [];
94
+ const warnings: SharedV4Warning[] = [];
89
95
 
90
96
  if (frequencyPenalty != null) {
91
97
  warnings.push({
@@ -137,6 +143,16 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
137
143
  }
138
144
 
139
145
  const isAnthropicModel = this.modelId.includes('anthropic');
146
+ const isOpenAIModel = this.modelId.startsWith('openai.');
147
+
148
+ bedrockOptions = resolveBedrockReasoningConfig({
149
+ reasoning,
150
+ bedrockOptions,
151
+ warnings,
152
+ isAnthropicModel,
153
+ modelId: this.modelId,
154
+ });
155
+
140
156
  const isThinkingEnabled =
141
157
  bedrockOptions.reasoningConfig?.type === 'enabled' ||
142
158
  bedrockOptions.reasoningConfig?.type === 'adaptive';
@@ -147,7 +163,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
147
163
  responseFormat?.type === 'json' &&
148
164
  responseFormat.schema != null;
149
165
 
150
- const jsonResponseTool: LanguageModelV3FunctionTool | undefined =
166
+ const jsonResponseTool: LanguageModelV4FunctionTool | undefined =
151
167
  responseFormat?.type === 'json' &&
152
168
  responseFormat.schema != null &&
153
169
  !useNativeStructuredOutput
@@ -247,7 +263,6 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
247
263
 
248
264
  const maxReasoningEffort =
249
265
  bedrockOptions.reasoningConfig?.maxReasoningEffort;
250
- const isOpenAIModel = this.modelId.startsWith('openai.');
251
266
 
252
267
  if (maxReasoningEffort != null) {
253
268
  if (isAnthropicModel) {
@@ -368,6 +383,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
368
383
  const {
369
384
  reasoningConfig: _,
370
385
  additionalModelRequestFields: __,
386
+ serviceTier: ___,
371
387
  ...filteredBedrockOptions
372
388
  } = providerOptions?.bedrock || {};
373
389
 
@@ -387,6 +403,11 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
387
403
  ...(Object.keys(inferenceConfig).length > 0 && {
388
404
  inferenceConfig,
389
405
  }),
406
+ ...(bedrockOptions.serviceTier != null && {
407
+ serviceTier: {
408
+ type: bedrockOptions.serviceTier,
409
+ },
410
+ }),
390
411
  ...filteredBedrockOptions,
391
412
  ...(toolConfig.tools !== undefined && toolConfig.tools.length > 0
392
413
  ? { toolConfig }
@@ -411,8 +432,8 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
411
432
  }
412
433
 
413
434
  async doGenerate(
414
- options: LanguageModelV3CallOptions,
415
- ): Promise<LanguageModelV3GenerateResult> {
435
+ options: LanguageModelV4CallOptions,
436
+ ): Promise<LanguageModelV4GenerateResult> {
416
437
  const {
417
438
  command: args,
418
439
  warnings,
@@ -435,7 +456,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
435
456
  fetch: this.config.fetch,
436
457
  });
437
458
 
438
- const content: Array<LanguageModelV3Content> = [];
459
+ const content: Array<LanguageModelV4Content> = [];
439
460
  let isJsonResponseFromTool = false;
440
461
 
441
462
  // map response content to content array
@@ -448,7 +469,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
448
469
  // reasoning
449
470
  if (part.reasoningContent) {
450
471
  if ('reasoningText' in part.reasoningContent) {
451
- const reasoning: LanguageModelV3Reasoning = {
472
+ const reasoning: LanguageModelV4Reasoning = {
452
473
  type: 'reasoning',
453
474
  text: part.reasoningContent.reasoningText.text,
454
475
  };
@@ -566,8 +587,8 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
566
587
  }
567
588
 
568
589
  async doStream(
569
- options: LanguageModelV3CallOptions,
570
- ): Promise<LanguageModelV3StreamResult> {
590
+ options: LanguageModelV4CallOptions,
591
+ ): Promise<LanguageModelV4StreamResult> {
571
592
  const {
572
593
  command: args,
573
594
  warnings,
@@ -591,12 +612,12 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
591
612
  fetch: this.config.fetch,
592
613
  });
593
614
 
594
- let finishReason: LanguageModelV3FinishReason = {
615
+ let finishReason: LanguageModelV4FinishReason = {
595
616
  unified: 'other',
596
617
  raw: undefined,
597
618
  };
598
619
  let usage: BedrockUsage | undefined = undefined;
599
- let providerMetadata: SharedV3ProviderMetadata | undefined = undefined;
620
+ let providerMetadata: SharedV4ProviderMetadata | undefined = undefined;
600
621
  let isJsonResponseFromTool = false;
601
622
  let stopSequence: string | null = null;
602
623
 
@@ -616,7 +637,7 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
616
637
  stream: response.pipeThrough(
617
638
  new TransformStream<
618
639
  ParseResult<z.infer<typeof BedrockStreamSchema>>,
619
- LanguageModelV3StreamPart
640
+ LanguageModelV4StreamPart
620
641
  >({
621
642
  start(controller) {
622
643
  controller.enqueue({ type: 'stream-start', warnings });
@@ -1122,3 +1143,73 @@ export const bedrockReasoningMetadataSchema = z.object({
1122
1143
  export type BedrockReasoningMetadata = z.infer<
1123
1144
  typeof bedrockReasoningMetadataSchema
1124
1145
  >;
1146
+
1147
+ const bedrockReasoningEffortMap: Partial<
1148
+ Record<string, 'low' | 'medium' | 'high' | 'max'>
1149
+ > = {
1150
+ minimal: 'low',
1151
+ low: 'low',
1152
+ medium: 'medium',
1153
+ high: 'high',
1154
+ xhigh: 'max',
1155
+ };
1156
+
1157
+ function resolveBedrockReasoningConfig({
1158
+ reasoning,
1159
+ bedrockOptions,
1160
+ warnings,
1161
+ isAnthropicModel,
1162
+ modelId,
1163
+ }: {
1164
+ reasoning: LanguageModelV4CallOptions['reasoning'];
1165
+ bedrockOptions: AmazonBedrockLanguageModelOptions;
1166
+ warnings: SharedV4Warning[];
1167
+ isAnthropicModel: boolean;
1168
+ modelId: string;
1169
+ }): AmazonBedrockLanguageModelOptions {
1170
+ if (!isCustomReasoning(reasoning) || bedrockOptions.reasoningConfig != null) {
1171
+ return bedrockOptions;
1172
+ }
1173
+
1174
+ const result = { ...bedrockOptions };
1175
+
1176
+ if (isAnthropicModel) {
1177
+ const capabilities = getModelCapabilities(modelId);
1178
+
1179
+ if (reasoning === 'none') {
1180
+ result.reasoningConfig = { type: 'disabled' };
1181
+ } else if (capabilities.supportsAdaptiveThinking) {
1182
+ const effort = mapReasoningToProviderEffort({
1183
+ reasoning,
1184
+ effortMap: bedrockReasoningEffortMap,
1185
+ warnings,
1186
+ });
1187
+ result.reasoningConfig = {
1188
+ type: 'adaptive',
1189
+ maxReasoningEffort: effort,
1190
+ };
1191
+ } else {
1192
+ const budgetTokens = mapReasoningToProviderBudget({
1193
+ reasoning,
1194
+ maxOutputTokens: capabilities.maxOutputTokens,
1195
+ maxReasoningBudget: capabilities.maxOutputTokens,
1196
+ warnings,
1197
+ });
1198
+ if (budgetTokens != null) {
1199
+ result.reasoningConfig = {
1200
+ type: 'enabled',
1201
+ budgetTokens,
1202
+ };
1203
+ }
1204
+ }
1205
+ } else if (reasoning !== 'none') {
1206
+ const effort = mapReasoningToProviderEffort({
1207
+ reasoning,
1208
+ effortMap: bedrockReasoningEffortMap,
1209
+ warnings,
1210
+ });
1211
+ result.reasoningConfig = { maxReasoningEffort: effort };
1212
+ }
1213
+
1214
+ return result;
1215
+ }
@@ -122,6 +122,16 @@ export const amazonBedrockLanguageModelOptions = z.object({
122
122
  * Anthropic beta features to enable
123
123
  */
124
124
  anthropicBeta: z.array(z.string()).optional(),
125
+ /**
126
+ * Service tier for the request.
127
+ * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html
128
+ *
129
+ * - 'reserved': Uses provisioned throughput capacity
130
+ * - 'priority': Prioritizes low-latency inference when capacity is available
131
+ * - 'default': Standard on-demand tier
132
+ * - 'flex': Lower-cost tier for flexible latency workloads
133
+ */
134
+ serviceTier: z.enum(['reserved', 'priority', 'default', 'flex']).optional(),
125
135
  });
126
136
 
127
137
  export type AmazonBedrockLanguageModelOptions = z.infer<
@@ -1,5 +1,5 @@
1
1
  import {
2
- EmbeddingModelV3,
2
+ EmbeddingModelV4,
3
3
  TooManyEmbeddingValuesForCallError,
4
4
  } from '@ai-sdk/provider';
5
5
  import {
@@ -25,10 +25,10 @@ type BedrockEmbeddingConfig = {
25
25
  fetch?: FetchFunction;
26
26
  };
27
27
 
28
- type DoEmbedResponse = Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>;
28
+ type DoEmbedResponse = Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>;
29
29
 
30
- export class BedrockEmbeddingModel implements EmbeddingModelV3 {
31
- readonly specificationVersion = 'v3';
30
+ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
31
+ readonly specificationVersion = 'v4';
32
32
  readonly provider = 'amazon-bedrock';
33
33
  readonly maxEmbeddingsPerCall = 1;
34
34
  readonly supportsParallelCalls = true;
@@ -48,7 +48,7 @@ export class BedrockEmbeddingModel implements EmbeddingModelV3 {
48
48
  headers,
49
49
  abortSignal,
50
50
  providerOptions,
51
- }: Parameters<EmbeddingModelV3['doEmbed']>[0]): Promise<DoEmbedResponse> {
51
+ }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<DoEmbedResponse> {
52
52
  if (values.length > this.maxEmbeddingsPerCall) {
53
53
  throw new TooManyEmbeddingValuesForCallError({
54
54
  provider: this.provider,
@@ -1,7 +1,7 @@
1
1
  import {
2
- ImageModelV3,
3
- ImageModelV3File,
4
- SharedV3Warning,
2
+ ImageModelV4,
3
+ ImageModelV4File,
4
+ SharedV4Warning,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
7
  FetchFunction,
@@ -29,8 +29,8 @@ type BedrockImageModelConfig = {
29
29
  };
30
30
  };
31
31
 
32
- export class BedrockImageModel implements ImageModelV3 {
33
- readonly specificationVersion = 'v3';
32
+ export class BedrockImageModel implements ImageModelV4 {
33
+ readonly specificationVersion = 'v4';
34
34
  readonly provider = 'amazon-bedrock';
35
35
 
36
36
  get maxImagesPerCall(): number {
@@ -58,10 +58,10 @@ export class BedrockImageModel implements ImageModelV3 {
58
58
  abortSignal,
59
59
  files,
60
60
  mask,
61
- }: Parameters<ImageModelV3['doGenerate']>[0]): Promise<
62
- Awaited<ReturnType<ImageModelV3['doGenerate']>>
61
+ }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<
62
+ Awaited<ReturnType<ImageModelV4['doGenerate']>>
63
63
  > {
64
- const warnings: Array<SharedV3Warning> = [];
64
+ const warnings: Array<SharedV4Warning> = [];
65
65
  const [width, height] = size ? size.split('x').map(Number) : [];
66
66
 
67
67
  const hasFiles = files != null && files.length > 0;
@@ -265,7 +265,7 @@ export class BedrockImageModel implements ImageModelV3 {
265
265
  }
266
266
  }
267
267
 
268
- function getBase64Data(file: ImageModelV3File): string {
268
+ function getBase64Data(file: ImageModelV4File): string {
269
269
  if (file.type === 'url') {
270
270
  throw new Error(
271
271
  'URL-based images are not supported for Amazon Bedrock image editing. ' +
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  JSONObject,
3
- LanguageModelV3CallOptions,
4
- SharedV3Warning,
3
+ LanguageModelV4CallOptions,
4
+ SharedV4Warning,
5
5
  UnsupportedFunctionalityError,
6
6
  } from '@ai-sdk/provider';
7
7
  import { asSchema } from '@ai-sdk/provider-utils';
@@ -16,16 +16,16 @@ export async function prepareTools({
16
16
  toolChoice,
17
17
  modelId,
18
18
  }: {
19
- tools: LanguageModelV3CallOptions['tools'];
20
- toolChoice?: LanguageModelV3CallOptions['toolChoice'];
19
+ tools: LanguageModelV4CallOptions['tools'];
20
+ toolChoice?: LanguageModelV4CallOptions['toolChoice'];
21
21
  modelId: string;
22
22
  }): Promise<{
23
23
  toolConfig: BedrockToolConfiguration;
24
24
  additionalTools: Record<string, unknown> | undefined;
25
25
  betas: Set<string>;
26
- toolWarnings: SharedV3Warning[];
26
+ toolWarnings: SharedV4Warning[];
27
27
  }> {
28
- const toolWarnings: SharedV3Warning[] = [];
28
+ const toolWarnings: SharedV4Warning[] = [];
29
29
  const betas = new Set<string>();
30
30
 
31
31
  if (tools == null || tools.length === 0) {
@@ -82,6 +82,7 @@ export async function prepareTools({
82
82
  tools: ProviderTools,
83
83
  toolChoice,
84
84
  supportsStructuredOutput: false,
85
+ supportsStrictTools: false,
85
86
  });
86
87
 
87
88
  toolWarnings.push(...anthropicToolWarnings);