@ai-sdk/amazon-bedrock 5.0.101 → 5.0.103
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 +25 -0
- package/dist/anthropic/index.d.ts +79 -76
- package/dist/anthropic/index.d.ts.map +1 -0
- package/dist/anthropic/index.js +433 -521
- package/dist/anthropic/index.js.map +1 -1
- package/dist/index.d.ts +218 -211
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2551 -3233
- package/dist/index.js.map +1 -1
- package/dist/mantle/index.cjs +190 -235
- package/dist/mantle/index.cjs.map +1 -1
- package/dist/mantle/index.d.cts +85 -82
- package/dist/mantle/index.d.cts.map +1 -0
- package/dist/mantle/index.d.ts +85 -82
- package/dist/mantle/index.d.ts.map +1 -0
- package/dist/mantle/index.js +187 -221
- package/dist/mantle/index.js.map +1 -1
- package/docs/08-amazon-bedrock.mdx +2 -2
- package/package.json +10 -10
- package/src/mantle/bedrock-mantle-provider.ts +29 -15
- package/src/resolve-amazon-bedrock-base-url.ts +9 -0
|
@@ -3,11 +3,13 @@ import {
|
|
|
3
3
|
OpenAIResponsesLanguageModel,
|
|
4
4
|
} from '@ai-sdk/openai/internal';
|
|
5
5
|
import {
|
|
6
|
+
InvalidArgumentError,
|
|
6
7
|
NoSuchModelError,
|
|
7
8
|
type LanguageModelV4,
|
|
8
9
|
type ProviderV4,
|
|
9
10
|
} from '@ai-sdk/provider';
|
|
10
11
|
import {
|
|
12
|
+
isValidHostnamePart,
|
|
11
13
|
loadOptionalSetting,
|
|
12
14
|
loadSetting,
|
|
13
15
|
withoutTrailingSlash,
|
|
@@ -215,21 +217,33 @@ export function createBedrockMantle(
|
|
|
215
217
|
'bedrock-mantle',
|
|
216
218
|
);
|
|
217
219
|
|
|
218
|
-
const getBaseURL = (modelId: string): string =>
|
|
219
|
-
withoutTrailingSlash(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
220
|
+
const getBaseURL = (modelId: string): string => {
|
|
221
|
+
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
222
|
+
if (baseURL != null) {
|
|
223
|
+
return baseURL;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const region = loadSetting({
|
|
227
|
+
settingValue: options.region,
|
|
228
|
+
settingName: 'region',
|
|
229
|
+
environmentVariableName: 'AWS_REGION',
|
|
230
|
+
description: 'AWS region',
|
|
231
|
+
});
|
|
232
|
+
if (!isValidHostnamePart(region)) {
|
|
233
|
+
throw new InvalidArgumentError({
|
|
234
|
+
argument: 'region',
|
|
235
|
+
message:
|
|
236
|
+
'Invalid AWS region. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return `https://bedrock-mantle.${region}.api.aws/${
|
|
241
|
+
// Mantle serves these models under its separate OpenAI route.
|
|
242
|
+
/^(?:openai\.gpt-(?!oss-)|google\.gemma-4|xai\.)/.test(modelId)
|
|
243
|
+
? 'openai/v1'
|
|
244
|
+
: 'v1'
|
|
245
|
+
}`;
|
|
246
|
+
};
|
|
233
247
|
|
|
234
248
|
const getHeaders = (): Record<string, string | undefined> =>
|
|
235
249
|
withUserAgentSuffix(
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { InvalidArgumentError } from '@ai-sdk/provider';
|
|
1
2
|
import {
|
|
3
|
+
isValidHostnamePart,
|
|
2
4
|
loadOptionalSetting,
|
|
3
5
|
withoutTrailingSlash,
|
|
4
6
|
} from '@ai-sdk/provider-utils';
|
|
@@ -41,6 +43,13 @@ export function resolveAmazonBedrockBaseURL({
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
const region = getRegion();
|
|
46
|
+
if (!isValidHostnamePart(region)) {
|
|
47
|
+
throw new InvalidArgumentError({
|
|
48
|
+
argument: 'region',
|
|
49
|
+
message:
|
|
50
|
+
'Invalid AWS region. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
44
53
|
const dnsSuffix =
|
|
45
54
|
AWS_PARTITION_DNS_SUFFIXES.find(({ regionPrefix }) =>
|
|
46
55
|
region.startsWith(regionPrefix),
|