@ai-sdk/amazon-bedrock 5.0.92 → 5.0.94

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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 5.0.94
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [154221f]
8
+ - Updated dependencies [ca31b89]
9
+ - @ai-sdk/anthropic@4.0.63
10
+ - @ai-sdk/openai@4.0.75
11
+
12
+ ## 5.0.93
13
+
14
+ ### Patch Changes
15
+
16
+ - b7bc639: fix(amazon-bedrock): route supported Mantle models through the OpenAI endpoint
17
+ - 31fb009: fix(amazon-bedrock): omit unsupported sampling parameters for newer Claude models
18
+ - fbdda09: fix(amazon-bedrock): omit unsupported OpenAI sampling settings from Converse requests
19
+ - 771e74b: chore: enable dead code lint rules
20
+ - Updated dependencies [fe07867]
21
+ - Updated dependencies [a4b0940]
22
+ - Updated dependencies [4cf5a99]
23
+ - Updated dependencies [771e74b]
24
+ - @ai-sdk/provider-utils@5.0.47
25
+ - @ai-sdk/openai@4.0.74
26
+ - @ai-sdk/anthropic@4.0.62
27
+
3
28
  ## 5.0.92
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -50,7 +50,7 @@ import { bedrock } from '@ai-sdk/amazon-bedrock';
50
50
  import { generateText } from 'ai';
51
51
 
52
52
  const { text } = await generateText({
53
- model: bedrock('anthropic.claude-3-haiku-20240307-v1:0'),
53
+ model: bedrock('us.anthropic.claude-haiku-4-5-20251001-v1:0'),
54
54
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
55
55
  // API key is automatically loaded from AWS_BEARER_TOKEN_BEDROCK
56
56
  });
@@ -70,7 +70,7 @@ const bedrockWithApiKey = bedrock.withSettings({
70
70
  });
71
71
 
72
72
  const { text } = await generateText({
73
- model: bedrockWithApiKey('anthropic.claude-3-haiku-20240307-v1:0'),
73
+ model: bedrockWithApiKey('us.anthropic.claude-haiku-4-5-20251001-v1:0'),
74
74
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
75
75
  });
76
76
  ```
@@ -85,7 +85,7 @@ import { generateText } from 'ai';
85
85
 
86
86
  // Uses AWS credentials from environment variables or AWS credential chain
87
87
  const { text } = await generateText({
88
- model: bedrock('anthropic.claude-3-haiku-20240307-v1:0'),
88
+ model: bedrock('us.anthropic.claude-haiku-4-5-20251001-v1:0'),
89
89
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
90
90
  });
91
91
  ```
@@ -23,7 +23,7 @@ import {
23
23
  import { AwsV4Signer } from "aws4fetch";
24
24
 
25
25
  // src/version.ts
26
- var VERSION = true ? "5.0.92" : "0.0.0-test";
26
+ var VERSION = true ? "5.0.94" : "0.0.0-test";
27
27
 
28
28
  // src/amazon-bedrock-sigv4-fetch.ts
29
29
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
package/dist/index.js CHANGED
@@ -1264,6 +1264,11 @@ var AmazonBedrockChatLanguageModel = class _AmazonBedrockChatLanguageModel {
1264
1264
  schema: anthropicProviderOptions
1265
1265
  });
1266
1266
  const warnings = [];
1267
+ const {
1268
+ supportsStructuredOutput: modelSupportsStructuredOutput,
1269
+ rejectsSamplingParameters,
1270
+ rejectsForcedToolUse
1271
+ } = getModelCapabilities(this.modelId);
1267
1272
  if (frequencyPenalty != null) {
1268
1273
  warnings.push({
1269
1274
  type: "unsupported",
@@ -1282,14 +1287,44 @@ var AmazonBedrockChatLanguageModel = class _AmazonBedrockChatLanguageModel {
1282
1287
  feature: "seed"
1283
1288
  });
1284
1289
  }
1285
- if (temperature != null && temperature > 1) {
1290
+ if (rejectsSamplingParameters) {
1291
+ if (temperature != null) {
1292
+ warnings.push({
1293
+ type: "unsupported",
1294
+ feature: "temperature",
1295
+ details: `temperature is not supported by ${this.modelId} and will be ignored`
1296
+ });
1297
+ temperature = void 0;
1298
+ }
1299
+ if (topK != null) {
1300
+ warnings.push({
1301
+ type: "unsupported",
1302
+ feature: "topK",
1303
+ details: `topK is not supported by ${this.modelId} and will be ignored`
1304
+ });
1305
+ topK = void 0;
1306
+ }
1307
+ if (topP != null) {
1308
+ warnings.push({
1309
+ type: "unsupported",
1310
+ feature: "topP",
1311
+ details: `topP is not supported by ${this.modelId} and will be ignored`
1312
+ });
1313
+ topP = void 0;
1314
+ }
1315
+ }
1316
+ const openAIModelId = (_c = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _c[1];
1317
+ const isOpenAIModel = openAIModelId != null;
1318
+ const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
1319
+ const shouldNormalizeTemperature = !isOpenAIModel || isOpenAIGptOssModel;
1320
+ if (shouldNormalizeTemperature && temperature != null && temperature > 1) {
1286
1321
  warnings.push({
1287
1322
  type: "unsupported",
1288
1323
  feature: "temperature",
1289
1324
  details: `${temperature} exceeds bedrock maximum of 1.0. clamped to 1.0`
1290
1325
  });
1291
1326
  temperature = 1;
1292
- } else if (temperature != null && temperature < 0) {
1327
+ } else if (shouldNormalizeTemperature && temperature != null && temperature < 0) {
1293
1328
  warnings.push({
1294
1329
  type: "unsupported",
1295
1330
  feature: "temperature",
@@ -1307,11 +1342,8 @@ var AmazonBedrockChatLanguageModel = class _AmazonBedrockChatLanguageModel {
1307
1342
  const isAnthropicModel2 = isAnthropicModel({
1308
1343
  modelId: this.modelId,
1309
1344
  modelFamily: this.config.modelFamily,
1310
- reasoningBudgetTokens: (_c = amazonBedrockOptions.reasoningConfig) == null ? void 0 : _c.budgetTokens
1345
+ reasoningBudgetTokens: (_e = amazonBedrockOptions.reasoningConfig) == null ? void 0 : _e.budgetTokens
1311
1346
  });
1312
- const openAIModelId = (_d = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _d[1];
1313
- const isOpenAIModel = openAIModelId != null;
1314
- const isOpenAIGptOssModel = (_e = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _e : false;
1315
1347
  amazonBedrockOptions = resolveAmazonBedrockReasoningConfig({
1316
1348
  reasoning,
1317
1349
  amazonBedrockOptions,
@@ -1320,10 +1352,6 @@ var AmazonBedrockChatLanguageModel = class _AmazonBedrockChatLanguageModel {
1320
1352
  modelId: this.modelId
1321
1353
  });
1322
1354
  const isThinkingEnabled = ((_f = amazonBedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "enabled" || ((_g = amazonBedrockOptions.reasoningConfig) == null ? void 0 : _g.type) === "adaptive";
1323
- const {
1324
- supportsStructuredOutput: modelSupportsStructuredOutput,
1325
- rejectsForcedToolUse
1326
- } = getModelCapabilities(this.modelId);
1327
1355
  const structuredOutputMode = (_i = (_h = amazonBedrockOptions.structuredOutputMode) != null ? _h : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _i : "auto";
1328
1356
  if (structuredOutputMode === "jsonTool") {
1329
1357
  const additionalModelRequestFields = {
@@ -1494,6 +1522,19 @@ var AmazonBedrockChatLanguageModel = class _AmazonBedrockChatLanguageModel {
1494
1522
  details: "topK is not supported when thinking is enabled"
1495
1523
  });
1496
1524
  }
1525
+ if (isOpenAIModel) {
1526
+ const unsupportedFeatures = isOpenAIGptOssModel ? ["stopSequences"] : ["temperature", "topP", "stopSequences"];
1527
+ for (const feature of unsupportedFeatures) {
1528
+ if (inferenceConfig[feature] != null) {
1529
+ delete inferenceConfig[feature];
1530
+ warnings.push({
1531
+ type: "unsupported",
1532
+ feature,
1533
+ details: `${feature} is not supported by this OpenAI model on the Converse API`
1534
+ });
1535
+ }
1536
+ }
1537
+ }
1497
1538
  const hasAnyTools = ((_u = (_t = toolConfig.tools) == null ? void 0 : _t.length) != null ? _u : 0) > 0 || additionalTools;
1498
1539
  let filteredPrompt = prompt;
1499
1540
  if (!hasAnyTools) {
@@ -2846,7 +2887,7 @@ import {
2846
2887
  import { AwsV4Signer } from "aws4fetch";
2847
2888
 
2848
2889
  // src/version.ts
2849
- var VERSION = true ? "5.0.92" : "0.0.0-test";
2890
+ var VERSION = true ? "5.0.94" : "0.0.0-test";
2850
2891
 
2851
2892
  // src/amazon-bedrock-sigv4-fetch.ts
2852
2893
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {