@ai-sdk/amazon-bedrock 5.0.0-beta.45 → 5.0.0-beta.47

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 (37) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/anthropic/index.d.ts +10 -10
  3. package/dist/anthropic/index.js +65 -51
  4. package/dist/anthropic/index.js.map +1 -1
  5. package/dist/index.d.ts +21 -21
  6. package/dist/index.js +338 -298
  7. package/dist/index.js.map +1 -1
  8. package/docs/08-amazon-bedrock.mdx +66 -66
  9. package/package.json +3 -3
  10. package/src/{bedrock-api-types.ts → amazon-bedrock-api-types.ts} +60 -55
  11. package/src/{bedrock-chat-options.ts → amazon-bedrock-chat-language-model-options.ts} +7 -7
  12. package/src/{bedrock-chat-language-model.ts → amazon-bedrock-chat-language-model.ts} +211 -190
  13. package/src/{bedrock-embedding-options.ts → amazon-bedrock-embedding-model-options.ts} +1 -1
  14. package/src/{bedrock-embedding-model.ts → amazon-bedrock-embedding-model.ts} +31 -24
  15. package/src/{bedrock-error.ts → amazon-bedrock-error.ts} +1 -1
  16. package/src/{bedrock-event-stream-decoder.ts → amazon-bedrock-event-stream-decoder.ts} +1 -1
  17. package/src/{bedrock-event-stream-response-handler.ts → amazon-bedrock-event-stream-response-handler.ts} +3 -3
  18. package/src/{bedrock-image-model.ts → amazon-bedrock-image-model.ts} +40 -36
  19. package/src/amazon-bedrock-image-settings.ts +9 -0
  20. package/src/{bedrock-prepare-tools.ts → amazon-bedrock-prepare-tools.ts} +18 -17
  21. package/src/{bedrock-provider.ts → amazon-bedrock-provider.ts} +40 -38
  22. package/src/amazon-bedrock-reasoning-metadata.ts +10 -0
  23. package/src/{bedrock-sigv4-fetch.ts → amazon-bedrock-sigv4-fetch.ts} +13 -7
  24. package/src/anthropic/amazon-bedrock-anthropic-fetch.ts +104 -0
  25. package/src/anthropic/{bedrock-anthropic-options.ts → amazon-bedrock-anthropic-options.ts} +1 -1
  26. package/src/anthropic/{bedrock-anthropic-provider.ts → amazon-bedrock-anthropic-provider.ts} +18 -16
  27. package/src/anthropic/index.ts +19 -7
  28. package/src/{convert-bedrock-usage.ts → convert-amazon-bedrock-usage.ts} +3 -3
  29. package/src/{convert-to-bedrock-chat-messages.ts → convert-to-amazon-bedrock-chat-messages.ts} +92 -59
  30. package/src/index.ts +15 -8
  31. package/src/{map-bedrock-finish-reason.ts → map-amazon-bedrock-finish-reason.ts} +3 -3
  32. package/src/reranking/{bedrock-reranking-api.ts → amazon-bedrock-reranking-api.ts} +3 -3
  33. package/src/reranking/{bedrock-reranking-options.ts → amazon-bedrock-reranking-model-options.ts} +1 -1
  34. package/src/reranking/{bedrock-reranking-model.ts → amazon-bedrock-reranking-model.ts} +29 -21
  35. package/src/anthropic/bedrock-anthropic-fetch.ts +0 -94
  36. package/src/bedrock-image-settings.ts +0 -6
  37. package/src/bedrock-reasoning-metadata.ts +0 -10
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
 
3
- export type BedrockEmbeddingModelId =
3
+ export type AmazonBedrockEmbeddingModelId =
4
4
  | 'amazon.titan-embed-text-v1'
5
5
  | 'amazon.titan-embed-text-v2:0'
6
6
  | 'cohere.embed-english-v3'
@@ -17,12 +17,12 @@ import {
17
17
  } from '@ai-sdk/provider-utils';
18
18
  import {
19
19
  amazonBedrockEmbeddingModelOptionsSchema,
20
- type BedrockEmbeddingModelId,
21
- } from './bedrock-embedding-options';
22
- import { BedrockErrorSchema } from './bedrock-error';
20
+ type AmazonBedrockEmbeddingModelId,
21
+ } from './amazon-bedrock-embedding-model-options';
22
+ import { AmazonBedrockErrorSchema } from './amazon-bedrock-error';
23
23
  import { z } from 'zod/v4';
24
24
 
25
- type BedrockEmbeddingConfig = {
25
+ type AmazonBedrockEmbeddingConfig = {
26
26
  baseUrl: () => string;
27
27
  headers?: Resolvable<Record<string, string | undefined>>;
28
28
  fetch?: FetchFunction;
@@ -30,13 +30,13 @@ type BedrockEmbeddingConfig = {
30
30
 
31
31
  type DoEmbedResponse = Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>;
32
32
 
33
- export class BedrockEmbeddingModel implements EmbeddingModelV4 {
33
+ export class AmazonBedrockEmbeddingModel implements EmbeddingModelV4 {
34
34
  readonly specificationVersion = 'v4';
35
35
  readonly provider = 'amazon-bedrock';
36
36
  readonly maxEmbeddingsPerCall = 1;
37
37
  readonly supportsParallelCalls = true;
38
38
 
39
- static [WORKFLOW_SERIALIZE](model: BedrockEmbeddingModel) {
39
+ static [WORKFLOW_SERIALIZE](model: AmazonBedrockEmbeddingModel) {
40
40
  return serializeModelOptions({
41
41
  modelId: model.modelId,
42
42
  config: model.config,
@@ -45,14 +45,14 @@ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
45
45
 
46
46
  static [WORKFLOW_DESERIALIZE](options: {
47
47
  modelId: string;
48
- config: BedrockEmbeddingConfig;
48
+ config: AmazonBedrockEmbeddingConfig;
49
49
  }) {
50
- return new BedrockEmbeddingModel(options.modelId, options.config);
50
+ return new AmazonBedrockEmbeddingModel(options.modelId, options.config);
51
51
  }
52
52
 
53
53
  constructor(
54
- readonly modelId: BedrockEmbeddingModelId,
55
- private readonly config: BedrockEmbeddingConfig,
54
+ readonly modelId: AmazonBedrockEmbeddingModelId,
55
+ private readonly config: AmazonBedrockEmbeddingConfig,
56
56
  ) {}
57
57
 
58
58
  private getUrl(modelId: string): string {
@@ -75,13 +75,20 @@ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
75
75
  });
76
76
  }
77
77
 
78
- // Parse provider options
79
- const bedrockOptions =
78
+ // Parse provider options. Prefer `amazonBedrock`; fall back to legacy
79
+ // `bedrock` key for backward compatibility.
80
+ const amazonBedrockOptions =
81
+ (await parseProviderOptions({
82
+ provider: 'amazonBedrock',
83
+ providerOptions,
84
+ schema: amazonBedrockEmbeddingModelOptionsSchema,
85
+ })) ??
80
86
  (await parseProviderOptions({
81
87
  provider: 'bedrock',
82
88
  providerOptions,
83
89
  schema: amazonBedrockEmbeddingModelOptionsSchema,
84
- })) ?? {};
90
+ })) ??
91
+ {};
85
92
 
86
93
  // https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html
87
94
  //
@@ -97,10 +104,10 @@ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
97
104
  taskType: 'SINGLE_EMBEDDING',
98
105
  singleEmbeddingParams: {
99
106
  embeddingPurpose:
100
- bedrockOptions.embeddingPurpose ?? 'GENERIC_INDEX',
101
- embeddingDimension: bedrockOptions.embeddingDimension ?? 1024,
107
+ amazonBedrockOptions.embeddingPurpose ?? 'GENERIC_INDEX',
108
+ embeddingDimension: amazonBedrockOptions.embeddingDimension ?? 1024,
102
109
  text: {
103
- truncationMode: bedrockOptions.truncate ?? 'END',
110
+ truncationMode: amazonBedrockOptions.truncate ?? 'END',
104
111
  value: values[0],
105
112
  },
106
113
  },
@@ -109,15 +116,15 @@ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
109
116
  ? {
110
117
  // Cohere embedding models on Bedrock require `input_type`.
111
118
  // Without it, the service attempts other schema branches and rejects the request.
112
- input_type: bedrockOptions.inputType ?? 'search_query',
119
+ input_type: amazonBedrockOptions.inputType ?? 'search_query',
113
120
  texts: [values[0]],
114
- truncate: bedrockOptions.truncate,
115
- output_dimension: bedrockOptions.outputDimension,
121
+ truncate: amazonBedrockOptions.truncate,
122
+ output_dimension: amazonBedrockOptions.outputDimension,
116
123
  }
117
124
  : {
118
125
  inputText: values[0],
119
- dimensions: bedrockOptions.dimensions,
120
- normalize: bedrockOptions.normalize,
126
+ dimensions: amazonBedrockOptions.dimensions,
127
+ normalize: amazonBedrockOptions.normalize,
121
128
  };
122
129
 
123
130
  const url = this.getUrl(this.modelId);
@@ -131,11 +138,11 @@ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
131
138
  ),
132
139
  body: args,
133
140
  failedResponseHandler: createJsonErrorResponseHandler({
134
- errorSchema: BedrockErrorSchema,
141
+ errorSchema: AmazonBedrockErrorSchema,
135
142
  errorToMessage: error => `${error.type}: ${error.message}`,
136
143
  }),
137
144
  successfulResponseHandler: createJsonResponseHandler(
138
- BedrockEmbeddingResponseSchema,
145
+ AmazonBedrockEmbeddingResponseSchema,
139
146
  ),
140
147
  fetch: this.config.fetch,
141
148
  abortSignal,
@@ -180,7 +187,7 @@ export class BedrockEmbeddingModel implements EmbeddingModelV4 {
180
187
  }
181
188
  }
182
189
 
183
- const BedrockEmbeddingResponseSchema = z.union([
190
+ const AmazonBedrockEmbeddingResponseSchema = z.union([
184
191
  // Titan-style response
185
192
  z.object({
186
193
  embedding: z.array(z.number()),
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
 
3
- export const BedrockErrorSchema = z.object({
3
+ export const AmazonBedrockErrorSchema = z.object({
4
4
  message: z.string(),
5
5
  type: z.string().nullish(),
6
6
  });
@@ -7,7 +7,7 @@ export interface DecodedEvent {
7
7
  data: string;
8
8
  }
9
9
 
10
- export function createBedrockEventStreamDecoder<T>(
10
+ export function createAmazonBedrockEventStreamDecoder<T>(
11
11
  body: ReadableStream<Uint8Array>,
12
12
  processEvent: (
13
13
  event: DecodedEvent,
@@ -7,9 +7,9 @@ import {
7
7
  type ResponseHandler,
8
8
  } from '@ai-sdk/provider-utils';
9
9
  import type { ZodType } from 'zod/v4';
10
- import { createBedrockEventStreamDecoder } from './bedrock-event-stream-decoder';
10
+ import { createAmazonBedrockEventStreamDecoder } from './amazon-bedrock-event-stream-decoder';
11
11
 
12
- export const createBedrockEventStreamResponseHandler =
12
+ export const createAmazonBedrockEventStreamResponseHandler =
13
13
  <T>(
14
14
  chunkSchema: ZodType<T, any>,
15
15
  ): ResponseHandler<ReadableStream<ParseResult<T>>> =>
@@ -22,7 +22,7 @@ export const createBedrockEventStreamResponseHandler =
22
22
 
23
23
  return {
24
24
  responseHeaders,
25
- value: createBedrockEventStreamDecoder<ParseResult<T>>(
25
+ value: createAmazonBedrockEventStreamDecoder<ParseResult<T>>(
26
26
  response.body,
27
27
  async (event, controller) => {
28
28
  if (event.messageType === 'event') {
@@ -18,12 +18,12 @@ import {
18
18
  } from '@ai-sdk/provider-utils';
19
19
  import {
20
20
  modelMaxImagesPerCall,
21
- type BedrockImageModelId,
22
- } from './bedrock-image-settings';
23
- import { BedrockErrorSchema } from './bedrock-error';
21
+ type AmazonBedrockImageModelId,
22
+ } from './amazon-bedrock-image-settings';
23
+ import { AmazonBedrockErrorSchema } from './amazon-bedrock-error';
24
24
  import { z } from 'zod/v4';
25
25
 
26
- type BedrockImageModelConfig = {
26
+ type AmazonBedrockImageModelConfig = {
27
27
  baseUrl: () => string;
28
28
  headers?: Resolvable<Record<string, string | undefined>>;
29
29
  fetch?: FetchFunction;
@@ -32,11 +32,11 @@ type BedrockImageModelConfig = {
32
32
  };
33
33
  };
34
34
 
35
- export class BedrockImageModel implements ImageModelV4 {
35
+ export class AmazonBedrockImageModel implements ImageModelV4 {
36
36
  readonly specificationVersion = 'v4';
37
37
  readonly provider = 'amazon-bedrock';
38
38
 
39
- static [WORKFLOW_SERIALIZE](model: BedrockImageModel) {
39
+ static [WORKFLOW_SERIALIZE](model: AmazonBedrockImageModel) {
40
40
  return serializeModelOptions({
41
41
  modelId: model.modelId,
42
42
  config: model.config,
@@ -45,9 +45,9 @@ export class BedrockImageModel implements ImageModelV4 {
45
45
 
46
46
  static [WORKFLOW_DESERIALIZE](options: {
47
47
  modelId: string;
48
- config: BedrockImageModelConfig;
48
+ config: AmazonBedrockImageModelConfig;
49
49
  }) {
50
- return new BedrockImageModel(options.modelId, options.config);
50
+ return new AmazonBedrockImageModel(options.modelId, options.config);
51
51
  }
52
52
 
53
53
  get maxImagesPerCall(): number {
@@ -60,8 +60,8 @@ export class BedrockImageModel implements ImageModelV4 {
60
60
  }
61
61
 
62
62
  constructor(
63
- readonly modelId: BedrockImageModelId,
64
- private readonly config: BedrockImageModelConfig,
63
+ readonly modelId: AmazonBedrockImageModelId,
64
+ private readonly config: AmazonBedrockImageModelConfig,
65
65
  ) {}
66
66
 
67
67
  async doGenerate({
@@ -83,17 +83,22 @@ export class BedrockImageModel implements ImageModelV4 {
83
83
 
84
84
  const hasFiles = files != null && files.length > 0;
85
85
 
86
+ // Prefer the new `amazonBedrock` providerOptions key; fall back to the
87
+ // legacy `bedrock` key for backward compatibility.
88
+ const amazonBedrockOptions = (providerOptions?.amazonBedrock ??
89
+ providerOptions?.bedrock) as Record<string, any> | undefined;
90
+
86
91
  // Build image generation config (common to most modes)
87
92
  const imageGenerationConfig = {
88
93
  ...(width ? { width } : {}),
89
94
  ...(height ? { height } : {}),
90
95
  ...(seed ? { seed } : {}),
91
96
  ...(n ? { numberOfImages: n } : {}),
92
- ...(providerOptions?.bedrock?.quality
93
- ? { quality: providerOptions.bedrock.quality }
97
+ ...(amazonBedrockOptions?.quality
98
+ ? { quality: amazonBedrockOptions.quality }
94
99
  : {}),
95
- ...(providerOptions?.bedrock?.cfgScale
96
- ? { cfgScale: providerOptions.bedrock.cfgScale }
100
+ ...(amazonBedrockOptions?.cfgScale
101
+ ? { cfgScale: amazonBedrockOptions.cfgScale }
97
102
  : {}),
98
103
  };
99
104
 
@@ -102,11 +107,11 @@ export class BedrockImageModel implements ImageModelV4 {
102
107
  if (hasFiles) {
103
108
  // Check if mask is actually provided (has valid data, not just an empty object)
104
109
  const hasMask = mask?.type != null;
105
- const hasMaskPrompt = providerOptions?.bedrock?.maskPrompt != null;
110
+ const hasMaskPrompt = amazonBedrockOptions?.maskPrompt != null;
106
111
 
107
112
  // Determine task type from provider options, or infer from mask presence
108
113
  const taskType =
109
- providerOptions?.bedrock?.taskType ??
114
+ amazonBedrockOptions?.taskType ??
110
115
  (hasMask || hasMaskPrompt ? 'INPAINTING' : 'IMAGE_VARIATION');
111
116
 
112
117
  const sourceImageBase64 = getBase64Data(files[0]);
@@ -116,8 +121,8 @@ export class BedrockImageModel implements ImageModelV4 {
116
121
  const inPaintingParams: Record<string, unknown> = {
117
122
  image: sourceImageBase64,
118
123
  ...(prompt ? { text: prompt } : {}),
119
- ...(providerOptions?.bedrock?.negativeText
120
- ? { negativeText: providerOptions.bedrock.negativeText }
124
+ ...(amazonBedrockOptions?.negativeText
125
+ ? { negativeText: amazonBedrockOptions.negativeText }
121
126
  : {}),
122
127
  };
123
128
 
@@ -125,7 +130,7 @@ export class BedrockImageModel implements ImageModelV4 {
125
130
  if (hasMask) {
126
131
  inPaintingParams.maskImage = getBase64Data(mask);
127
132
  } else if (hasMaskPrompt) {
128
- inPaintingParams.maskPrompt = providerOptions.bedrock.maskPrompt;
133
+ inPaintingParams.maskPrompt = amazonBedrockOptions.maskPrompt;
129
134
  }
130
135
 
131
136
  args = {
@@ -140,11 +145,11 @@ export class BedrockImageModel implements ImageModelV4 {
140
145
  const outPaintingParams: Record<string, unknown> = {
141
146
  image: sourceImageBase64,
142
147
  ...(prompt ? { text: prompt } : {}),
143
- ...(providerOptions?.bedrock?.negativeText
144
- ? { negativeText: providerOptions.bedrock.negativeText }
148
+ ...(amazonBedrockOptions?.negativeText
149
+ ? { negativeText: amazonBedrockOptions.negativeText }
145
150
  : {}),
146
- ...(providerOptions?.bedrock?.outPaintingMode
147
- ? { outPaintingMode: providerOptions.bedrock.outPaintingMode }
151
+ ...(amazonBedrockOptions?.outPaintingMode
152
+ ? { outPaintingMode: amazonBedrockOptions.outPaintingMode }
148
153
  : {}),
149
154
  };
150
155
 
@@ -152,7 +157,7 @@ export class BedrockImageModel implements ImageModelV4 {
152
157
  if (hasMask) {
153
158
  outPaintingParams.maskImage = getBase64Data(mask);
154
159
  } else if (hasMaskPrompt) {
155
- outPaintingParams.maskPrompt = providerOptions.bedrock.maskPrompt;
160
+ outPaintingParams.maskPrompt = amazonBedrockOptions.maskPrompt;
156
161
  }
157
162
 
158
163
  args = {
@@ -181,13 +186,12 @@ export class BedrockImageModel implements ImageModelV4 {
181
186
  const imageVariationParams: Record<string, unknown> = {
182
187
  images,
183
188
  ...(prompt ? { text: prompt } : {}),
184
- ...(providerOptions?.bedrock?.negativeText
185
- ? { negativeText: providerOptions.bedrock.negativeText }
189
+ ...(amazonBedrockOptions?.negativeText
190
+ ? { negativeText: amazonBedrockOptions.negativeText }
186
191
  : {}),
187
- ...(providerOptions?.bedrock?.similarityStrength != null
192
+ ...(amazonBedrockOptions?.similarityStrength != null
188
193
  ? {
189
- similarityStrength:
190
- providerOptions.bedrock.similarityStrength,
194
+ similarityStrength: amazonBedrockOptions.similarityStrength,
191
195
  }
192
196
  : {}),
193
197
  };
@@ -209,14 +213,14 @@ export class BedrockImageModel implements ImageModelV4 {
209
213
  taskType: 'TEXT_IMAGE',
210
214
  textToImageParams: {
211
215
  text: prompt,
212
- ...(providerOptions?.bedrock?.negativeText
216
+ ...(amazonBedrockOptions?.negativeText
213
217
  ? {
214
- negativeText: providerOptions.bedrock.negativeText,
218
+ negativeText: amazonBedrockOptions.negativeText,
215
219
  }
216
220
  : {}),
217
- ...(providerOptions?.bedrock?.style
221
+ ...(amazonBedrockOptions?.style
218
222
  ? {
219
- style: providerOptions.bedrock.style,
223
+ style: amazonBedrockOptions.style,
220
224
  }
221
225
  : {}),
222
226
  },
@@ -244,11 +248,11 @@ export class BedrockImageModel implements ImageModelV4 {
244
248
  ),
245
249
  body: args,
246
250
  failedResponseHandler: createJsonErrorResponseHandler({
247
- errorSchema: BedrockErrorSchema,
251
+ errorSchema: AmazonBedrockErrorSchema,
248
252
  errorToMessage: error => `${error.type}: ${error.message}`,
249
253
  }),
250
254
  successfulResponseHandler: createJsonResponseHandler(
251
- bedrockImageResponseSchema,
255
+ amazonBedrockImageResponseSchema,
252
256
  ),
253
257
  abortSignal,
254
258
  fetch: this.config.fetch,
@@ -303,7 +307,7 @@ function getBase64Data(file: ImageModelV4File): string {
303
307
 
304
308
  // minimal version of the schema, focussed on what is needed for the implementation
305
309
  // this approach limits breakages when the API changes and increases efficiency
306
- const bedrockImageResponseSchema = z.object({
310
+ const amazonBedrockImageResponseSchema = z.object({
307
311
  // Normal successful response
308
312
  images: z.array(z.string()).optional(),
309
313
 
@@ -0,0 +1,9 @@
1
+ export type AmazonBedrockImageModelId =
2
+ | 'amazon.nova-canvas-v1:0'
3
+ | (string & {});
4
+
5
+ // https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html
6
+ export const modelMaxImagesPerCall: Record<AmazonBedrockImageModelId, number> =
7
+ {
8
+ 'amazon.nova-canvas-v1:0': 5,
9
+ };
@@ -10,9 +10,9 @@ import {
10
10
  prepareTools as prepareAnthropicTools,
11
11
  } from '@ai-sdk/anthropic/internal';
12
12
  import type {
13
- BedrockTool,
14
- BedrockToolConfiguration,
15
- } from './bedrock-api-types';
13
+ AmazonBedrockTool,
14
+ AmazonBedrockToolConfiguration,
15
+ } from './amazon-bedrock-api-types';
16
16
 
17
17
  export async function prepareTools({
18
18
  tools,
@@ -23,7 +23,7 @@ export async function prepareTools({
23
23
  toolChoice?: LanguageModelV4CallOptions['toolChoice'];
24
24
  modelId: string;
25
25
  }): Promise<{
26
- toolConfig: BedrockToolConfiguration;
26
+ toolConfig: AmazonBedrockToolConfiguration;
27
27
  additionalTools: Record<string, unknown> | undefined;
28
28
  betas: Set<string>;
29
29
  toolWarnings: SharedV4Warning[];
@@ -71,7 +71,7 @@ export async function prepareTools({
71
71
  const functionTools = supportedTools.filter(t => t.type === 'function');
72
72
 
73
73
  let additionalTools: Record<string, unknown> | undefined = undefined;
74
- const bedrockTools: BedrockTool[] = [];
74
+ const amazonBedrockTools: AmazonBedrockTool[] = [];
75
75
 
76
76
  const usingAnthropicTools = isAnthropicModel && ProviderTools.length > 0;
77
77
 
@@ -108,7 +108,7 @@ export async function prepareTools({
108
108
 
109
109
  if (toolFactory != null) {
110
110
  const fullToolDefinition = (toolFactory as (args: any) => any)({});
111
- bedrockTools.push({
111
+ amazonBedrockTools.push({
112
112
  toolSpec: {
113
113
  name: tool.name,
114
114
  inputSchema: {
@@ -134,7 +134,7 @@ export async function prepareTools({
134
134
  : functionTools;
135
135
 
136
136
  for (const tool of filteredFunctionTools) {
137
- bedrockTools.push({
137
+ amazonBedrockTools.push({
138
138
  toolSpec: {
139
139
  name: tool.name,
140
140
  ...(tool.description?.trim() !== ''
@@ -149,22 +149,23 @@ export async function prepareTools({
149
149
  }
150
150
 
151
151
  // Handle toolChoice for standard Bedrock tools, but NOT for Anthropic provider-defined tools
152
- let bedrockToolChoice: BedrockToolConfiguration['toolChoice'] = undefined;
153
- if (!usingAnthropicTools && bedrockTools.length > 0 && toolChoice) {
152
+ let amazonBedrockToolChoice: AmazonBedrockToolConfiguration['toolChoice'] =
153
+ undefined;
154
+ if (!usingAnthropicTools && amazonBedrockTools.length > 0 && toolChoice) {
154
155
  const type = toolChoice.type;
155
156
  switch (type) {
156
157
  case 'auto':
157
- bedrockToolChoice = { auto: {} };
158
+ amazonBedrockToolChoice = { auto: {} };
158
159
  break;
159
160
  case 'required':
160
- bedrockToolChoice = { any: {} };
161
+ amazonBedrockToolChoice = { any: {} };
161
162
  break;
162
163
  case 'none':
163
- bedrockTools.length = 0;
164
- bedrockToolChoice = undefined;
164
+ amazonBedrockTools.length = 0;
165
+ amazonBedrockToolChoice = undefined;
165
166
  break;
166
167
  case 'tool':
167
- bedrockToolChoice = { tool: { name: toolChoice.toolName } };
168
+ amazonBedrockToolChoice = { tool: { name: toolChoice.toolName } };
168
169
  break;
169
170
  default: {
170
171
  const _exhaustiveCheck: never = type;
@@ -175,9 +176,9 @@ export async function prepareTools({
175
176
  }
176
177
  }
177
178
 
178
- const toolConfig: BedrockToolConfiguration =
179
- bedrockTools.length > 0
180
- ? { tools: bedrockTools, toolChoice: bedrockToolChoice }
179
+ const toolConfig: AmazonBedrockToolConfiguration =
180
+ amazonBedrockTools.length > 0
181
+ ? { tools: amazonBedrockTools, toolChoice: amazonBedrockToolChoice }
181
182
  : {};
182
183
 
183
184
  return {
@@ -14,19 +14,19 @@ import {
14
14
  withUserAgentSuffix,
15
15
  type FetchFunction,
16
16
  } from '@ai-sdk/provider-utils';
17
- import { BedrockChatLanguageModel } from './bedrock-chat-language-model';
18
- import type { BedrockChatModelId } from './bedrock-chat-options';
19
- import { BedrockEmbeddingModel } from './bedrock-embedding-model';
20
- import type { BedrockEmbeddingModelId } from './bedrock-embedding-options';
21
- import { BedrockImageModel } from './bedrock-image-model';
22
- import type { BedrockImageModelId } from './bedrock-image-settings';
17
+ import { AmazonBedrockChatLanguageModel } from './amazon-bedrock-chat-language-model';
18
+ import type { AmazonBedrockChatModelId } from './amazon-bedrock-chat-language-model-options';
19
+ import { AmazonBedrockEmbeddingModel } from './amazon-bedrock-embedding-model';
20
+ import type { AmazonBedrockEmbeddingModelId } from './amazon-bedrock-embedding-model-options';
21
+ import { AmazonBedrockImageModel } from './amazon-bedrock-image-model';
22
+ import type { AmazonBedrockImageModelId } from './amazon-bedrock-image-settings';
23
23
  import {
24
24
  createApiKeyFetchFunction,
25
25
  createSigV4FetchFunction,
26
- type BedrockCredentials,
27
- } from './bedrock-sigv4-fetch';
28
- import { BedrockRerankingModel } from './reranking/bedrock-reranking-model';
29
- import type { BedrockRerankingModelId } from './reranking/bedrock-reranking-options';
26
+ type AmazonBedrockCredentials,
27
+ } from './amazon-bedrock-sigv4-fetch';
28
+ import { AmazonBedrockRerankingModel } from './reranking/amazon-bedrock-reranking-model';
29
+ import type { AmazonBedrockRerankingModelId } from './reranking/amazon-bedrock-reranking-model-options';
30
30
  import { VERSION } from './version';
31
31
 
32
32
  export interface AmazonBedrockProviderSettings {
@@ -103,56 +103,58 @@ export interface AmazonBedrockProviderSettings {
103
103
  * credential values to be used instead of the `accessKeyId`, `secretAccessKey`,
104
104
  * and `sessionToken` settings.
105
105
  */
106
- credentialProvider?: () => PromiseLike<Omit<BedrockCredentials, 'region'>>;
106
+ credentialProvider?: () => PromiseLike<
107
+ Omit<AmazonBedrockCredentials, 'region'>
108
+ >;
107
109
 
108
110
  // for testing
109
111
  generateId?: () => string;
110
112
  }
111
113
 
112
114
  export interface AmazonBedrockProvider extends ProviderV4 {
113
- (modelId: BedrockChatModelId): LanguageModelV4;
115
+ (modelId: AmazonBedrockChatModelId): LanguageModelV4;
114
116
 
115
- languageModel(modelId: BedrockChatModelId): LanguageModelV4;
117
+ languageModel(modelId: AmazonBedrockChatModelId): LanguageModelV4;
116
118
 
117
119
  /**
118
120
  * Creates a model for text embeddings.
119
121
  */
120
- embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV4;
122
+ embedding(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
121
123
 
122
124
  /**
123
125
  * Creates a model for text embeddings.
124
126
  */
125
- embeddingModel(modelId: BedrockEmbeddingModelId): EmbeddingModelV4;
127
+ embeddingModel(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
126
128
 
127
129
  /**
128
130
  * @deprecated Use `embedding` instead.
129
131
  */
130
- textEmbedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV4;
132
+ textEmbedding(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
131
133
 
132
134
  /**
133
135
  * @deprecated Use `embeddingModel` instead.
134
136
  */
135
- textEmbeddingModel(modelId: BedrockEmbeddingModelId): EmbeddingModelV4;
137
+ textEmbeddingModel(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
136
138
 
137
139
  /**
138
140
  * Creates a model for image generation.
139
141
  */
140
- image(modelId: BedrockImageModelId): ImageModelV4;
142
+ image(modelId: AmazonBedrockImageModelId): ImageModelV4;
141
143
 
142
144
  /**
143
145
  * Creates a model for image generation.
144
146
  */
145
- imageModel(modelId: BedrockImageModelId): ImageModelV4;
147
+ imageModel(modelId: AmazonBedrockImageModelId): ImageModelV4;
146
148
 
147
149
  /**
148
150
  * Creates a model for reranking documents.
149
151
  */
150
- reranking(modelId: BedrockRerankingModelId): RerankingModelV4;
152
+ reranking(modelId: AmazonBedrockRerankingModelId): RerankingModelV4;
151
153
 
152
154
  /**
153
155
  * Creates a model for reranking documents.
154
156
  */
155
- rerankingModel(modelId: BedrockRerankingModelId): RerankingModelV4;
157
+ rerankingModel(modelId: AmazonBedrockRerankingModelId): RerankingModelV4;
156
158
 
157
159
  /**
158
160
  * Anthropic-specific tools that can be used with Anthropic models on Bedrock.
@@ -268,7 +270,7 @@ export function createAmazonBedrock(
268
270
  return withUserAgentSuffix(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION}`);
269
271
  };
270
272
 
271
- const getBedrockRuntimeBaseUrl = (): string =>
273
+ const getAmazonBedrockRuntimeBaseUrl = (): string =>
272
274
  withoutTrailingSlash(
273
275
  options.baseURL ??
274
276
  `https://bedrock-runtime.${loadSetting({
@@ -279,7 +281,7 @@ export function createAmazonBedrock(
279
281
  })}.amazonaws.com`,
280
282
  ) ?? `https://bedrock-runtime.us-east-1.amazonaws.com`;
281
283
 
282
- const getBedrockAgentRuntimeBaseUrl = (): string =>
284
+ const getAmazonBedrockAgentRuntimeBaseUrl = (): string =>
283
285
  withoutTrailingSlash(
284
286
  options.baseURL ??
285
287
  `https://bedrock-agent-runtime.${loadSetting({
@@ -290,15 +292,15 @@ export function createAmazonBedrock(
290
292
  })}.amazonaws.com`,
291
293
  ) ?? `https://bedrock-agent-runtime.us-west-2.amazonaws.com`;
292
294
 
293
- const createChatModel = (modelId: BedrockChatModelId) =>
294
- new BedrockChatLanguageModel(modelId, {
295
- baseUrl: getBedrockRuntimeBaseUrl,
295
+ const createChatModel = (modelId: AmazonBedrockChatModelId) =>
296
+ new AmazonBedrockChatLanguageModel(modelId, {
297
+ baseUrl: getAmazonBedrockRuntimeBaseUrl,
296
298
  headers: getHeaders,
297
299
  fetch: fetchFunction,
298
300
  generateId,
299
301
  });
300
302
 
301
- const provider = function (modelId: BedrockChatModelId) {
303
+ const provider = function (modelId: AmazonBedrockChatModelId) {
302
304
  if (new.target) {
303
305
  throw new Error(
304
306
  'The Amazon Bedrock model function cannot be called with the new keyword.',
@@ -308,23 +310,23 @@ export function createAmazonBedrock(
308
310
  return createChatModel(modelId);
309
311
  };
310
312
 
311
- const createEmbeddingModel = (modelId: BedrockEmbeddingModelId) =>
312
- new BedrockEmbeddingModel(modelId, {
313
- baseUrl: getBedrockRuntimeBaseUrl,
313
+ const createEmbeddingModel = (modelId: AmazonBedrockEmbeddingModelId) =>
314
+ new AmazonBedrockEmbeddingModel(modelId, {
315
+ baseUrl: getAmazonBedrockRuntimeBaseUrl,
314
316
  headers: getHeaders,
315
317
  fetch: fetchFunction,
316
318
  });
317
319
 
318
- const createImageModel = (modelId: BedrockImageModelId) =>
319
- new BedrockImageModel(modelId, {
320
- baseUrl: getBedrockRuntimeBaseUrl,
320
+ const createImageModel = (modelId: AmazonBedrockImageModelId) =>
321
+ new AmazonBedrockImageModel(modelId, {
322
+ baseUrl: getAmazonBedrockRuntimeBaseUrl,
321
323
  headers: getHeaders,
322
324
  fetch: fetchFunction,
323
325
  });
324
326
 
325
- const createRerankingModel = (modelId: BedrockRerankingModelId) =>
326
- new BedrockRerankingModel(modelId, {
327
- baseUrl: getBedrockAgentRuntimeBaseUrl,
327
+ const createRerankingModel = (modelId: AmazonBedrockRerankingModelId) =>
328
+ new AmazonBedrockRerankingModel(modelId, {
329
+ baseUrl: getAmazonBedrockAgentRuntimeBaseUrl,
328
330
  region: loadSetting({
329
331
  settingValue: options.region,
330
332
  settingName: 'region',
@@ -351,6 +353,6 @@ export function createAmazonBedrock(
351
353
  }
352
354
 
353
355
  /**
354
- * Default Bedrock provider instance.
356
+ * Default Amazon Bedrock provider instance.
355
357
  */
356
- export const bedrock = createAmazonBedrock();
358
+ export const amazonBedrock = createAmazonBedrock();
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod/v4';
2
+
3
+ export const amazonBedrockReasoningMetadataSchema = z.object({
4
+ signature: z.string().optional(),
5
+ redactedData: z.string().optional(),
6
+ });
7
+
8
+ export type AmazonBedrockReasoningMetadata = z.infer<
9
+ typeof amazonBedrockReasoningMetadataSchema
10
+ >;