@ai-sdk/amazon-bedrock 4.0.163 → 4.0.166

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,37 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 4.0.166
4
+
5
+ ### Patch Changes
6
+
7
+ - ada21b6: Omit assistant messages when only cache points remain after unsigned reasoning is filtered.
8
+ - fb9b783: feat(amazon-bedrock): add model family setting for embeddings to support ARN
9
+ - 6b88988: Accept citation deltas in Amazon Bedrock streaming responses.
10
+ - 06cc1cb: Enable Anthropic reasoning budgets for application inference profile ARNs.
11
+ - Updated dependencies [cc23556]
12
+ - @ai-sdk/provider-utils@4.0.50
13
+ - @ai-sdk/anthropic@3.0.115
14
+ - @ai-sdk/openai@3.0.105
15
+
16
+ ## 4.0.165
17
+
18
+ ### Patch Changes
19
+
20
+ - da1ce8f: Forward the Anthropic option for disabling parallel tool use through Amazon Bedrock without sending conflicting tool choice fields.
21
+ - Updated dependencies [426c9b3]
22
+ - Updated dependencies [34d045d]
23
+ - @ai-sdk/openai@3.0.104
24
+
25
+ ## 4.0.164
26
+
27
+ ### Patch Changes
28
+
29
+ - d69e9a1: Omit assistant messages that become empty after unsupported reasoning content is removed.
30
+ - Updated dependencies [9a521b9]
31
+ - @ai-sdk/openai@3.0.103
32
+ - @ai-sdk/provider-utils@4.0.49
33
+ - @ai-sdk/anthropic@3.0.114
34
+
3
35
  ## 4.0.163
4
36
 
5
37
  ### Patch Changes
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
35
35
  var import_aws4fetch = require("aws4fetch");
36
36
 
37
37
  // src/version.ts
38
- var VERSION = true ? "4.0.163" : "0.0.0-test";
38
+ var VERSION = true ? "4.0.166" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "4.0.163" : "0.0.0-test";
27
+ var VERSION = true ? "4.0.166" : "0.0.0-test";
28
28
 
29
29
  // src/bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
package/dist/index.d.mts CHANGED
@@ -5,6 +5,15 @@ import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, RerankingM
5
5
  import { FetchFunction } from '@ai-sdk/provider-utils';
6
6
 
7
7
  type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
8
+ type AmazonBedrockEmbeddingModelSettings = {
9
+ /**
10
+ * The embedding model family.
11
+ *
12
+ * Specify this when the model ID does not identify the underlying model,
13
+ * such as an application inference profile ARN.
14
+ */
15
+ modelFamily?: 'titan' | 'cohere' | 'nova';
16
+ };
8
17
  declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
9
18
  dimensions: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1024>, z.ZodLiteral<512>, z.ZodLiteral<256>]>>;
10
19
  normalize: z.ZodOptional<z.ZodBoolean>;
@@ -159,19 +168,19 @@ interface AmazonBedrockProvider extends ProviderV3 {
159
168
  /**
160
169
  * Creates a model for text embeddings.
161
170
  */
162
- embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
171
+ embedding(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
163
172
  /**
164
173
  * Creates a model for text embeddings.
165
174
  */
166
- embeddingModel(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
175
+ embeddingModel(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
167
176
  /**
168
177
  * @deprecated Use `embedding` instead.
169
178
  */
170
- textEmbedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
179
+ textEmbedding(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
171
180
  /**
172
181
  * @deprecated Use `embeddingModel` instead.
173
182
  */
174
- textEmbeddingModel(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
183
+ textEmbeddingModel(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
175
184
  /**
176
185
  * Creates a model for image generation.
177
186
  */
@@ -204,4 +213,4 @@ declare const bedrock: AmazonBedrockProvider;
204
213
 
205
214
  declare const VERSION: string;
206
215
 
207
- export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
216
+ export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockEmbeddingModelSettings, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,15 @@ import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, RerankingM
5
5
  import { FetchFunction } from '@ai-sdk/provider-utils';
6
6
 
7
7
  type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
8
+ type AmazonBedrockEmbeddingModelSettings = {
9
+ /**
10
+ * The embedding model family.
11
+ *
12
+ * Specify this when the model ID does not identify the underlying model,
13
+ * such as an application inference profile ARN.
14
+ */
15
+ modelFamily?: 'titan' | 'cohere' | 'nova';
16
+ };
8
17
  declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
9
18
  dimensions: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1024>, z.ZodLiteral<512>, z.ZodLiteral<256>]>>;
10
19
  normalize: z.ZodOptional<z.ZodBoolean>;
@@ -159,19 +168,19 @@ interface AmazonBedrockProvider extends ProviderV3 {
159
168
  /**
160
169
  * Creates a model for text embeddings.
161
170
  */
162
- embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
171
+ embedding(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
163
172
  /**
164
173
  * Creates a model for text embeddings.
165
174
  */
166
- embeddingModel(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
175
+ embeddingModel(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
167
176
  /**
168
177
  * @deprecated Use `embedding` instead.
169
178
  */
170
- textEmbedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
179
+ textEmbedding(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
171
180
  /**
172
181
  * @deprecated Use `embeddingModel` instead.
173
182
  */
174
- textEmbeddingModel(modelId: BedrockEmbeddingModelId): EmbeddingModelV3;
183
+ textEmbeddingModel(modelId: BedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV3;
175
184
  /**
176
185
  * Creates a model for image generation.
177
186
  */
@@ -204,4 +213,4 @@ declare const bedrock: AmazonBedrockProvider;
204
213
 
205
214
  declare const VERSION: string;
206
215
 
207
- export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
216
+ export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockEmbeddingModelSettings, type AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, bedrock, createAmazonBedrock };
package/dist/index.js CHANGED
@@ -241,7 +241,8 @@ var import_internal = require("@ai-sdk/anthropic/internal");
241
241
  async function prepareTools({
242
242
  tools,
243
243
  toolChoice,
244
- modelId
244
+ modelId,
245
+ disableParallelToolUse
245
246
  }) {
246
247
  var _a;
247
248
  const toolWarnings = [];
@@ -287,6 +288,7 @@ async function prepareTools({
287
288
  } = await (0, import_internal.prepareTools)({
288
289
  tools: ProviderTools,
289
290
  toolChoice,
291
+ disableParallelToolUse,
290
292
  supportsStructuredOutput: false,
291
293
  supportsStrictTools: false
292
294
  });
@@ -342,8 +344,17 @@ async function prepareTools({
342
344
  }
343
345
  });
344
346
  }
347
+ if (isAnthropicModel && !usingAnthropicTools && disableParallelToolUse && bedrockTools.length > 0 && (toolChoice == null ? void 0 : toolChoice.type) !== "none") {
348
+ additionalTools = {
349
+ tool_choice: (toolChoice == null ? void 0 : toolChoice.type) === "required" ? { type: "any", disable_parallel_tool_use: true } : (toolChoice == null ? void 0 : toolChoice.type) === "tool" ? {
350
+ type: "tool",
351
+ name: toolChoice.toolName,
352
+ disable_parallel_tool_use: true
353
+ } : { type: "auto", disable_parallel_tool_use: true }
354
+ };
355
+ }
345
356
  let bedrockToolChoice = void 0;
346
- if (!usingAnthropicTools && bedrockTools.length > 0 && toolChoice) {
357
+ if (!usingAnthropicTools && (additionalTools == null ? void 0 : additionalTools.tool_choice) == null && bedrockTools.length > 0 && toolChoice) {
347
358
  const type = toolChoice.type;
348
359
  switch (type) {
349
360
  case "auto":
@@ -688,7 +699,12 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
688
699
  }
689
700
  pushCachePoint(bedrockContent, providerOptions);
690
701
  }
691
- messages.push({ role: "user", content: bedrockContent });
702
+ const previousMessage = messages.at(-1);
703
+ if ((previousMessage == null ? void 0 : previousMessage.role) === "user") {
704
+ previousMessage.content.push(...bedrockContent);
705
+ } else {
706
+ messages.push({ role: "user", content: bedrockContent });
707
+ }
692
708
  break;
693
709
  }
694
710
  case "assistant": {
@@ -697,15 +713,56 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
697
713
  const message = block.messages[j];
698
714
  const isLastMessage = j === block.messages.length - 1;
699
715
  const { content } = message;
700
- const hasReasoningBlocks = content.some(
701
- (part) => part.type === "reasoning"
716
+ const convertedReasoningContent = await Promise.all(
717
+ content.map(async (part) => {
718
+ if (part.type !== "reasoning") {
719
+ return void 0;
720
+ }
721
+ const metadata = await (0, import_provider_utils3.parseProviderOptions)({
722
+ provider: "bedrock",
723
+ providerOptions: part.providerOptions,
724
+ schema: bedrockReasoningMetadataSchema
725
+ });
726
+ if ((metadata == null ? void 0 : metadata.signature) != null) {
727
+ return {
728
+ reasoningContent: {
729
+ reasoningText: {
730
+ // do not trim reasoning text when a signature is present:
731
+ // the signature validates the exact original bytes
732
+ text: part.text,
733
+ signature: metadata.signature
734
+ }
735
+ }
736
+ };
737
+ }
738
+ if ((metadata == null ? void 0 : metadata.redactedContent) != null) {
739
+ return {
740
+ reasoningContent: {
741
+ redactedContent: metadata.redactedContent
742
+ }
743
+ };
744
+ }
745
+ if ((metadata == null ? void 0 : metadata.redactedData) != null) {
746
+ return {
747
+ reasoningContent: {
748
+ redactedReasoning: {
749
+ data: metadata.redactedData
750
+ }
751
+ }
752
+ };
753
+ }
754
+ return void 0;
755
+ })
756
+ );
757
+ const hasReplayableReasoningBlocks = convertedReasoningContent.some(
758
+ (part) => part != null
702
759
  );
703
760
  for (let k = 0; k < content.length; k++) {
704
761
  const part = content[k];
705
762
  const isLastContentPart = k === content.length - 1;
706
763
  switch (part.type) {
707
764
  case "text": {
708
- if (!part.text.trim() && !hasReasoningBlocks) {
765
+ if (!part.text.trim() && !hasReplayableReasoningBlocks) {
709
766
  break;
710
767
  }
711
768
  bedrockContent.push({
@@ -724,34 +781,9 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
724
781
  break;
725
782
  }
726
783
  case "reasoning": {
727
- const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
728
- provider: "bedrock",
729
- providerOptions: part.providerOptions,
730
- schema: bedrockReasoningMetadataSchema
731
- });
732
- if ((reasoningMetadata == null ? void 0 : reasoningMetadata.signature) != null) {
733
- bedrockContent.push({
734
- reasoningContent: {
735
- reasoningText: {
736
- text: part.text,
737
- signature: reasoningMetadata.signature
738
- }
739
- }
740
- });
741
- } else if ((reasoningMetadata == null ? void 0 : reasoningMetadata.redactedContent) != null) {
742
- bedrockContent.push({
743
- reasoningContent: {
744
- redactedContent: reasoningMetadata.redactedContent
745
- }
746
- });
747
- } else if ((reasoningMetadata == null ? void 0 : reasoningMetadata.redactedData) != null) {
748
- bedrockContent.push({
749
- reasoningContent: {
750
- redactedReasoning: {
751
- data: reasoningMetadata.redactedData
752
- }
753
- }
754
- });
784
+ const convertedPart = convertedReasoningContent[k];
785
+ if (convertedPart != null) {
786
+ bedrockContent.push(convertedPart);
755
787
  }
756
788
  break;
757
789
  }
@@ -770,7 +802,9 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
770
802
  }
771
803
  pushCachePoint(bedrockContent, message.providerOptions);
772
804
  }
773
- messages.push({ role: "assistant", content: bedrockContent });
805
+ if (bedrockContent.some((block2) => !("cachePoint" in block2))) {
806
+ messages.push({ role: "assistant", content: bedrockContent });
807
+ }
774
808
  break;
775
809
  }
776
810
  default: {
@@ -879,6 +913,9 @@ function mapBedrockFinishReason(finishReason, isJsonResponseFromTool) {
879
913
  }
880
914
 
881
915
  // src/bedrock-chat-language-model.ts
916
+ var anthropicProviderOptions = import_v44.z.object({
917
+ disableParallelToolUse: import_v44.z.boolean().optional()
918
+ });
882
919
  var BedrockChatLanguageModel = class {
883
920
  constructor(modelId, config) {
884
921
  this.modelId = modelId;
@@ -904,12 +941,17 @@ var BedrockChatLanguageModel = class {
904
941
  toolChoice,
905
942
  providerOptions
906
943
  }) {
907
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
944
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
908
945
  const bedrockOptions = (_a = await (0, import_provider_utils4.parseProviderOptions)({
909
946
  provider: "bedrock",
910
947
  providerOptions,
911
948
  schema: amazonBedrockLanguageModelOptions
912
949
  })) != null ? _a : {};
950
+ const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
951
+ provider: "anthropic",
952
+ providerOptions,
953
+ schema: anthropicProviderOptions
954
+ });
913
955
  const warnings = [];
914
956
  if (frequencyPenalty != null) {
915
957
  warnings.push({
@@ -951,11 +993,11 @@ var BedrockChatLanguageModel = class {
951
993
  details: "Only text and json response formats are supported."
952
994
  });
953
995
  }
954
- const isAnthropicModel = this.modelId.includes("anthropic");
955
- const openAIModelId = (_b = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _b[1];
996
+ const isAnthropicModel = this.modelId.includes("anthropic") || this.modelId.includes(":application-inference-profile/") && ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.budgetTokens) != null;
997
+ const openAIModelId = (_c = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _c[1];
956
998
  const isOpenAIModel = openAIModelId != null;
957
- const isOpenAIGptOssModel = (_c = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _c : false;
958
- const isThinkingEnabled = ((_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.type) === "enabled" || ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "adaptive";
999
+ const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
1000
+ const isThinkingEnabled = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
959
1001
  const { supportsStructuredOutput: modelSupportsStructuredOutput } = (0, import_internal2.getModelCapabilities)(this.modelId);
960
1002
  const useNativeStructuredOutput = isAnthropicModel && supportsNativeStructuredOutput(this.modelId) && (modelSupportsStructuredOutput || isThinkingEnabled) && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null;
961
1003
  const useJsonInstructionForStructuredOutput = isAnthropicModel && !supportsStrictTools(this.modelId) && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && tools != null && tools.length > 0;
@@ -968,7 +1010,8 @@ var BedrockChatLanguageModel = class {
968
1010
  const { toolConfig, additionalTools, toolWarnings, betas } = await prepareTools({
969
1011
  tools: jsonResponseTool ? [...tools != null ? tools : [], jsonResponseTool] : tools,
970
1012
  toolChoice: jsonResponseTool != null ? { type: "required" } : toolChoice,
971
- modelId: this.modelId
1013
+ modelId: this.modelId,
1014
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
972
1015
  });
973
1016
  warnings.push(...toolWarnings);
974
1017
  if (additionalTools) {
@@ -978,16 +1021,16 @@ var BedrockChatLanguageModel = class {
978
1021
  };
979
1022
  }
980
1023
  if (betas.size > 0 || bedrockOptions.anthropicBeta) {
981
- const existingBetas = (_f = bedrockOptions.anthropicBeta) != null ? _f : [];
1024
+ const existingBetas = (_g = bedrockOptions.anthropicBeta) != null ? _g : [];
982
1025
  const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
983
1026
  bedrockOptions.additionalModelRequestFields = {
984
1027
  ...bedrockOptions.additionalModelRequestFields,
985
1028
  anthropic_beta: mergedBetas
986
1029
  };
987
1030
  }
988
- const thinkingType = (_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type;
989
- const thinkingBudget = thinkingType === "enabled" ? (_h = bedrockOptions.reasoningConfig) == null ? void 0 : _h.budgetTokens : void 0;
990
- const thinkingDisplay = thinkingType === "adaptive" ? (_i = bedrockOptions.reasoningConfig) == null ? void 0 : _i.display : void 0;
1031
+ const thinkingType = (_h = bedrockOptions.reasoningConfig) == null ? void 0 : _h.type;
1032
+ const thinkingBudget = thinkingType === "enabled" ? (_i = bedrockOptions.reasoningConfig) == null ? void 0 : _i.budgetTokens : void 0;
1033
+ const thinkingDisplay = thinkingType === "adaptive" ? (_j = bedrockOptions.reasoningConfig) == null ? void 0 : _j.display : void 0;
991
1034
  const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingEnabled;
992
1035
  const inferenceConfig = {
993
1036
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
@@ -1020,7 +1063,7 @@ var BedrockChatLanguageModel = class {
1020
1063
  };
1021
1064
  }
1022
1065
  } else if (!isAnthropicModel) {
1023
- if (((_j = bedrockOptions.reasoningConfig) == null ? void 0 : _j.budgetTokens) != null) {
1066
+ if (((_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.budgetTokens) != null) {
1024
1067
  warnings.push({
1025
1068
  type: "unsupported",
1026
1069
  feature: "budgetTokens",
@@ -1035,13 +1078,13 @@ var BedrockChatLanguageModel = class {
1035
1078
  });
1036
1079
  }
1037
1080
  }
1038
- const maxReasoningEffort = (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.maxReasoningEffort;
1081
+ const maxReasoningEffort = (_l = bedrockOptions.reasoningConfig) == null ? void 0 : _l.maxReasoningEffort;
1039
1082
  if (maxReasoningEffort != null) {
1040
1083
  if (isAnthropicModel) {
1041
1084
  bedrockOptions.additionalModelRequestFields = {
1042
1085
  ...bedrockOptions.additionalModelRequestFields,
1043
1086
  output_config: {
1044
- ...(_l = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _l.output_config,
1087
+ ...(_m = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _m.output_config,
1045
1088
  effort: maxReasoningEffort
1046
1089
  }
1047
1090
  };
@@ -1052,7 +1095,7 @@ var BedrockChatLanguageModel = class {
1052
1095
  } : {
1053
1096
  ...bedrockOptions.additionalModelRequestFields,
1054
1097
  reasoning: {
1055
- ...(_m = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _m.reasoning,
1098
+ ...(_n = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _n.reasoning,
1056
1099
  effort: maxReasoningEffort
1057
1100
  }
1058
1101
  };
@@ -1071,7 +1114,7 @@ var BedrockChatLanguageModel = class {
1071
1114
  bedrockOptions.additionalModelRequestFields = {
1072
1115
  ...bedrockOptions.additionalModelRequestFields,
1073
1116
  output_config: {
1074
- ...(_n = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _n.output_config,
1117
+ ...(_o = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _o.output_config,
1075
1118
  format: {
1076
1119
  type: "json_schema",
1077
1120
  schema: (0, import_internal2.sanitizeJsonSchema)(responseFormat.schema)
@@ -1103,7 +1146,7 @@ var BedrockChatLanguageModel = class {
1103
1146
  details: "topK is not supported when thinking is enabled"
1104
1147
  });
1105
1148
  }
1106
- const hasAnyTools = ((_p = (_o = toolConfig.tools) == null ? void 0 : _o.length) != null ? _p : 0) > 0 || additionalTools;
1149
+ const hasAnyTools = ((_q = (_p = toolConfig.tools) == null ? void 0 : _p.length) != null ? _q : 0) > 0 || additionalTools;
1107
1150
  let filteredPrompt = prompt;
1108
1151
  if (!hasAnyTools) {
1109
1152
  const hasToolContent = prompt.some(
@@ -1786,6 +1829,9 @@ var BedrockStreamSchema = import_v44.z.object({
1786
1829
  contentBlockIndex: import_v44.z.number(),
1787
1830
  delta: import_v44.z.union([
1788
1831
  import_v44.z.object({ text: import_v44.z.string() }),
1832
+ import_v44.z.object({
1833
+ citation: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown())
1834
+ }),
1789
1835
  import_v44.z.object({ toolUse: import_v44.z.object({ input: import_v44.z.string() }) }),
1790
1836
  import_v44.z.object({
1791
1837
  reasoningContent: import_v44.z.object({ text: import_v44.z.string() })
@@ -1906,7 +1952,11 @@ var BedrockEmbeddingModel = class {
1906
1952
  this.supportsParallelCalls = true;
1907
1953
  }
1908
1954
  get maxEmbeddingsPerCall() {
1909
- return isCohereEmbeddingModel(this.modelId) ? 96 : 1;
1955
+ return this.modelFamily === "cohere" ? 96 : 1;
1956
+ }
1957
+ get modelFamily() {
1958
+ var _a;
1959
+ return (_a = this.config.modelFamily) != null ? _a : detectEmbeddingModelFamily(this.modelId);
1910
1960
  }
1911
1961
  getUrl(modelId) {
1912
1962
  const encodedModelId = encodeURIComponent(modelId);
@@ -1932,9 +1982,8 @@ var BedrockEmbeddingModel = class {
1932
1982
  providerOptions,
1933
1983
  schema: amazonBedrockEmbeddingModelOptionsSchema
1934
1984
  })) != null ? _a : {};
1935
- const isNovaModel = isNovaEmbeddingModel(this.modelId);
1936
- const isCohereModel = isCohereEmbeddingModel(this.modelId);
1937
- const args = isNovaModel ? {
1985
+ const modelFamily = this.modelFamily;
1986
+ const args = modelFamily === "nova" ? {
1938
1987
  taskType: "SINGLE_EMBEDDING",
1939
1988
  singleEmbeddingParams: {
1940
1989
  embeddingPurpose: (_b = bedrockOptions.embeddingPurpose) != null ? _b : "GENERIC_INDEX",
@@ -1944,7 +1993,7 @@ var BedrockEmbeddingModel = class {
1944
1993
  value: values[0]
1945
1994
  }
1946
1995
  }
1947
- } : isCohereModel ? {
1996
+ } : modelFamily === "cohere" ? {
1948
1997
  // Cohere embedding models on Bedrock require `input_type`.
1949
1998
  // Without it, the service attempts other schema branches and rejects the request.
1950
1999
  input_type: (_e = bedrockOptions.inputType) != null ? _e : "search_query",
@@ -2001,7 +2050,10 @@ function isCohereEmbeddingModel(modelId) {
2001
2050
  return modelId.includes("cohere.embed-");
2002
2051
  }
2003
2052
  function isNovaEmbeddingModel(modelId) {
2004
- return modelId.startsWith("amazon.nova-") && modelId.includes("embed");
2053
+ return modelId.includes("amazon.nova-") && modelId.includes("embed");
2054
+ }
2055
+ function detectEmbeddingModelFamily(modelId) {
2056
+ return isNovaEmbeddingModel(modelId) ? "nova" : isCohereEmbeddingModel(modelId) ? "cohere" : "titan";
2005
2057
  }
2006
2058
  var BedrockEmbeddingResponseSchema = import_v46.z.union([
2007
2059
  // Titan-style response
@@ -2243,7 +2295,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
2243
2295
  var import_aws4fetch = require("aws4fetch");
2244
2296
 
2245
2297
  // src/version.ts
2246
- var VERSION = true ? "4.0.163" : "0.0.0-test";
2298
+ var VERSION = true ? "4.0.166" : "0.0.0-test";
2247
2299
 
2248
2300
  // src/bedrock-sigv4-fetch.ts
2249
2301
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -2554,10 +2606,11 @@ Original error: ${errorMessage}`
2554
2606
  }
2555
2607
  return createChatModel(modelId);
2556
2608
  };
2557
- const createEmbeddingModel = (modelId) => new BedrockEmbeddingModel(modelId, {
2609
+ const createEmbeddingModel = (modelId, settings = {}) => new BedrockEmbeddingModel(modelId, {
2558
2610
  baseUrl: getBedrockRuntimeBaseUrl,
2559
2611
  headers: getHeaders,
2560
- fetch: fetchFunction
2612
+ fetch: fetchFunction,
2613
+ modelFamily: settings.modelFamily
2561
2614
  });
2562
2615
  const createImageModel = (modelId) => new BedrockImageModel(modelId, {
2563
2616
  baseUrl: getBedrockRuntimeBaseUrl,