@ai-sdk/amazon-bedrock 3.0.0-beta.12 → 3.0.0-beta.14

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.0.0-beta.14
4
+
5
+ ### Patch Changes
6
+
7
+ - f418dd7: Added anthropic provider defined tool support to amazon bedrock
8
+ - Updated dependencies [f418dd7]
9
+ - Updated dependencies [27deb4d]
10
+ - @ai-sdk/anthropic@2.0.0-beta.12
11
+ - @ai-sdk/provider@2.0.0-beta.2
12
+ - @ai-sdk/provider-utils@3.0.0-beta.9
13
+
14
+ ## 3.0.0-beta.13
15
+
16
+ ### Patch Changes
17
+
18
+ - eb173f1: chore (providers): remove model shorthand deprecation warnings
19
+ - Updated dependencies [dd5fd43]
20
+ - @ai-sdk/provider-utils@3.0.0-beta.8
21
+
3
22
  ## 3.0.0-beta.12
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { anthropicTools } from '@ai-sdk/anthropic/internal';
3
4
  import { z } from 'zod/v4';
4
5
 
5
6
  type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
@@ -96,13 +97,16 @@ interface AmazonBedrockProvider extends ProviderV2 {
96
97
  embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV2<string>;
97
98
  /**
98
99
  Creates a model for image generation.
99
- @deprecated Use `imageModel` instead.
100
100
  */
101
101
  image(modelId: BedrockImageModelId): ImageModelV2;
102
102
  /**
103
103
  Creates a model for image generation.
104
104
  */
105
105
  imageModel(modelId: BedrockImageModelId): ImageModelV2;
106
+ /**
107
+ Anthropic-specific tools that can be used with Anthropic models on Bedrock.
108
+ */
109
+ tools: typeof anthropicTools;
106
110
  }
107
111
  /**
108
112
  Create an Amazon Bedrock provider instance.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { anthropicTools } from '@ai-sdk/anthropic/internal';
3
4
  import { z } from 'zod/v4';
4
5
 
5
6
  type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
@@ -96,13 +97,16 @@ interface AmazonBedrockProvider extends ProviderV2 {
96
97
  embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV2<string>;
97
98
  /**
98
99
  Creates a model for image generation.
99
- @deprecated Use `imageModel` instead.
100
100
  */
101
101
  image(modelId: BedrockImageModelId): ImageModelV2;
102
102
  /**
103
103
  Creates a model for image generation.
104
104
  */
105
105
  imageModel(modelId: BedrockImageModelId): ImageModelV2;
106
+ /**
107
+ Anthropic-specific tools that can be used with Anthropic models on Bedrock.
108
+ */
109
+ tools: typeof anthropicTools;
106
110
  }
107
111
  /**
108
112
  Create an Amazon Bedrock provider instance.
package/dist/index.js CHANGED
@@ -26,10 +26,11 @@ __export(src_exports, {
26
26
  module.exports = __toCommonJS(src_exports);
27
27
 
28
28
  // src/bedrock-provider.ts
29
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
29
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
30
+ var import_internal2 = require("@ai-sdk/anthropic/internal");
30
31
 
31
32
  // src/bedrock-chat-language-model.ts
32
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
33
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
33
34
  var import_v43 = require("zod/v4");
34
35
 
35
36
  // src/bedrock-api-types.ts
@@ -161,95 +162,145 @@ var createBedrockEventStreamResponseHandler = (chunkSchema) => async ({ response
161
162
 
162
163
  // src/bedrock-prepare-tools.ts
163
164
  var import_provider2 = require("@ai-sdk/provider");
164
- function promptContainsToolContent(prompt) {
165
- return prompt.some((message) => {
166
- if ("content" in message && Array.isArray(message.content)) {
167
- return message.content.some(
168
- (part) => part.type === "tool-call" || part.type === "tool-result"
169
- );
170
- }
171
- return false;
172
- });
173
- }
165
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
166
+ var import_internal = require("@ai-sdk/anthropic/internal");
174
167
  function prepareTools({
175
168
  tools,
176
169
  toolChoice,
177
- prompt
170
+ modelId
178
171
  }) {
179
- tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
180
- const hasToolContent = promptContainsToolContent(prompt);
181
- if (tools == null) {
172
+ const toolWarnings = [];
173
+ const betas = /* @__PURE__ */ new Set();
174
+ if (tools == null || tools.length === 0) {
182
175
  return {
183
- toolConfig: {
184
- tools: void 0,
185
- toolChoice: void 0
186
- },
187
- toolWarnings: []
176
+ toolConfig: {},
177
+ additionalTools: void 0,
178
+ betas,
179
+ toolWarnings
188
180
  };
189
181
  }
190
- const toolWarnings = [];
191
- const bedrockTools = [];
192
- for (const tool of tools) {
193
- if (tool.type === "provider-defined") {
194
- toolWarnings.push({ type: "unsupported-tool", tool });
195
- } else {
196
- bedrockTools.push({
197
- toolSpec: {
198
- name: tool.name,
199
- description: tool.description,
200
- inputSchema: {
201
- json: tool.inputSchema
202
- }
203
- }
182
+ const supportedTools = tools.filter((tool) => {
183
+ if (tool.type === "provider-defined" && tool.id === "anthropic.web_search_20250305") {
184
+ toolWarnings.push({
185
+ type: "unsupported-tool",
186
+ tool,
187
+ details: "The web_search_20250305 tool is not supported on Amazon Bedrock."
204
188
  });
189
+ return false;
205
190
  }
206
- }
207
- if (toolChoice == null) {
191
+ return true;
192
+ });
193
+ if (supportedTools.length === 0) {
208
194
  return {
209
- toolConfig: { tools: bedrockTools, toolChoice: void 0 },
195
+ toolConfig: {},
196
+ additionalTools: void 0,
197
+ betas,
210
198
  toolWarnings
211
199
  };
212
200
  }
213
- const type = toolChoice.type;
214
- switch (type) {
215
- case "auto":
216
- return {
217
- toolConfig: { tools: bedrockTools, toolChoice: { auto: {} } },
218
- toolWarnings
219
- };
220
- case "required":
221
- return {
222
- toolConfig: { tools: bedrockTools, toolChoice: { any: {} } },
223
- toolWarnings
224
- };
225
- case "none":
226
- return {
227
- toolConfig: {
228
- tools: void 0,
229
- toolChoice: void 0
230
- },
231
- toolWarnings
232
- };
233
- case "tool":
234
- return {
235
- toolConfig: {
236
- tools: bedrockTools,
237
- toolChoice: { tool: { name: toolChoice.toolName } }
238
- },
239
- toolWarnings
201
+ const isAnthropicModel = modelId.includes("anthropic.");
202
+ const providerDefinedTools = supportedTools.filter(
203
+ (t) => t.type === "provider-defined"
204
+ );
205
+ const functionTools = supportedTools.filter((t) => t.type === "function");
206
+ let additionalTools = void 0;
207
+ const bedrockTools = [];
208
+ const usingAnthropicTools = isAnthropicModel && providerDefinedTools.length > 0;
209
+ if (usingAnthropicTools) {
210
+ if (functionTools.length > 0) {
211
+ toolWarnings.push({
212
+ type: "unsupported-setting",
213
+ setting: "tools",
214
+ details: "Mixed Anthropic provider-defined tools and standard function tools are not supported in a single call to Bedrock. Only Anthropic tools will be used."
215
+ });
216
+ }
217
+ const {
218
+ toolChoice: preparedAnthropicToolChoice,
219
+ toolWarnings: anthropicToolWarnings,
220
+ betas: anthropicBetas
221
+ } = (0, import_internal.prepareTools)({
222
+ tools: providerDefinedTools,
223
+ toolChoice
224
+ });
225
+ toolWarnings.push(...anthropicToolWarnings);
226
+ anthropicBetas.forEach((beta) => betas.add(beta));
227
+ if (preparedAnthropicToolChoice) {
228
+ additionalTools = {
229
+ tool_choice: preparedAnthropicToolChoice
240
230
  };
241
- default: {
242
- const _exhaustiveCheck = type;
243
- throw new import_provider2.UnsupportedFunctionalityError({
244
- functionality: `tool choice type: ${_exhaustiveCheck}`
231
+ }
232
+ for (const tool of providerDefinedTools) {
233
+ const toolFactory = Object.values(import_internal.anthropicTools).find((factory) => {
234
+ const instance = factory({});
235
+ return instance.id === tool.id;
245
236
  });
237
+ if (toolFactory != null) {
238
+ const fullToolDefinition = toolFactory({});
239
+ bedrockTools.push({
240
+ toolSpec: {
241
+ name: tool.name,
242
+ inputSchema: {
243
+ json: (0, import_provider_utils2.asSchema)(fullToolDefinition.inputSchema).jsonSchema
244
+ }
245
+ }
246
+ });
247
+ } else {
248
+ toolWarnings.push({ type: "unsupported-tool", tool });
249
+ }
250
+ }
251
+ } else {
252
+ for (const tool of providerDefinedTools) {
253
+ toolWarnings.push({ type: "unsupported-tool", tool });
254
+ }
255
+ }
256
+ for (const tool of functionTools) {
257
+ bedrockTools.push({
258
+ toolSpec: {
259
+ name: tool.name,
260
+ description: tool.description,
261
+ inputSchema: {
262
+ json: tool.inputSchema
263
+ }
264
+ }
265
+ });
266
+ }
267
+ let bedrockToolChoice = void 0;
268
+ if (!usingAnthropicTools && bedrockTools.length > 0 && toolChoice) {
269
+ const type = toolChoice.type;
270
+ switch (type) {
271
+ case "auto":
272
+ bedrockToolChoice = { auto: {} };
273
+ break;
274
+ case "required":
275
+ bedrockToolChoice = { any: {} };
276
+ break;
277
+ case "none":
278
+ bedrockTools.length = 0;
279
+ bedrockToolChoice = void 0;
280
+ break;
281
+ case "tool":
282
+ bedrockToolChoice = { tool: { name: toolChoice.toolName } };
283
+ break;
284
+ default: {
285
+ const _exhaustiveCheck = type;
286
+ throw new import_provider2.UnsupportedFunctionalityError({
287
+ functionality: `tool choice type: ${_exhaustiveCheck}`
288
+ });
289
+ }
246
290
  }
247
291
  }
292
+ const toolConfig = bedrockTools.length > 0 ? { tools: bedrockTools, toolChoice: bedrockToolChoice } : {};
293
+ return {
294
+ toolConfig,
295
+ additionalTools,
296
+ betas,
297
+ toolWarnings
298
+ };
248
299
  }
249
300
 
250
301
  // src/convert-to-bedrock-chat-messages.ts
251
302
  var import_provider3 = require("@ai-sdk/provider");
252
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
303
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
253
304
  function getCachePoint(providerMetadata) {
254
305
  var _a;
255
306
  return (_a = providerMetadata == null ? void 0 : providerMetadata.bedrock) == null ? void 0 : _a.cachePoint;
@@ -304,7 +355,7 @@ async function convertToBedrockChatMessages(prompt) {
304
355
  bedrockContent.push({
305
356
  image: {
306
357
  format: getBedrockImageFormat(part.mediaType),
307
- source: { bytes: (0, import_provider_utils2.convertToBase64)(part.data) }
358
+ source: { bytes: (0, import_provider_utils3.convertToBase64)(part.data) }
308
359
  }
309
360
  });
310
361
  } else {
@@ -318,7 +369,7 @@ async function convertToBedrockChatMessages(prompt) {
318
369
  document: {
319
370
  format: getBedrockDocumentFormat(part.mediaType),
320
371
  name: generateDocumentName(),
321
- source: { bytes: (0, import_provider_utils2.convertToBase64)(part.data) }
372
+ source: { bytes: (0, import_provider_utils3.convertToBase64)(part.data) }
322
373
  }
323
374
  });
324
375
  }
@@ -417,7 +468,7 @@ async function convertToBedrockChatMessages(prompt) {
417
468
  break;
418
469
  }
419
470
  case "reasoning": {
420
- const reasoningMetadata = await (0, import_provider_utils2.parseProviderOptions)({
471
+ const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
421
472
  provider: "bedrock",
422
473
  providerOptions: part.providerOptions,
423
474
  schema: bedrockReasoningMetadataSchema
@@ -599,8 +650,8 @@ var BedrockChatLanguageModel = class {
599
650
  toolChoice,
600
651
  providerOptions
601
652
  }) {
602
- var _a, _b, _c, _d;
603
- const bedrockOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
653
+ var _a, _b, _c, _d, _e, _f;
654
+ const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
604
655
  provider: "bedrock",
605
656
  providerOptions,
606
657
  schema: bedrockProviderOptions
@@ -651,6 +702,18 @@ var BedrockChatLanguageModel = class {
651
702
  description: "Respond with a JSON object.",
652
703
  inputSchema: responseFormat.schema
653
704
  } : void 0;
705
+ const { toolConfig, additionalTools, toolWarnings, betas } = prepareTools({
706
+ tools: jsonResponseTool ? [jsonResponseTool, ...tools != null ? tools : []] : tools,
707
+ toolChoice: jsonResponseTool != null ? { type: "tool", toolName: jsonResponseTool.name } : toolChoice,
708
+ modelId: this.modelId
709
+ });
710
+ warnings.push(...toolWarnings);
711
+ if (additionalTools) {
712
+ bedrockOptions.additionalModelRequestFields = {
713
+ ...bedrockOptions.additionalModelRequestFields,
714
+ ...additionalTools
715
+ };
716
+ }
654
717
  const isThinking = ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.type) === "enabled";
655
718
  const thinkingBudget = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.budgetTokens;
656
719
  const inferenceConfig = {
@@ -689,9 +752,9 @@ var BedrockChatLanguageModel = class {
689
752
  details: "topP is not supported when thinking is enabled"
690
753
  });
691
754
  }
692
- const activeTools = jsonResponseTool != null ? [jsonResponseTool] : tools != null ? tools : [];
755
+ const hasAnyTools = ((_f = (_e = toolConfig.tools) == null ? void 0 : _e.length) != null ? _f : 0) > 0 || additionalTools;
693
756
  let filteredPrompt = prompt;
694
- if (activeTools.length === 0) {
757
+ if (!hasAnyTools) {
695
758
  const hasToolContent = prompt.some(
696
759
  (message) => "content" in message && Array.isArray(message.content) && message.content.some(
697
760
  (part) => part.type === "tool-call" || part.type === "tool-result"
@@ -716,11 +779,6 @@ var BedrockChatLanguageModel = class {
716
779
  }
717
780
  }
718
781
  const { system, messages } = await convertToBedrockChatMessages(filteredPrompt);
719
- const { toolConfig, toolWarnings } = prepareTools({
720
- tools: activeTools,
721
- toolChoice: jsonResponseTool != null ? { type: "tool", toolName: jsonResponseTool.name } : toolChoice,
722
- prompt: filteredPrompt
723
- });
724
782
  const { reasoningConfig: _, ...filteredBedrockOptions } = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
725
783
  return {
726
784
  command: {
@@ -731,35 +789,44 @@ var BedrockChatLanguageModel = class {
731
789
  inferenceConfig
732
790
  },
733
791
  ...filteredBedrockOptions,
734
- ...toolConfig.tools !== void 0 ? { toolConfig } : {}
792
+ ...toolConfig.tools !== void 0 && toolConfig.tools.length > 0 ? { toolConfig } : {}
735
793
  },
736
- warnings: [...warnings, ...toolWarnings],
737
- usesJsonResponseTool: jsonResponseTool != null
794
+ warnings,
795
+ usesJsonResponseTool: jsonResponseTool != null,
796
+ betas
738
797
  };
739
798
  }
799
+ async getHeaders({
800
+ betas,
801
+ headers
802
+ }) {
803
+ return (0, import_provider_utils4.combineHeaders)(
804
+ await (0, import_provider_utils4.resolve)(this.config.headers),
805
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
806
+ headers
807
+ );
808
+ }
740
809
  async doGenerate(options) {
741
810
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
742
811
  const {
743
812
  command: args,
744
813
  warnings,
745
- usesJsonResponseTool
814
+ usesJsonResponseTool,
815
+ betas
746
816
  } = await this.getArgs(options);
747
817
  const url = `${this.getUrl(this.modelId)}/converse`;
748
- const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
818
+ const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
749
819
  url,
750
- headers: (0, import_provider_utils3.combineHeaders)(
751
- await (0, import_provider_utils3.resolve)(this.config.headers),
752
- options.headers
753
- ),
820
+ headers: await this.getHeaders({ betas, headers: options.headers }),
754
821
  body: args,
755
- failedResponseHandler: (0, import_provider_utils3.createJsonErrorResponseHandler)({
822
+ failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
756
823
  errorSchema: BedrockErrorSchema,
757
824
  errorToMessage: (error) => {
758
825
  var _a2;
759
826
  return `${(_a2 = error.message) != null ? _a2 : "Unknown error"}`;
760
827
  }
761
828
  }),
762
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
829
+ successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
763
830
  BedrockResponseSchema
764
831
  ),
765
832
  abortSignal: options.abortSignal,
@@ -847,17 +914,15 @@ var BedrockChatLanguageModel = class {
847
914
  const {
848
915
  command: args,
849
916
  warnings,
850
- usesJsonResponseTool
917
+ usesJsonResponseTool,
918
+ betas
851
919
  } = await this.getArgs(options);
852
920
  const url = `${this.getUrl(this.modelId)}/converse-stream`;
853
- const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
921
+ const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
854
922
  url,
855
- headers: (0, import_provider_utils3.combineHeaders)(
856
- await (0, import_provider_utils3.resolve)(this.config.headers),
857
- options.headers
858
- ),
923
+ headers: await this.getHeaders({ betas, headers: options.headers }),
859
924
  body: args,
860
- failedResponseHandler: (0, import_provider_utils3.createJsonErrorResponseHandler)({
925
+ failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
861
926
  errorSchema: BedrockErrorSchema,
862
927
  errorToMessage: (error) => `${error.type}: ${error.message}`
863
928
  }),
@@ -1209,7 +1274,7 @@ var bedrockReasoningMetadataSchema = import_v43.z.object({
1209
1274
 
1210
1275
  // src/bedrock-embedding-model.ts
1211
1276
  var import_provider4 = require("@ai-sdk/provider");
1212
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
1277
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
1213
1278
 
1214
1279
  // src/bedrock-embedding-options.ts
1215
1280
  var import_v44 = require("zod/v4");
@@ -1256,7 +1321,7 @@ var BedrockEmbeddingModel = class {
1256
1321
  values
1257
1322
  });
1258
1323
  }
1259
- const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
1324
+ const bedrockOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
1260
1325
  provider: "bedrock",
1261
1326
  providerOptions,
1262
1327
  schema: bedrockEmbeddingProviderOptions
@@ -1267,17 +1332,17 @@ var BedrockEmbeddingModel = class {
1267
1332
  normalize: bedrockOptions.normalize
1268
1333
  };
1269
1334
  const url = this.getUrl(this.modelId);
1270
- const { value: response } = await (0, import_provider_utils4.postJsonToApi)({
1335
+ const { value: response } = await (0, import_provider_utils5.postJsonToApi)({
1271
1336
  url,
1272
- headers: await (0, import_provider_utils4.resolve)(
1273
- (0, import_provider_utils4.combineHeaders)(await (0, import_provider_utils4.resolve)(this.config.headers), headers)
1337
+ headers: await (0, import_provider_utils5.resolve)(
1338
+ (0, import_provider_utils5.combineHeaders)(await (0, import_provider_utils5.resolve)(this.config.headers), headers)
1274
1339
  ),
1275
1340
  body: args,
1276
- failedResponseHandler: (0, import_provider_utils4.createJsonErrorResponseHandler)({
1341
+ failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
1277
1342
  errorSchema: BedrockErrorSchema,
1278
1343
  errorToMessage: (error) => `${error.type}: ${error.message}`
1279
1344
  }),
1280
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1345
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1281
1346
  BedrockEmbeddingResponseSchema
1282
1347
  ),
1283
1348
  fetch: this.config.fetch,
@@ -1295,7 +1360,7 @@ var BedrockEmbeddingResponseSchema = import_v45.z.object({
1295
1360
  });
1296
1361
 
1297
1362
  // src/bedrock-image-model.ts
1298
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1363
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1299
1364
 
1300
1365
  // src/bedrock-image-settings.ts
1301
1366
  var modelMaxImagesPerCall = {
@@ -1360,17 +1425,17 @@ var BedrockImageModel = class {
1360
1425
  });
1361
1426
  }
1362
1427
  const currentDate = (_g = (_f = (_e = this.config._internal) == null ? void 0 : _e.currentDate) == null ? void 0 : _f.call(_e)) != null ? _g : /* @__PURE__ */ new Date();
1363
- const { value: response, responseHeaders } = await (0, import_provider_utils5.postJsonToApi)({
1428
+ const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
1364
1429
  url: this.getUrl(this.modelId),
1365
- headers: await (0, import_provider_utils5.resolve)(
1366
- (0, import_provider_utils5.combineHeaders)(await (0, import_provider_utils5.resolve)(this.config.headers), headers)
1430
+ headers: await (0, import_provider_utils6.resolve)(
1431
+ (0, import_provider_utils6.combineHeaders)(await (0, import_provider_utils6.resolve)(this.config.headers), headers)
1367
1432
  ),
1368
1433
  body: args,
1369
- failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
1434
+ failedResponseHandler: (0, import_provider_utils6.createJsonErrorResponseHandler)({
1370
1435
  errorSchema: BedrockErrorSchema,
1371
1436
  errorToMessage: (error) => `${error.type}: ${error.message}`
1372
1437
  }),
1373
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1438
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1374
1439
  bedrockImageResponseSchema
1375
1440
  ),
1376
1441
  abortSignal,
@@ -1414,7 +1479,7 @@ function convertHeadersToRecord(headers) {
1414
1479
  }
1415
1480
 
1416
1481
  // src/bedrock-sigv4-fetch.ts
1417
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1482
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1418
1483
  var import_aws4fetch = require("aws4fetch");
1419
1484
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
1420
1485
  return async (input, init) => {
@@ -1429,7 +1494,7 @@ function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
1429
1494
  const signer = new import_aws4fetch.AwsV4Signer({
1430
1495
  url,
1431
1496
  method: "POST",
1432
- headers: Object.entries((0, import_provider_utils6.removeUndefinedEntries)(originalHeaders)),
1497
+ headers: Object.entries((0, import_provider_utils7.removeUndefinedEntries)(originalHeaders)),
1433
1498
  body,
1434
1499
  region: credentials.region,
1435
1500
  accessKeyId: credentials.accessKeyId,
@@ -1442,8 +1507,8 @@ function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
1442
1507
  return fetch(input, {
1443
1508
  ...init,
1444
1509
  body,
1445
- headers: (0, import_provider_utils6.removeUndefinedEntries)(
1446
- (0, import_provider_utils6.combineHeaders)(originalHeaders, signedHeaders)
1510
+ headers: (0, import_provider_utils7.removeUndefinedEntries)(
1511
+ (0, import_provider_utils7.combineHeaders)(originalHeaders, signedHeaders)
1447
1512
  )
1448
1513
  });
1449
1514
  };
@@ -1464,8 +1529,8 @@ function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
1464
1529
  const originalHeaders = extractHeaders(init == null ? void 0 : init.headers);
1465
1530
  return fetch(input, {
1466
1531
  ...init,
1467
- headers: (0, import_provider_utils6.removeUndefinedEntries)(
1468
- (0, import_provider_utils6.combineHeaders)(originalHeaders, {
1532
+ headers: (0, import_provider_utils7.removeUndefinedEntries)(
1533
+ (0, import_provider_utils7.combineHeaders)(originalHeaders, {
1469
1534
  Authorization: `Bearer ${apiKey}`
1470
1535
  })
1471
1536
  )
@@ -1475,13 +1540,13 @@ function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
1475
1540
 
1476
1541
  // src/bedrock-provider.ts
1477
1542
  function createAmazonBedrock(options = {}) {
1478
- const rawApiKey = (0, import_provider_utils7.loadOptionalSetting)({
1543
+ const rawApiKey = (0, import_provider_utils8.loadOptionalSetting)({
1479
1544
  settingValue: options.apiKey,
1480
1545
  environmentVariableName: "AWS_BEARER_TOKEN_BEDROCK"
1481
1546
  });
1482
1547
  const apiKey = rawApiKey && rawApiKey.trim().length > 0 ? rawApiKey.trim() : void 0;
1483
1548
  const fetchFunction = apiKey ? createApiKeyFetchFunction(apiKey, options.fetch) : createSigV4FetchFunction(async () => {
1484
- const region = (0, import_provider_utils7.loadSetting)({
1549
+ const region = (0, import_provider_utils8.loadSetting)({
1485
1550
  settingValue: options.region,
1486
1551
  settingName: "region",
1487
1552
  environmentVariableName: "AWS_REGION",
@@ -1503,19 +1568,19 @@ function createAmazonBedrock(options = {}) {
1503
1568
  try {
1504
1569
  return {
1505
1570
  region,
1506
- accessKeyId: (0, import_provider_utils7.loadSetting)({
1571
+ accessKeyId: (0, import_provider_utils8.loadSetting)({
1507
1572
  settingValue: options.accessKeyId,
1508
1573
  settingName: "accessKeyId",
1509
1574
  environmentVariableName: "AWS_ACCESS_KEY_ID",
1510
1575
  description: "AWS access key ID"
1511
1576
  }),
1512
- secretAccessKey: (0, import_provider_utils7.loadSetting)({
1577
+ secretAccessKey: (0, import_provider_utils8.loadSetting)({
1513
1578
  settingValue: options.secretAccessKey,
1514
1579
  settingName: "secretAccessKey",
1515
1580
  environmentVariableName: "AWS_SECRET_ACCESS_KEY",
1516
1581
  description: "AWS secret access key"
1517
1582
  }),
1518
- sessionToken: (0, import_provider_utils7.loadOptionalSetting)({
1583
+ sessionToken: (0, import_provider_utils8.loadOptionalSetting)({
1519
1584
  settingValue: options.sessionToken,
1520
1585
  environmentVariableName: "AWS_SESSION_TOKEN"
1521
1586
  })
@@ -1543,8 +1608,8 @@ Original error: ${errorMessage}`
1543
1608
  }, options.fetch);
1544
1609
  const getBaseUrl = () => {
1545
1610
  var _a, _b;
1546
- return (_b = (0, import_provider_utils7.withoutTrailingSlash)(
1547
- (_a = options.baseURL) != null ? _a : `https://bedrock-runtime.${(0, import_provider_utils7.loadSetting)({
1611
+ return (_b = (0, import_provider_utils8.withoutTrailingSlash)(
1612
+ (_a = options.baseURL) != null ? _a : `https://bedrock-runtime.${(0, import_provider_utils8.loadSetting)({
1548
1613
  settingValue: options.region,
1549
1614
  settingName: "region",
1550
1615
  environmentVariableName: "AWS_REGION",
@@ -1558,7 +1623,7 @@ Original error: ${errorMessage}`
1558
1623
  baseUrl: getBaseUrl,
1559
1624
  headers: (_a = options.headers) != null ? _a : {},
1560
1625
  fetch: fetchFunction,
1561
- generateId: import_provider_utils7.generateId
1626
+ generateId: import_provider_utils8.generateId
1562
1627
  });
1563
1628
  };
1564
1629
  const provider = function(modelId) {
@@ -1591,6 +1656,7 @@ Original error: ${errorMessage}`
1591
1656
  provider.textEmbeddingModel = createEmbeddingModel;
1592
1657
  provider.image = createImageModel;
1593
1658
  provider.imageModel = createImageModel;
1659
+ provider.tools = import_internal2.anthropicTools;
1594
1660
  return provider;
1595
1661
  }
1596
1662
  var bedrock = createAmazonBedrock();