@ai-sdk/amazon-bedrock 5.0.0-beta.45 → 5.0.0-beta.46

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/anthropic/index.d.ts +10 -10
  3. package/dist/anthropic/index.js +58 -46
  4. package/dist/anthropic/index.js.map +1 -1
  5. package/dist/index.d.ts +21 -21
  6. package/dist/index.js +328 -292
  7. package/dist/index.js.map +1 -1
  8. package/docs/08-amazon-bedrock.mdx +66 -66
  9. package/package.json +3 -3
  10. package/src/{bedrock-api-types.ts → amazon-bedrock-api-types.ts} +60 -55
  11. package/src/{bedrock-chat-options.ts → amazon-bedrock-chat-language-model-options.ts} +7 -7
  12. package/src/{bedrock-chat-language-model.ts → amazon-bedrock-chat-language-model.ts} +211 -190
  13. package/src/{bedrock-embedding-options.ts → amazon-bedrock-embedding-model-options.ts} +1 -1
  14. package/src/{bedrock-embedding-model.ts → amazon-bedrock-embedding-model.ts} +31 -24
  15. package/src/{bedrock-error.ts → amazon-bedrock-error.ts} +1 -1
  16. package/src/{bedrock-event-stream-decoder.ts → amazon-bedrock-event-stream-decoder.ts} +1 -1
  17. package/src/{bedrock-event-stream-response-handler.ts → amazon-bedrock-event-stream-response-handler.ts} +3 -3
  18. package/src/{bedrock-image-model.ts → amazon-bedrock-image-model.ts} +40 -36
  19. package/src/amazon-bedrock-image-settings.ts +9 -0
  20. package/src/{bedrock-prepare-tools.ts → amazon-bedrock-prepare-tools.ts} +18 -17
  21. package/src/{bedrock-provider.ts → amazon-bedrock-provider.ts} +40 -38
  22. package/src/amazon-bedrock-reasoning-metadata.ts +10 -0
  23. package/src/{bedrock-sigv4-fetch.ts → amazon-bedrock-sigv4-fetch.ts} +4 -2
  24. package/src/anthropic/amazon-bedrock-anthropic-fetch.ts +104 -0
  25. package/src/anthropic/{bedrock-anthropic-options.ts → amazon-bedrock-anthropic-options.ts} +1 -1
  26. package/src/anthropic/{bedrock-anthropic-provider.ts → amazon-bedrock-anthropic-provider.ts} +18 -16
  27. package/src/anthropic/index.ts +19 -7
  28. package/src/{convert-bedrock-usage.ts → convert-amazon-bedrock-usage.ts} +3 -3
  29. package/src/{convert-to-bedrock-chat-messages.ts → convert-to-amazon-bedrock-chat-messages.ts} +78 -56
  30. package/src/index.ts +15 -8
  31. package/src/{map-bedrock-finish-reason.ts → map-amazon-bedrock-finish-reason.ts} +3 -3
  32. package/src/reranking/{bedrock-reranking-api.ts → amazon-bedrock-reranking-api.ts} +3 -3
  33. package/src/reranking/{bedrock-reranking-options.ts → amazon-bedrock-reranking-model-options.ts} +1 -1
  34. package/src/reranking/{bedrock-reranking-model.ts → amazon-bedrock-reranking-model.ts} +29 -21
  35. package/src/anthropic/bedrock-anthropic-fetch.ts +0 -94
  36. package/src/bedrock-image-settings.ts +0 -6
  37. package/src/bedrock-reasoning-metadata.ts +0 -10
@@ -1,9 +1,9 @@
1
1
  import type { JSONObject } from '@ai-sdk/provider';
2
2
 
3
- export interface BedrockConverseInput {
4
- system?: BedrockSystemMessages;
5
- messages: BedrockMessages;
6
- toolConfig?: BedrockToolConfiguration;
3
+ export interface AmazonBedrockConverseInput {
4
+ system?: AmazonBedrockSystemMessages;
5
+ messages: AmazonBedrockMessages;
6
+ toolConfig?: AmazonBedrockToolConfiguration;
7
7
  inferenceConfig?: {
8
8
  maxOutputTokens?: number;
9
9
  temperature?: number;
@@ -17,25 +17,26 @@ export interface BedrockConverseInput {
17
17
  type: string;
18
18
  };
19
19
  guardrailConfig?:
20
- | BedrockGuardrailConfiguration
21
- | BedrockGuardrailStreamConfiguration
20
+ | AmazonBedrockGuardrailConfiguration
21
+ | AmazonBedrockGuardrailStreamConfiguration
22
22
  | undefined;
23
23
  }
24
24
 
25
- export type BedrockSystemMessages = Array<BedrockSystemContentBlock>;
25
+ export type AmazonBedrockSystemMessages =
26
+ Array<AmazonBedrockSystemContentBlock>;
26
27
 
27
- export type BedrockMessages = Array<
28
- BedrockAssistantMessage | BedrockUserMessage
28
+ export type AmazonBedrockMessages = Array<
29
+ AmazonBedrockAssistantMessage | AmazonBedrockUserMessage
29
30
  >;
30
31
 
31
- export interface BedrockAssistantMessage {
32
+ export interface AmazonBedrockAssistantMessage {
32
33
  role: 'assistant';
33
- content: Array<BedrockContentBlock>;
34
+ content: Array<AmazonBedrockContentBlock>;
34
35
  }
35
36
 
36
- export interface BedrockUserMessage {
37
+ export interface AmazonBedrockUserMessage {
37
38
  role: 'user';
38
- content: Array<BedrockContentBlock>;
39
+ content: Array<AmazonBedrockContentBlock>;
39
40
  }
40
41
 
41
42
  /**
@@ -45,27 +46,29 @@ export interface BedrockUserMessage {
45
46
  * - '5m': 5-minute TTL (default, supported by all models)
46
47
  * - '1h': 1-hour TTL (supported by Claude Opus 4.5, Claude Haiku 4.5, Claude Sonnet 4.5)
47
48
  */
48
- export type BedrockCacheTTL = '5m' | '1h';
49
+ export type AmazonBedrockCacheTTL = '5m' | '1h';
49
50
 
50
- export type BedrockCachePoint = {
51
- cachePoint: { type: 'default'; ttl?: BedrockCacheTTL };
51
+ export type AmazonBedrockCachePoint = {
52
+ cachePoint: { type: 'default'; ttl?: AmazonBedrockCacheTTL };
52
53
  };
53
54
 
54
55
  /**
55
56
  * Creates a cache point with an optional TTL.
56
57
  * @param ttl - Cache TTL ('5m' or '1h'). If not provided, uses the default 5-minute TTL.
57
58
  */
58
- export function createBedrockCachePoint(
59
- ttl?: BedrockCacheTTL,
60
- ): BedrockCachePoint {
59
+ export function createAmazonBedrockCachePoint(
60
+ ttl?: AmazonBedrockCacheTTL,
61
+ ): AmazonBedrockCachePoint {
61
62
  return {
62
63
  cachePoint: { type: 'default', ttl },
63
64
  };
64
65
  }
65
66
 
66
- export type BedrockSystemContentBlock = { text: string } | BedrockCachePoint;
67
+ export type AmazonBedrockSystemContentBlock =
68
+ | { text: string }
69
+ | AmazonBedrockCachePoint;
67
70
 
68
- export interface BedrockGuardrailConfiguration {
71
+ export interface AmazonBedrockGuardrailConfiguration {
69
72
  guardrails?: Array<{
70
73
  name: string;
71
74
  description?: string;
@@ -73,13 +76,14 @@ export interface BedrockGuardrailConfiguration {
73
76
  }>;
74
77
  }
75
78
 
76
- export type BedrockGuardrailStreamConfiguration = BedrockGuardrailConfiguration;
79
+ export type AmazonBedrockGuardrailStreamConfiguration =
80
+ AmazonBedrockGuardrailConfiguration;
77
81
 
78
- export interface BedrockToolInputSchema {
82
+ export interface AmazonBedrockToolInputSchema {
79
83
  json: Record<string, unknown>;
80
84
  }
81
85
 
82
- export interface BedrockTool {
86
+ export interface AmazonBedrockTool {
83
87
  toolSpec: {
84
88
  name: string;
85
89
  description?: string;
@@ -88,8 +92,8 @@ export interface BedrockTool {
88
92
  };
89
93
  }
90
94
 
91
- export interface BedrockToolConfiguration {
92
- tools?: Array<BedrockTool | BedrockCachePoint>;
95
+ export interface AmazonBedrockToolConfiguration {
96
+ tools?: Array<AmazonBedrockTool | AmazonBedrockCachePoint>;
93
97
  toolChoice?:
94
98
  | { tool: { name: string } }
95
99
  | { auto: {} }
@@ -110,7 +114,7 @@ export const BEDROCK_STOP_REASONS = [
110
114
  'tool_use',
111
115
  ] as const;
112
116
 
113
- export type BedrockStopReason = (typeof BEDROCK_STOP_REASONS)[number];
117
+ export type AmazonBedrockStopReason = (typeof BEDROCK_STOP_REASONS)[number];
114
118
 
115
119
  /**
116
120
  * @see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ImageBlock.html
@@ -121,9 +125,10 @@ export const BEDROCK_IMAGE_MIME_TYPES = {
121
125
  'image/gif': 'gif',
122
126
  'image/webp': 'webp',
123
127
  } as const;
124
- type BedrockImageFormats = typeof BEDROCK_IMAGE_MIME_TYPES;
125
- export type BedrockImageFormat = BedrockImageFormats[keyof BedrockImageFormats];
126
- export type BedrockImageMimeType = keyof BedrockImageFormats;
128
+ type AmazonBedrockImageFormats = typeof BEDROCK_IMAGE_MIME_TYPES;
129
+ export type AmazonBedrockImageFormat =
130
+ AmazonBedrockImageFormats[keyof AmazonBedrockImageFormats];
131
+ export type AmazonBedrockImageMimeType = keyof AmazonBedrockImageFormats;
127
132
 
128
133
  /**
129
134
  * @see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_DocumentBlock.html
@@ -140,14 +145,14 @@ export const BEDROCK_DOCUMENT_MIME_TYPES = {
140
145
  'text/plain': 'txt',
141
146
  'text/markdown': 'md',
142
147
  } as const;
143
- type BedrockDocumentFormats = typeof BEDROCK_DOCUMENT_MIME_TYPES;
144
- export type BedrockDocumentFormat =
145
- BedrockDocumentFormats[keyof BedrockDocumentFormats];
146
- export type BedrockDocumentMimeType = keyof BedrockDocumentFormats;
148
+ type AmazonBedrockDocumentFormats = typeof BEDROCK_DOCUMENT_MIME_TYPES;
149
+ export type AmazonBedrockDocumentFormat =
150
+ AmazonBedrockDocumentFormats[keyof AmazonBedrockDocumentFormats];
151
+ export type AmazonBedrockDocumentMimeType = keyof AmazonBedrockDocumentFormats;
147
152
 
148
- export interface BedrockDocumentBlock {
153
+ export interface AmazonBedrockDocumentBlock {
149
154
  document: {
150
- format: BedrockDocumentFormat;
155
+ format: AmazonBedrockDocumentFormat;
151
156
  name: string;
152
157
  source: {
153
158
  bytes: string;
@@ -158,27 +163,27 @@ export interface BedrockDocumentBlock {
158
163
  };
159
164
  }
160
165
 
161
- export interface BedrockGuardrailConverseContentBlock {
166
+ export interface AmazonBedrockGuardrailConverseContentBlock {
162
167
  guardContent: unknown;
163
168
  }
164
169
 
165
- export interface BedrockImageBlock {
170
+ export interface AmazonBedrockImageBlock {
166
171
  image: {
167
- format: BedrockImageFormat;
172
+ format: AmazonBedrockImageFormat;
168
173
  source: {
169
174
  bytes: string;
170
175
  };
171
176
  };
172
177
  }
173
178
 
174
- export interface BedrockToolResultBlock {
179
+ export interface AmazonBedrockToolResultBlock {
175
180
  toolResult: {
176
181
  toolUseId: string;
177
- content: Array<BedrockTextBlock | BedrockImageBlock>;
182
+ content: Array<AmazonBedrockTextBlock | AmazonBedrockImageBlock>;
178
183
  };
179
184
  }
180
185
 
181
- export interface BedrockToolUseBlock {
186
+ export interface AmazonBedrockToolUseBlock {
182
187
  toolUse: {
183
188
  toolUseId: string;
184
189
  name: string;
@@ -186,11 +191,11 @@ export interface BedrockToolUseBlock {
186
191
  };
187
192
  }
188
193
 
189
- export interface BedrockTextBlock {
194
+ export interface AmazonBedrockTextBlock {
190
195
  text: string;
191
196
  }
192
197
 
193
- export interface BedrockReasoningContentBlock {
198
+ export interface AmazonBedrockReasoningContentBlock {
194
199
  reasoningContent: {
195
200
  reasoningText: {
196
201
  text: string;
@@ -199,7 +204,7 @@ export interface BedrockReasoningContentBlock {
199
204
  };
200
205
  }
201
206
 
202
- export interface BedrockRedactedReasoningContentBlock {
207
+ export interface AmazonBedrockRedactedReasoningContentBlock {
203
208
  reasoningContent: {
204
209
  redactedReasoning: {
205
210
  data: string;
@@ -207,13 +212,13 @@ export interface BedrockRedactedReasoningContentBlock {
207
212
  };
208
213
  }
209
214
 
210
- export type BedrockContentBlock =
211
- | BedrockDocumentBlock
212
- | BedrockGuardrailConverseContentBlock
213
- | BedrockImageBlock
214
- | BedrockTextBlock
215
- | BedrockToolResultBlock
216
- | BedrockToolUseBlock
217
- | BedrockReasoningContentBlock
218
- | BedrockRedactedReasoningContentBlock
219
- | BedrockCachePoint;
215
+ export type AmazonBedrockContentBlock =
216
+ | AmazonBedrockDocumentBlock
217
+ | AmazonBedrockGuardrailConverseContentBlock
218
+ | AmazonBedrockImageBlock
219
+ | AmazonBedrockTextBlock
220
+ | AmazonBedrockToolResultBlock
221
+ | AmazonBedrockToolUseBlock
222
+ | AmazonBedrockReasoningContentBlock
223
+ | AmazonBedrockRedactedReasoningContentBlock
224
+ | AmazonBedrockCachePoint;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod/v4';
2
2
 
3
3
  // https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html
4
- export type BedrockChatModelId =
4
+ export type AmazonBedrockChatModelId =
5
5
  | 'amazon.titan-tg1-large'
6
6
  | 'amazon.titan-text-express-v1'
7
7
  | 'anthropic.claude-v2'
@@ -81,7 +81,7 @@ export type BedrockChatModelId =
81
81
  * Bedrock file part provider options for document-specific features.
82
82
  * These options apply to individual file parts (documents).
83
83
  */
84
- export const bedrockFilePartProviderOptions = z.object({
84
+ export const amazonBedrockFilePartProviderOptions = z.object({
85
85
  /**
86
86
  * Citation configuration for this document.
87
87
  * When enabled, this document will generate citations in the response.
@@ -96,11 +96,11 @@ export const bedrockFilePartProviderOptions = z.object({
96
96
  .optional(),
97
97
  });
98
98
 
99
- export type BedrockFilePartProviderOptions = z.infer<
100
- typeof bedrockFilePartProviderOptions
99
+ export type AmazonBedrockFilePartProviderOptions = z.infer<
100
+ typeof amazonBedrockFilePartProviderOptions
101
101
  >;
102
102
 
103
- export const amazonBedrockLanguageModelOptions = z.object({
103
+ export const amazonBedrockLanguageModelChatOptions = z.object({
104
104
  /**
105
105
  * Additional inference parameters that the model supports,
106
106
  * beyond the base set of inference parameters that Converse
@@ -139,6 +139,6 @@ export const amazonBedrockLanguageModelOptions = z.object({
139
139
  serviceTier: z.enum(['reserved', 'priority', 'default', 'flex']).optional(),
140
140
  });
141
141
 
142
- export type AmazonBedrockLanguageModelOptions = z.infer<
143
- typeof amazonBedrockLanguageModelOptions
142
+ export type AmazonBedrockLanguageModelChatOptions = z.infer<
143
+ typeof amazonBedrockLanguageModelChatOptions
144
144
  >;