@ai-sdk/amazon-bedrock 4.0.109 → 4.0.111

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.
@@ -1586,6 +1586,7 @@ const result = await generateText({
1586
1586
 
1587
1587
  Anthropic has reasoning support for Claude 3.7 and Claude 4 models on Bedrock, including:
1588
1588
 
1589
+ - `us.anthropic.claude-opus-4-8`
1589
1590
  - `us.anthropic.claude-opus-4-7`
1590
1591
  - `us.anthropic.claude-opus-4-6-v1`
1591
1592
  - `us.anthropic.claude-opus-4-5-20251101-v1:0`
@@ -1623,6 +1624,7 @@ on how to integrate reasoning into your chatbot.
1623
1624
 
1624
1625
  | Model | Image Input | Object Generation | Tool Usage | Computer Use | Reasoning |
1625
1626
  | ---------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
1627
+ | `us.anthropic.claude-opus-4-8` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1626
1628
  | `us.anthropic.claude-opus-4-7` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1627
1629
  | `us.anthropic.claude-opus-4-6-v1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1628
1630
  | `us.anthropic.claude-opus-4-5-20251101-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.109",
3
+ "version": "4.0.111",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,7 @@
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.80",
41
+ "@ai-sdk/anthropic": "3.0.81",
42
42
  "@ai-sdk/provider": "3.0.10",
43
43
  "@ai-sdk/provider-utils": "4.0.27"
44
44
  },
@@ -1,4 +1,5 @@
1
1
  export type BedrockAnthropicModelId =
2
+ | 'anthropic.claude-opus-4-8'
2
3
  | 'anthropic.claude-opus-4-7'
3
4
  | 'anthropic.claude-opus-4-6-v1'
4
5
  | 'anthropic.claude-sonnet-4-6-v1'
@@ -15,6 +16,7 @@ export type BedrockAnthropicModelId =
15
16
  | 'anthropic.claude-3-opus-20240229-v1:0'
16
17
  | 'anthropic.claude-3-sonnet-20240229-v1:0'
17
18
  | 'anthropic.claude-3-haiku-20240307-v1:0'
19
+ | 'us.anthropic.claude-opus-4-8'
18
20
  | 'us.anthropic.claude-opus-4-7'
19
21
  | 'us.anthropic.claude-opus-4-6-v1'
20
22
  | 'us.anthropic.claude-sonnet-4-6-v1'
@@ -324,8 +324,10 @@ export function createBedrockAnthropic(
324
324
  // Bedrock Anthropic doesn't support URL sources, force download and base64 conversion
325
325
  supportedUrls: () => ({}),
326
326
  // native structured output via output_config.format is supported on Bedrock
327
- // Bedrock rejects `output_config.format` for `claude-opus-4-7`
328
- supportsNativeStructuredOutput: !modelId.includes('claude-opus-4-7'),
327
+ // Bedrock rejects `output_config.format` for `claude-opus-4-7` and `claude-opus-4-8`
328
+ supportsNativeStructuredOutput:
329
+ !modelId.includes('claude-opus-4-7') &&
330
+ !modelId.includes('claude-opus-4-8'),
329
331
  });
330
332
 
331
333
  const provider = function (modelId: BedrockAnthropicModelId) {
@@ -174,7 +174,7 @@ export interface BedrockImageBlock {
174
174
  export interface BedrockToolResultBlock {
175
175
  toolResult: {
176
176
  toolUseId: string;
177
- content: Array<BedrockTextBlock | BedrockImageBlock>;
177
+ content: Array<BedrockTextBlock | BedrockImageBlock | BedrockDocumentBlock>;
178
178
  };
179
179
  }
180
180
 
@@ -7,6 +7,7 @@ export type BedrockChatModelId =
7
7
  | 'anthropic.claude-v2'
8
8
  | 'anthropic.claude-v2:1'
9
9
  | 'anthropic.claude-instant-v1'
10
+ | 'anthropic.claude-opus-4-8'
10
11
  | 'anthropic.claude-opus-4-7'
11
12
  | 'anthropic.claude-opus-4-6-v1'
12
13
  | 'anthropic.claude-sonnet-4-6-v1'
@@ -55,6 +56,7 @@ export type BedrockChatModelId =
55
56
  | 'us.anthropic.claude-3-5-haiku-20241022-v1:0'
56
57
  | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0'
57
58
  | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0'
59
+ | 'us.anthropic.claude-opus-4-8'
58
60
  | 'us.anthropic.claude-opus-4-7'
59
61
  | 'us.anthropic.claude-opus-4-6-v1'
60
62
  | 'us.anthropic.claude-sonnet-4-6-v1'
@@ -182,34 +182,69 @@ export async function convertToBedrockChatMessages(
182
182
  const output = part.output;
183
183
  switch (output.type) {
184
184
  case 'content': {
185
- toolResultContent = output.value.map(contentPart => {
186
- switch (contentPart.type) {
187
- case 'text':
188
- return { text: contentPart.text };
189
- case 'image-data':
190
- if (!contentPart.mediaType.startsWith('image/')) {
185
+ toolResultContent = await Promise.all(
186
+ output.value.map(async contentPart => {
187
+ switch (contentPart.type) {
188
+ case 'text':
189
+ return { text: contentPart.text };
190
+ case 'image-data': {
191
+ return {
192
+ image: {
193
+ format: getBedrockImageFormat(
194
+ contentPart.mediaType,
195
+ ),
196
+ source: {
197
+ bytes: convertToBase64(contentPart.data),
198
+ },
199
+ },
200
+ };
201
+ }
202
+ case 'file-data': {
203
+ if (!contentPart.mediaType.startsWith('image/')) {
204
+ const enableCitations =
205
+ await shouldEnableCitations(
206
+ contentPart.providerOptions,
207
+ );
208
+
209
+ return {
210
+ document: {
211
+ format: getBedrockDocumentFormat(
212
+ contentPart.mediaType,
213
+ ),
214
+ name:
215
+ 'filename' in contentPart &&
216
+ contentPart.filename
217
+ ? stripFileExtension(contentPart.filename)
218
+ : generateDocumentName(),
219
+ source: {
220
+ bytes: convertToBase64(contentPart.data),
221
+ },
222
+ ...(enableCitations && {
223
+ citations: { enabled: true },
224
+ }),
225
+ },
226
+ };
227
+ }
228
+
229
+ return {
230
+ image: {
231
+ format: getBedrockImageFormat(
232
+ contentPart.mediaType,
233
+ ),
234
+ source: {
235
+ bytes: convertToBase64(contentPart.data),
236
+ },
237
+ },
238
+ };
239
+ }
240
+ default: {
191
241
  throw new UnsupportedFunctionalityError({
192
- functionality: `media type: ${contentPart.mediaType}`,
242
+ functionality: `unsupported tool content part type: ${contentPart.type}`,
193
243
  });
194
244
  }
195
-
196
- const format = getBedrockImageFormat(
197
- contentPart.mediaType,
198
- );
199
-
200
- return {
201
- image: {
202
- format,
203
- source: { bytes: contentPart.data },
204
- },
205
- };
206
- default: {
207
- throw new UnsupportedFunctionalityError({
208
- functionality: `unsupported tool content part type: ${contentPart.type}`,
209
- });
210
245
  }
211
- }
212
- });
246
+ }),
247
+ );
213
248
  break;
214
249
  }
215
250
  case 'text':