@ai-sdk/amazon-bedrock 3.0.74 → 3.0.76

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,18 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.0.76
4
+
5
+ ### Patch Changes
6
+
7
+ - 18a97b2: feat(amazon-bedrock): add support for new Anthropic adaptive thinking and reasoning effort including max
8
+
9
+ ## 3.0.75
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [ca1f53a]
14
+ - @ai-sdk/anthropic@2.0.59
15
+
3
16
  ## 3.0.74
4
17
 
5
18
  ### Patch Changes
@@ -9,7 +9,7 @@ interface BedrockCredentials {
9
9
  sessionToken?: string;
10
10
  }
11
11
 
12
- type BedrockAnthropicModelId = 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
12
+ type BedrockAnthropicModelId = 'anthropic.claude-opus-4-6-v1' | 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-6-v1' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
13
13
 
14
14
  interface BedrockAnthropicProvider extends ProviderV2 {
15
15
  /**
@@ -9,7 +9,7 @@ interface BedrockCredentials {
9
9
  sessionToken?: string;
10
10
  }
11
11
 
12
- type BedrockAnthropicModelId = 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
12
+ type BedrockAnthropicModelId = 'anthropic.claude-opus-4-6-v1' | 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-6-v1' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
13
13
 
14
14
  interface BedrockAnthropicProvider extends ProviderV2 {
15
15
  /**
@@ -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 ? "3.0.74" : "0.0.0-test";
38
+ var VERSION = true ? "3.0.76" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "3.0.74" : "0.0.0-test";
27
+ var VERSION = true ? "3.0.76" : "0.0.0-test";
28
28
 
29
29
  // src/bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
package/dist/index.d.mts CHANGED
@@ -7,12 +7,13 @@ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-
7
7
  declare const bedrockProviderOptions: z.ZodObject<{
8
8
  additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
9
9
  reasoningConfig: z.ZodOptional<z.ZodObject<{
10
- type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
10
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">, z.ZodLiteral<"adaptive">]>>;
11
11
  budgetTokens: z.ZodOptional<z.ZodNumber>;
12
12
  maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
13
13
  low: "low";
14
14
  medium: "medium";
15
15
  high: "high";
16
+ max: "max";
16
17
  }>>;
17
18
  }, z.core.$strip>>;
18
19
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
package/dist/index.d.ts CHANGED
@@ -7,12 +7,13 @@ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-
7
7
  declare const bedrockProviderOptions: z.ZodObject<{
8
8
  additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
9
9
  reasoningConfig: z.ZodOptional<z.ZodObject<{
10
- type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
10
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">, z.ZodLiteral<"adaptive">]>>;
11
11
  budgetTokens: z.ZodOptional<z.ZodNumber>;
12
12
  maxReasoningEffort: z.ZodOptional<z.ZodEnum<{
13
13
  low: "low";
14
14
  medium: "medium";
15
15
  high: "high";
16
+ max: "max";
16
17
  }>>;
17
18
  }, z.core.$strip>>;
18
19
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.74" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.76" : "0.0.0-test";
34
34
 
35
35
  // src/bedrock-provider.ts
36
36
  var import_internal2 = require("@ai-sdk/anthropic/internal");
@@ -95,9 +95,13 @@ var bedrockProviderOptions = import_v4.z.object({
95
95
  */
96
96
  additionalModelRequestFields: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
97
97
  reasoningConfig: import_v4.z.object({
98
- type: import_v4.z.union([import_v4.z.literal("enabled"), import_v4.z.literal("disabled")]).optional(),
98
+ type: import_v4.z.union([
99
+ import_v4.z.literal("enabled"),
100
+ import_v4.z.literal("disabled"),
101
+ import_v4.z.literal("adaptive")
102
+ ]).optional(),
99
103
  budgetTokens: import_v4.z.number().optional(),
100
- maxReasoningEffort: import_v4.z.enum(["low", "medium", "high"]).optional()
104
+ maxReasoningEffort: import_v4.z.enum(["low", "medium", "high", "max"]).optional()
101
105
  }).optional(),
102
106
  /**
103
107
  * Anthropic beta features to enable
@@ -781,8 +785,9 @@ var BedrockChatLanguageModel = class {
781
785
  };
782
786
  }
783
787
  const isAnthropicModel = this.modelId.includes("anthropic");
784
- const isThinkingRequested = ((_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type) === "enabled";
785
- const thinkingBudget = (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens;
788
+ const thinkingType = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type;
789
+ const isThinkingRequested = thinkingType === "enabled" || thinkingType === "adaptive";
790
+ const thinkingBudget = thinkingType === "enabled" ? (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens : void 0;
786
791
  const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
787
792
  const inferenceConfig = {
788
793
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
@@ -791,25 +796,43 @@ var BedrockChatLanguageModel = class {
791
796
  ...topK != null && { topK },
792
797
  ...stopSequences != null && { stopSequences }
793
798
  };
794
- if (isAnthropicThinkingEnabled && thinkingBudget != null) {
795
- if (inferenceConfig.maxTokens != null) {
796
- inferenceConfig.maxTokens += thinkingBudget;
797
- } else {
798
- inferenceConfig.maxTokens = thinkingBudget + 4096;
799
- }
800
- bedrockOptions.additionalModelRequestFields = {
801
- ...bedrockOptions.additionalModelRequestFields,
802
- thinking: {
803
- type: (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type,
804
- budget_tokens: thinkingBudget
799
+ if (isAnthropicThinkingEnabled) {
800
+ if (thinkingBudget != null) {
801
+ if (inferenceConfig.maxTokens != null) {
802
+ inferenceConfig.maxTokens += thinkingBudget;
803
+ } else {
804
+ inferenceConfig.maxTokens = thinkingBudget + 4096;
805
805
  }
806
- };
807
- } else if (!isAnthropicModel && thinkingBudget != null) {
808
- warnings.push({
809
- type: "unsupported-setting",
810
- setting: "providerOptions",
811
- details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
812
- });
806
+ bedrockOptions.additionalModelRequestFields = {
807
+ ...bedrockOptions.additionalModelRequestFields,
808
+ thinking: {
809
+ type: "enabled",
810
+ budget_tokens: thinkingBudget
811
+ }
812
+ };
813
+ } else if (thinkingType === "adaptive") {
814
+ bedrockOptions.additionalModelRequestFields = {
815
+ ...bedrockOptions.additionalModelRequestFields,
816
+ thinking: {
817
+ type: "adaptive"
818
+ }
819
+ };
820
+ }
821
+ } else if (!isAnthropicModel) {
822
+ if (((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.budgetTokens) != null) {
823
+ warnings.push({
824
+ type: "unsupported-setting",
825
+ setting: "budgetTokens",
826
+ details: "budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model."
827
+ });
828
+ }
829
+ if (thinkingType === "adaptive") {
830
+ warnings.push({
831
+ type: "unsupported-setting",
832
+ setting: "adaptive thinking",
833
+ details: "adaptive thinking type applies only to Anthropic models on Bedrock."
834
+ });
835
+ }
813
836
  }
814
837
  const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
815
838
  if (maxReasoningEffort != null && !isAnthropicModel) {
@@ -823,11 +846,12 @@ var BedrockChatLanguageModel = class {
823
846
  }
824
847
  };
825
848
  } else if (maxReasoningEffort != null && isAnthropicModel) {
826
- warnings.push({
827
- type: "unsupported-setting",
828
- setting: "providerOptions",
829
- details: "maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model."
830
- });
849
+ bedrockOptions.additionalModelRequestFields = {
850
+ ...bedrockOptions.additionalModelRequestFields,
851
+ output_config: {
852
+ effort: maxReasoningEffort
853
+ }
854
+ };
831
855
  }
832
856
  if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
833
857
  delete inferenceConfig.temperature;