@ai-sdk/amazon-bedrock 4.0.49 → 4.0.51

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.
@@ -1489,7 +1489,7 @@ const result = await generateText({
1489
1489
 
1490
1490
  Anthropic has reasoning support for Claude 3.7 and Claude 4 models on Bedrock, including:
1491
1491
 
1492
- - `us.anthropic.claude-opus-4-6-v1:0`
1492
+ - `us.anthropic.claude-opus-4-6-v1`
1493
1493
  - `us.anthropic.claude-opus-4-5-20251101-v1:0`
1494
1494
  - `us.anthropic.claude-sonnet-4-5-20250929-v1:0`
1495
1495
  - `us.anthropic.claude-opus-4-20250514-v1:0`
@@ -1526,7 +1526,7 @@ on how to integrate reasoning into your chatbot.
1526
1526
 
1527
1527
  | Model | Image Input | Object Generation | Tool Usage | Computer Use | Reasoning |
1528
1528
  | ---------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
1529
- | `us.anthropic.claude-opus-4-6-v1:0` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1529
+ | `us.anthropic.claude-opus-4-6-v1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1530
1530
  | `us.anthropic.claude-opus-4-5-20251101-v1:0` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1531
1531
  | `us.anthropic.claude-sonnet-4-5-20250929-v1:0` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1532
1532
  | `us.anthropic.claude-opus-4-20250514-v1:0` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "4.0.49",
3
+ "version": "4.0.51",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -38,9 +38,9 @@
38
38
  "@smithy/eventstream-codec": "^4.0.1",
39
39
  "@smithy/util-utf8": "^4.0.0",
40
40
  "aws4fetch": "^1.0.20",
41
- "@ai-sdk/anthropic": "3.0.37",
42
- "@ai-sdk/provider": "3.0.7",
43
- "@ai-sdk/provider-utils": "4.0.13"
41
+ "@ai-sdk/anthropic": "3.0.38",
42
+ "@ai-sdk/provider": "3.0.8",
43
+ "@ai-sdk/provider-utils": "4.0.14"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "20.17.24",
@@ -1,5 +1,5 @@
1
1
  export type BedrockAnthropicModelId =
2
- | 'anthropic.claude-opus-4-6-v1:0'
2
+ | 'anthropic.claude-opus-4-6-v1'
3
3
  | 'anthropic.claude-opus-4-5-20251101-v1:0'
4
4
  | 'anthropic.claude-sonnet-4-5-20250929-v1:0'
5
5
  | 'anthropic.claude-opus-4-20250514-v1:0'
@@ -13,7 +13,7 @@ export type BedrockAnthropicModelId =
13
13
  | 'anthropic.claude-3-opus-20240229-v1:0'
14
14
  | 'anthropic.claude-3-sonnet-20240229-v1:0'
15
15
  | 'anthropic.claude-3-haiku-20240307-v1:0'
16
- | 'us.anthropic.claude-opus-4-6-v1:0'
16
+ | 'us.anthropic.claude-opus-4-6-v1'
17
17
  | 'us.anthropic.claude-opus-4-5-20251101-v1:0'
18
18
  | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0'
19
19
  | 'us.anthropic.claude-opus-4-20250514-v1:0'
@@ -177,9 +177,13 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
177
177
  }
178
178
 
179
179
  const isAnthropicModel = this.modelId.includes('anthropic');
180
+ const thinkingType = bedrockOptions.reasoningConfig?.type;
180
181
  const isThinkingRequested =
181
- bedrockOptions.reasoningConfig?.type === 'enabled';
182
- const thinkingBudget = bedrockOptions.reasoningConfig?.budgetTokens;
182
+ thinkingType === 'enabled' || thinkingType === 'adaptive';
183
+ const thinkingBudget =
184
+ thinkingType === 'enabled'
185
+ ? bedrockOptions.reasoningConfig?.budgetTokens
186
+ : undefined;
183
187
  const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
184
188
 
185
189
  const inferenceConfig = {
@@ -190,36 +194,60 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
190
194
  ...(stopSequences != null && { stopSequences }),
191
195
  };
192
196
 
193
- if (isAnthropicThinkingEnabled && thinkingBudget != null) {
194
- if (inferenceConfig.maxTokens != null) {
195
- inferenceConfig.maxTokens += thinkingBudget;
196
- } else {
197
- inferenceConfig.maxTokens = thinkingBudget + 4096; // Default + thinking budget maxTokens = 4096, TODO update default in v5
197
+ if (isAnthropicThinkingEnabled) {
198
+ if (thinkingBudget != null) {
199
+ if (inferenceConfig.maxTokens != null) {
200
+ inferenceConfig.maxTokens += thinkingBudget;
201
+ } else {
202
+ inferenceConfig.maxTokens = thinkingBudget + 4096; // Default + thinking budget maxTokens = 4096, TODO update default in v5
203
+ }
204
+ bedrockOptions.additionalModelRequestFields = {
205
+ ...bedrockOptions.additionalModelRequestFields,
206
+ thinking: {
207
+ type: 'enabled',
208
+ budget_tokens: thinkingBudget,
209
+ },
210
+ };
211
+ } else if (thinkingType === 'adaptive') {
212
+ bedrockOptions.additionalModelRequestFields = {
213
+ ...bedrockOptions.additionalModelRequestFields,
214
+ thinking: {
215
+ type: 'adaptive',
216
+ },
217
+ };
218
+ }
219
+ } else if (!isAnthropicModel) {
220
+ if (bedrockOptions.reasoningConfig?.budgetTokens != null) {
221
+ warnings.push({
222
+ type: 'unsupported',
223
+ feature: 'budgetTokens',
224
+ details:
225
+ 'budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model.',
226
+ });
227
+ }
228
+ if (thinkingType === 'adaptive') {
229
+ warnings.push({
230
+ type: 'unsupported',
231
+ feature: 'adaptive thinking',
232
+ details:
233
+ 'adaptive thinking type applies only to Anthropic models on Bedrock.',
234
+ });
198
235
  }
199
- // Add them to additional model request fields
200
- // Add thinking config to additionalModelRequestFields
201
- bedrockOptions.additionalModelRequestFields = {
202
- ...bedrockOptions.additionalModelRequestFields,
203
- thinking: {
204
- type: bedrockOptions.reasoningConfig?.type,
205
- budget_tokens: thinkingBudget,
206
- },
207
- };
208
- } else if (!isAnthropicModel && thinkingBudget != null) {
209
- warnings.push({
210
- type: 'unsupported',
211
- feature: 'budgetTokens',
212
- details:
213
- 'budgetTokens applies only to Anthropic models on Bedrock and will be ignored for this model.',
214
- });
215
236
  }
216
237
 
217
238
  const maxReasoningEffort =
218
239
  bedrockOptions.reasoningConfig?.maxReasoningEffort;
219
240
  const isOpenAIModel = this.modelId.startsWith('openai.');
220
241
 
221
- if (maxReasoningEffort != null && !isAnthropicModel) {
222
- if (isOpenAIModel) {
242
+ if (maxReasoningEffort != null) {
243
+ if (isAnthropicModel) {
244
+ bedrockOptions.additionalModelRequestFields = {
245
+ ...bedrockOptions.additionalModelRequestFields,
246
+ output_config: {
247
+ effort: maxReasoningEffort,
248
+ },
249
+ };
250
+ } else if (isOpenAIModel) {
223
251
  // OpenAI models on Bedrock expect `reasoning_effort` as a flat value
224
252
  bedrockOptions.additionalModelRequestFields = {
225
253
  ...bedrockOptions.additionalModelRequestFields,
@@ -230,20 +258,13 @@ export class BedrockChatLanguageModel implements LanguageModelV3 {
230
258
  bedrockOptions.additionalModelRequestFields = {
231
259
  ...bedrockOptions.additionalModelRequestFields,
232
260
  reasoningConfig: {
233
- ...(bedrockOptions.reasoningConfig?.type != null && {
234
- type: bedrockOptions.reasoningConfig.type,
235
- }),
261
+ ...(thinkingType != null &&
262
+ thinkingType !== 'adaptive' && { type: thinkingType }),
263
+ ...(thinkingBudget != null && { budgetTokens: thinkingBudget }),
236
264
  maxReasoningEffort,
237
265
  },
238
266
  };
239
267
  }
240
- } else if (maxReasoningEffort != null && isAnthropicModel) {
241
- warnings.push({
242
- type: 'unsupported',
243
- feature: 'maxReasoningEffort',
244
- details:
245
- 'maxReasoningEffort applies only to Amazon Nova models on Bedrock and will be ignored for this model.',
246
- });
247
268
  }
248
269
 
249
270
  if (isAnthropicThinkingEnabled && inferenceConfig.temperature != null) {
@@ -100,9 +100,15 @@ export const bedrockProviderOptions = z.object({
100
100
  additionalModelRequestFields: z.record(z.string(), z.any()).optional(),
101
101
  reasoningConfig: z
102
102
  .object({
103
- type: z.union([z.literal('enabled'), z.literal('disabled')]).optional(),
103
+ type: z
104
+ .union([
105
+ z.literal('enabled'),
106
+ z.literal('disabled'),
107
+ z.literal('adaptive'),
108
+ ])
109
+ .optional(),
104
110
  budgetTokens: z.number().optional(),
105
- maxReasoningEffort: z.enum(['low', 'medium', 'high']).optional(),
111
+ maxReasoningEffort: z.enum(['low', 'medium', 'high', 'max']).optional(),
106
112
  })
107
113
  .optional(),
108
114
  /**