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

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.
@@ -133,12 +133,10 @@ const bedrock = createAmazonBedrock({
133
133
  ```
134
134
 
135
135
  <Note>
136
- The credentials settings fall back to environment variable defaults described
137
- below. These may be set by your serverless environment without your awareness,
138
- which can lead to merged/conflicting credential values and provider errors
139
- around failed authentication. If you're experiencing issues be sure you are
140
- explicitly specifying all settings (even if `undefined`) to avoid any
141
- defaults.
136
+ Omitted options use the environment variables below. When **both**
137
+ `accessKeyId` and `secretAccessKey` are strings, SigV4 uses a **`sessionToken`
138
+ only if you pass one** - not `AWS_SESSION_TOKEN` from the environment - so static
139
+ keys are not mixed with workload tokens (e.g. EKS IRSA).
142
140
  </Note>
143
141
 
144
142
  You can use the following optional settings to customize the Amazon Bedrock provider instance:
@@ -160,8 +158,10 @@ You can use the following optional settings to customize the Amazon Bedrock prov
160
158
 
161
159
  - **sessionToken** _string_
162
160
 
163
- Optional. The AWS session token that you want to use for the API calls.
164
- It uses the `AWS_SESSION_TOKEN` environment variable by default.
161
+ Optional. For temporary credentials. With **both** access keys set as strings,
162
+ pass the token here if needed; `AWS_SESSION_TOKEN` from the environment is not
163
+ used. If either key is taken from the environment, omitting `sessionToken`
164
+ allows `AWS_SESSION_TOKEN`.
165
165
 
166
166
  - **credentialProvider** _() =&gt; Promise&lt;&#123; accessKeyId: string; secretAccessKey: string; sessionToken?: string; &#125;&gt;_
167
167
 
@@ -720,7 +720,7 @@ const computerTool = bedrock.tools.computer_20241022({
720
720
  toModelOutput({ output }) {
721
721
  return typeof output === 'string'
722
722
  ? [{ type: 'text', text: output }]
723
- : [{ type: 'image', data: output.data, mediaType: 'image/png' }];
723
+ : [{ type: 'file-data', data: output.data, mediaType: 'image/png' }];
724
724
  },
725
725
  });
726
726
  ```
@@ -1359,8 +1359,10 @@ You can use the following optional settings to customize the Bedrock Anthropic p
1359
1359
 
1360
1360
  - **sessionToken** _string_
1361
1361
 
1362
- Optional. The AWS session token that you want to use for the API calls.
1363
- It uses the `AWS_SESSION_TOKEN` environment variable by default.
1362
+ Optional. For temporary credentials. With **both** access keys set as strings,
1363
+ pass the token here if needed; `AWS_SESSION_TOKEN` from the environment is not
1364
+ used. If either key is taken from the environment, omitting `sessionToken`
1365
+ allows `AWS_SESSION_TOKEN`.
1364
1366
 
1365
1367
  - **apiKey** _string_
1366
1368
 
@@ -1621,8 +1623,4 @@ The `bedrockOptions` provider setting previously available has been removed. If
1621
1623
  you were using the `bedrockOptions` object, you should now use the `region`,
1622
1624
  `accessKeyId`, `secretAccessKey`, and `sessionToken` settings directly instead.
1623
1625
 
1624
- Note that you may need to set all of these explicitly, e.g. even if you're not
1625
- using `sessionToken`, set it to `undefined`. If you're running in a serverless
1626
- environment, there may be default environment variables set by your containing
1627
- environment that the Amazon Bedrock provider will then pick up and could
1628
- conflict with the ones you're intending to use.
1626
+ Static IAM user keys do not require `sessionToken`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "5.0.0-beta.44",
3
+ "version": "5.0.0-beta.45",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -38,16 +38,16 @@
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": "4.0.0-beta.40",
42
- "@ai-sdk/provider": "4.0.0-beta.13",
43
- "@ai-sdk/provider-utils": "5.0.0-beta.28"
41
+ "@ai-sdk/anthropic": "4.0.0-beta.41",
42
+ "@ai-sdk/provider": "4.0.0-beta.14",
43
+ "@ai-sdk/provider-utils": "5.0.0-beta.29"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "20.17.24",
47
47
  "tsup": "^8.3.0",
48
48
  "typescript": "5.8.3",
49
49
  "zod": "3.25.76",
50
- "@ai-sdk/test-server": "2.0.0-beta.2",
50
+ "@ai-sdk/test-server": "2.0.0-beta.3",
51
51
  "@vercel/ai-tsconfig": "0.0.0"
52
52
  },
53
53
  "peerDependencies": {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  convertBase64ToUint8Array,
3
- FetchFunction,
4
3
  safeParseJSON,
4
+ type FetchFunction,
5
5
  } from '@ai-sdk/provider-utils';
6
6
  import { z } from 'zod/v4';
7
7
  import { createBedrockEventStreamDecoder } from '../bedrock-event-stream-decoder';
@@ -1,28 +1,28 @@
1
1
  import {
2
- LanguageModelV4,
3
2
  NoSuchModelError,
4
- ProviderV4,
3
+ type LanguageModelV4,
4
+ type ProviderV4,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
- FetchFunction,
8
7
  loadOptionalSetting,
9
8
  loadSetting,
10
- Resolvable,
11
9
  resolve,
12
10
  withoutTrailingSlash,
13
11
  withUserAgentSuffix,
12
+ type FetchFunction,
13
+ type Resolvable,
14
14
  } from '@ai-sdk/provider-utils';
15
15
  import {
16
16
  anthropicTools,
17
17
  AnthropicLanguageModel,
18
18
  } from '@ai-sdk/anthropic/internal';
19
19
  import {
20
- BedrockCredentials,
21
20
  createApiKeyFetchFunction,
22
21
  createSigV4FetchFunction,
22
+ type BedrockCredentials,
23
23
  } from '../bedrock-sigv4-fetch';
24
24
  import { createBedrockAnthropicFetch } from './bedrock-anthropic-fetch';
25
- import { BedrockAnthropicModelId } from './bedrock-anthropic-options';
25
+ import type { BedrockAnthropicModelId } from './bedrock-anthropic-options';
26
26
  import { VERSION } from '../version';
27
27
 
28
28
  // Bedrock requires newer tool versions than the default Anthropic SDK versions
@@ -1,4 +1,4 @@
1
- import { JSONObject } from '@ai-sdk/provider';
1
+ import type { JSONObject } from '@ai-sdk/provider';
2
2
 
3
3
  export interface BedrockConverseInput {
4
4
  system?: BedrockSystemMessages;
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  JSONObject,
3
3
  LanguageModelV4,
4
4
  LanguageModelV4CallOptions,
@@ -13,9 +13,6 @@ import {
13
13
  SharedV4Warning,
14
14
  } from '@ai-sdk/provider';
15
15
  import {
16
- FetchFunction,
17
- ParseResult,
18
- Resolvable,
19
16
  combineHeaders,
20
17
  createJsonErrorResponseHandler,
21
18
  createJsonResponseHandler,
@@ -28,26 +25,33 @@ import {
28
25
  serializeModelOptions,
29
26
  WORKFLOW_SERIALIZE,
30
27
  WORKFLOW_DESERIALIZE,
28
+ type FetchFunction,
29
+ type ParseResult,
30
+ type Resolvable,
31
31
  } from '@ai-sdk/provider-utils';
32
32
  import { getModelCapabilities } from '@ai-sdk/anthropic/internal';
33
33
  import { z } from 'zod/v4';
34
34
  import {
35
35
  BEDROCK_STOP_REASONS,
36
- BedrockConverseInput,
37
- BedrockStopReason,
36
+ type BedrockConverseInput,
37
+ type BedrockStopReason,
38
38
  } from './bedrock-api-types';
39
39
  import {
40
- AmazonBedrockLanguageModelOptions,
41
- BedrockChatModelId,
42
40
  amazonBedrockLanguageModelOptions,
41
+ type AmazonBedrockLanguageModelOptions,
42
+ type BedrockChatModelId,
43
43
  } from './bedrock-chat-options';
44
44
  import { BedrockErrorSchema } from './bedrock-error';
45
45
  import { createBedrockEventStreamResponseHandler } from './bedrock-event-stream-response-handler';
46
46
  import { prepareTools } from './bedrock-prepare-tools';
47
- import { BedrockUsage, convertBedrockUsage } from './convert-bedrock-usage';
47
+ import {
48
+ convertBedrockUsage,
49
+ type BedrockUsage,
50
+ } from './convert-bedrock-usage';
48
51
  import { convertToBedrockChatMessages } from './convert-to-bedrock-chat-messages';
49
52
  import { mapBedrockFinishReason } from './map-bedrock-finish-reason';
50
53
  import { isMistralModel, normalizeToolCallId } from './normalize-tool-call-id';
54
+ import type { BedrockReasoningMetadata } from './bedrock-reasoning-metadata';
51
55
 
52
56
  type BedrockChatConfig = {
53
57
  baseUrl: () => string;
@@ -1177,14 +1181,10 @@ const BedrockStreamSchema = z.object({
1177
1181
  validationException: z.record(z.string(), z.unknown()).nullish(),
1178
1182
  });
1179
1183
 
1180
- export const bedrockReasoningMetadataSchema = z.object({
1181
- signature: z.string().optional(),
1182
- redactedData: z.string().optional(),
1183
- });
1184
-
1185
- export type BedrockReasoningMetadata = z.infer<
1186
- typeof bedrockReasoningMetadataSchema
1187
- >;
1184
+ export {
1185
+ bedrockReasoningMetadataSchema,
1186
+ type BedrockReasoningMetadata,
1187
+ } from './bedrock-reasoning-metadata';
1188
1188
 
1189
1189
  const bedrockReasoningEffortMap: Partial<
1190
1190
  Record<string, 'low' | 'medium' | 'high' | 'max'>
@@ -1,10 +1,8 @@
1
1
  import {
2
- EmbeddingModelV4,
3
2
  TooManyEmbeddingValuesForCallError,
3
+ type EmbeddingModelV4,
4
4
  } from '@ai-sdk/provider';
5
5
  import {
6
- FetchFunction,
7
- Resolvable,
8
6
  combineHeaders,
9
7
  createJsonErrorResponseHandler,
10
8
  createJsonResponseHandler,
@@ -14,10 +12,12 @@ import {
14
12
  serializeModelOptions,
15
13
  WORKFLOW_SERIALIZE,
16
14
  WORKFLOW_DESERIALIZE,
15
+ type FetchFunction,
16
+ type Resolvable,
17
17
  } from '@ai-sdk/provider-utils';
18
18
  import {
19
- BedrockEmbeddingModelId,
20
19
  amazonBedrockEmbeddingModelOptionsSchema,
20
+ type BedrockEmbeddingModelId,
21
21
  } from './bedrock-embedding-options';
22
22
  import { BedrockErrorSchema } from './bedrock-error';
23
23
  import { z } from 'zod/v4';
@@ -1,12 +1,12 @@
1
1
  import { EmptyResponseBodyError } from '@ai-sdk/provider';
2
2
  import {
3
- ParseResult,
4
3
  safeParseJSON,
5
4
  extractResponseHeaders,
6
- ResponseHandler,
7
5
  safeValidateTypes,
6
+ type ParseResult,
7
+ type ResponseHandler,
8
8
  } from '@ai-sdk/provider-utils';
9
- import { ZodType } from 'zod/v4';
9
+ import type { ZodType } from 'zod/v4';
10
10
  import { createBedrockEventStreamDecoder } from './bedrock-event-stream-decoder';
11
11
 
12
12
  export const createBedrockEventStreamResponseHandler =
@@ -1,11 +1,9 @@
1
- import {
1
+ import type {
2
2
  ImageModelV4,
3
3
  ImageModelV4File,
4
4
  SharedV4Warning,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
- FetchFunction,
8
- Resolvable,
9
7
  combineHeaders,
10
8
  convertUint8ArrayToBase64,
11
9
  createJsonErrorResponseHandler,
@@ -15,10 +13,12 @@ import {
15
13
  serializeModelOptions,
16
14
  WORKFLOW_SERIALIZE,
17
15
  WORKFLOW_DESERIALIZE,
16
+ type FetchFunction,
17
+ type Resolvable,
18
18
  } from '@ai-sdk/provider-utils';
19
19
  import {
20
- BedrockImageModelId,
21
20
  modelMaxImagesPerCall,
21
+ type BedrockImageModelId,
22
22
  } from './bedrock-image-settings';
23
23
  import { BedrockErrorSchema } from './bedrock-error';
24
24
  import { z } from 'zod/v4';
@@ -1,15 +1,18 @@
1
1
  import {
2
- JSONObject,
3
- LanguageModelV4CallOptions,
4
- SharedV4Warning,
5
2
  UnsupportedFunctionalityError,
3
+ type JSONObject,
4
+ type LanguageModelV4CallOptions,
5
+ type SharedV4Warning,
6
6
  } from '@ai-sdk/provider';
7
7
  import { asSchema } from '@ai-sdk/provider-utils';
8
8
  import {
9
9
  anthropicTools,
10
10
  prepareTools as prepareAnthropicTools,
11
11
  } from '@ai-sdk/anthropic/internal';
12
- import { BedrockTool, BedrockToolConfiguration } from './bedrock-api-types';
12
+ import type {
13
+ BedrockTool,
14
+ BedrockToolConfiguration,
15
+ } from './bedrock-api-types';
13
16
 
14
17
  export async function prepareTools({
15
18
  tools,
@@ -1,5 +1,5 @@
1
1
  import { anthropicTools } from '@ai-sdk/anthropic/internal';
2
- import {
2
+ import type {
3
3
  EmbeddingModelV4,
4
4
  ImageModelV4,
5
5
  LanguageModelV4,
@@ -7,26 +7,26 @@ import {
7
7
  RerankingModelV4,
8
8
  } from '@ai-sdk/provider';
9
9
  import {
10
- FetchFunction,
11
10
  generateId,
12
11
  loadOptionalSetting,
13
12
  loadSetting,
14
13
  withoutTrailingSlash,
15
14
  withUserAgentSuffix,
15
+ type FetchFunction,
16
16
  } from '@ai-sdk/provider-utils';
17
17
  import { BedrockChatLanguageModel } from './bedrock-chat-language-model';
18
- import { BedrockChatModelId } from './bedrock-chat-options';
18
+ import type { BedrockChatModelId } from './bedrock-chat-options';
19
19
  import { BedrockEmbeddingModel } from './bedrock-embedding-model';
20
- import { BedrockEmbeddingModelId } from './bedrock-embedding-options';
20
+ import type { BedrockEmbeddingModelId } from './bedrock-embedding-options';
21
21
  import { BedrockImageModel } from './bedrock-image-model';
22
- import { BedrockImageModelId } from './bedrock-image-settings';
22
+ import type { BedrockImageModelId } from './bedrock-image-settings';
23
23
  import {
24
- BedrockCredentials,
25
24
  createApiKeyFetchFunction,
26
25
  createSigV4FetchFunction,
26
+ type BedrockCredentials,
27
27
  } from './bedrock-sigv4-fetch';
28
28
  import { BedrockRerankingModel } from './reranking/bedrock-reranking-model';
29
- import { BedrockRerankingModelId } from './reranking/bedrock-reranking-options';
29
+ import type { BedrockRerankingModelId } from './reranking/bedrock-reranking-options';
30
30
  import { VERSION } from './version';
31
31
 
32
32
  export interface AmazonBedrockProviderSettings {
@@ -74,8 +74,10 @@ export interface AmazonBedrockProviderSettings {
74
74
  secretAccessKey?: string;
75
75
 
76
76
  /**
77
- * The AWS session token to use for the Bedrock provider. Defaults to the value of the
78
- * `AWS_SESSION_TOKEN` environment variable.
77
+ * The AWS session token to use for the Bedrock provider. When `accessKeyId` and
78
+ * `secretAccessKey` are both passed explicitly as options, only this field is used
79
+ * If either access key field is omitted and resolved from the environment, the
80
+ * session token also falls back to `AWS_SESSION_TOKEN` when not set here.
79
81
  */
80
82
  sessionToken?: string;
81
83
 
@@ -221,10 +223,13 @@ export function createAmazonBedrock(
221
223
  environmentVariableName: 'AWS_SECRET_ACCESS_KEY',
222
224
  description: 'AWS secret access key',
223
225
  }),
224
- sessionToken: loadOptionalSetting({
225
- settingValue: options.sessionToken,
226
- environmentVariableName: 'AWS_SESSION_TOKEN',
227
- }),
226
+ sessionToken:
227
+ options.accessKeyId != null && options.secretAccessKey != null
228
+ ? options.sessionToken
229
+ : loadOptionalSetting({
230
+ settingValue: options.sessionToken,
231
+ environmentVariableName: 'AWS_SESSION_TOKEN',
232
+ }),
228
233
  };
229
234
  } catch (error) {
230
235
  // Provide helpful error message for missing AWS credentials
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod/v4';
2
+
3
+ export const bedrockReasoningMetadataSchema = z.object({
4
+ signature: z.string().optional(),
5
+ redactedData: z.string().optional(),
6
+ });
7
+
8
+ export type BedrockReasoningMetadata = z.infer<
9
+ typeof bedrockReasoningMetadataSchema
10
+ >;
@@ -1,9 +1,9 @@
1
1
  import {
2
- FetchFunction,
3
2
  combineHeaders,
4
3
  normalizeHeaders,
5
4
  withUserAgentSuffix,
6
5
  getRuntimeEnvironmentUserAgent,
6
+ type FetchFunction,
7
7
  } from '@ai-sdk/provider-utils';
8
8
  import { AwsV4Signer } from 'aws4fetch';
9
9
  import { VERSION } from './version';
@@ -1,4 +1,4 @@
1
- import { LanguageModelV4Usage } from '@ai-sdk/provider';
1
+ import type { LanguageModelV4Usage } from '@ai-sdk/provider';
2
2
 
3
3
  export type BedrockUsage = {
4
4
  inputTokens: number;
@@ -1,31 +1,33 @@
1
1
  import {
2
- JSONObject,
3
- LanguageModelV4Message,
4
- LanguageModelV4Prompt,
5
- SharedV4ProviderMetadata,
6
2
  UnsupportedFunctionalityError,
3
+ type JSONObject,
4
+ type LanguageModelV4Message,
5
+ type LanguageModelV4Prompt,
6
+ type SharedV4ProviderMetadata,
7
7
  } from '@ai-sdk/provider';
8
8
  import {
9
9
  convertToBase64,
10
- isProviderReference,
10
+ getTopLevelMediaType,
11
+ isFullMediaType,
11
12
  parseProviderOptions,
13
+ resolveFullMediaType,
12
14
  stripFileExtension,
13
15
  } from '@ai-sdk/provider-utils';
14
16
  import {
15
17
  BEDROCK_DOCUMENT_MIME_TYPES,
16
18
  BEDROCK_IMAGE_MIME_TYPES,
17
- BedrockAssistantMessage,
18
- BedrockCachePoint,
19
- BedrockDocumentFormat,
20
- BedrockDocumentMimeType,
21
- BedrockImageFormat,
22
- BedrockImageMimeType,
23
- BedrockMessages,
24
- BedrockSystemMessages,
25
- BedrockUserMessage,
19
+ type BedrockAssistantMessage,
20
+ type BedrockCachePoint,
21
+ type BedrockDocumentFormat,
22
+ type BedrockDocumentMimeType,
23
+ type BedrockImageFormat,
24
+ type BedrockImageMimeType,
25
+ type BedrockMessages,
26
+ type BedrockSystemMessages,
27
+ type BedrockUserMessage,
26
28
  } from './bedrock-api-types';
27
- import { bedrockReasoningMetadataSchema } from './bedrock-chat-language-model';
28
29
  import { bedrockFilePartProviderOptions } from './bedrock-chat-options';
30
+ import { bedrockReasoningMetadataSchema } from './bedrock-reasoning-metadata';
29
31
  import { normalizeToolCallId } from './normalize-tool-call-id';
30
32
 
31
33
  function getCachePoint(
@@ -113,51 +115,77 @@ export async function convertToBedrockChatMessages(
113
115
  }
114
116
 
115
117
  case 'file': {
116
- if (isProviderReference(part.data)) {
117
- throw new UnsupportedFunctionalityError({
118
- functionality: 'file parts with provider references',
119
- });
120
- }
121
-
122
- if (part.data instanceof URL) {
123
- // The AI SDK automatically downloads files for user file parts with URLs
124
- throw new UnsupportedFunctionalityError({
125
- functionality: 'File URL data',
126
- });
127
- }
128
-
129
- if (part.mediaType.startsWith('image/')) {
130
- bedrockContent.push({
131
- image: {
132
- format: getBedrockImageFormat(part.mediaType),
133
- source: { bytes: convertToBase64(part.data) },
134
- },
135
- });
136
- } else {
137
- if (!part.mediaType) {
118
+ switch (part.data.type) {
119
+ case 'reference': {
120
+ throw new UnsupportedFunctionalityError({
121
+ functionality: 'file parts with provider references',
122
+ });
123
+ }
124
+ case 'url': {
138
125
  throw new UnsupportedFunctionalityError({
139
- functionality: 'file without mime type',
140
- message:
141
- 'File mime type is required in user message part content',
126
+ functionality: 'File URL data',
127
+ });
128
+ }
129
+ case 'text': {
130
+ const textMediaType = isFullMediaType(part.mediaType)
131
+ ? part.mediaType
132
+ : 'text/plain';
133
+ const enableCitations = await shouldEnableCitations(
134
+ part.providerOptions,
135
+ );
136
+
137
+ bedrockContent.push({
138
+ document: {
139
+ format: getBedrockDocumentFormat(textMediaType),
140
+ name: part.filename
141
+ ? stripFileExtension(part.filename)
142
+ : generateDocumentName(),
143
+ source: {
144
+ bytes: convertToBase64(
145
+ new TextEncoder().encode(part.data.text),
146
+ ),
147
+ },
148
+ ...(enableCitations && {
149
+ citations: { enabled: true },
150
+ }),
151
+ },
142
152
  });
153
+ break;
143
154
  }
155
+ case 'data': {
156
+ const fullMediaType = resolveFullMediaType({ part });
144
157
 
145
- const enableCitations = await shouldEnableCitations(
146
- part.providerOptions,
147
- );
148
-
149
- bedrockContent.push({
150
- document: {
151
- format: getBedrockDocumentFormat(part.mediaType),
152
- name: part.filename
153
- ? stripFileExtension(part.filename)
154
- : generateDocumentName(),
155
- source: { bytes: convertToBase64(part.data) },
156
- ...(enableCitations && {
157
- citations: { enabled: true },
158
- }),
159
- },
160
- });
158
+ if (getTopLevelMediaType(fullMediaType) === 'image') {
159
+ bedrockContent.push({
160
+ image: {
161
+ format: getBedrockImageFormat(fullMediaType),
162
+ source: {
163
+ bytes: convertToBase64(part.data.data),
164
+ },
165
+ },
166
+ });
167
+ } else {
168
+ const enableCitations = await shouldEnableCitations(
169
+ part.providerOptions,
170
+ );
171
+
172
+ bedrockContent.push({
173
+ document: {
174
+ format: getBedrockDocumentFormat(fullMediaType),
175
+ name: part.filename
176
+ ? stripFileExtension(part.filename)
177
+ : generateDocumentName(),
178
+ source: {
179
+ bytes: convertToBase64(part.data.data),
180
+ },
181
+ ...(enableCitations && {
182
+ citations: { enabled: true },
183
+ }),
184
+ },
185
+ });
186
+ }
187
+ break;
188
+ }
161
189
  }
162
190
 
163
191
  break;
@@ -370,14 +398,7 @@ export async function convertToBedrockChatMessages(
370
398
  return { system, messages };
371
399
  }
372
400
 
373
- function getBedrockImageFormat(mimeType?: string): BedrockImageFormat {
374
- if (!mimeType) {
375
- throw new UnsupportedFunctionalityError({
376
- functionality: 'image without mime type',
377
- message: 'Image mime type is required in user message part content',
378
- });
379
- }
380
-
401
+ function getBedrockImageFormat(mimeType: string): BedrockImageFormat {
381
402
  const format = BEDROCK_IMAGE_MIME_TYPES[mimeType as BedrockImageMimeType];
382
403
  if (!format) {
383
404
  throw new UnsupportedFunctionalityError({
@@ -1,8 +1,8 @@
1
1
  import {
2
- type FetchFunction,
3
2
  getRuntimeEnvironmentUserAgent,
4
3
  normalizeHeaders,
5
4
  withUserAgentSuffix,
5
+ type FetchFunction,
6
6
  } from '@ai-sdk/provider-utils';
7
7
  import { VERSION } from './version';
8
8
 
@@ -1,5 +1,5 @@
1
- import { LanguageModelV4FinishReason } from '@ai-sdk/provider';
2
- import { BedrockStopReason } from './bedrock-api-types';
1
+ import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';
2
+ import type { BedrockStopReason } from './bedrock-api-types';
3
3
 
4
4
  export function mapBedrockFinishReason(
5
5
  finishReason: BedrockStopReason,
@@ -1,24 +1,23 @@
1
- import { RerankingModelV4 } from '@ai-sdk/provider';
1
+ import type { RerankingModelV4 } from '@ai-sdk/provider';
2
2
  import {
3
- FetchFunction,
4
- Resolvable,
5
3
  combineHeaders,
6
4
  createJsonErrorResponseHandler,
7
5
  createJsonResponseHandler,
8
6
  parseProviderOptions,
9
7
  postJsonToApi,
10
8
  resolve,
9
+ type FetchFunction,
10
+ type Resolvable,
11
11
  } from '@ai-sdk/provider-utils';
12
12
  import { BedrockErrorSchema } from '../bedrock-error';
13
13
  import {
14
- BedrockRerankingInput,
15
14
  bedrockRerankingResponseSchema,
15
+ type BedrockRerankingInput,
16
16
  } from './bedrock-reranking-api';
17
17
  import {
18
- BedrockRerankingModelId,
19
18
  amazonBedrockRerankingModelOptionsSchema,
19
+ type BedrockRerankingModelId,
20
20
  } from './bedrock-reranking-options';
21
-
22
21
  type BedrockRerankingConfig = {
23
22
  baseUrl: () => string;
24
23
  region: string;