@ai-sdk/amazon-bedrock 5.0.105 → 5.0.107
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 +38 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/index.js +38 -25
- package/dist/index.js.map +1 -1
- package/dist/mantle/index.cjs +1 -1
- package/dist/mantle/index.js +1 -1
- package/docs/08-amazon-bedrock.mdx +18 -0
- package/package.json +7 -7
- package/src/amazon-bedrock-chat-language-model.ts +59 -37
package/dist/mantle/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let _ai_sdk_provider = require("@ai-sdk/provider");
|
|
|
4
4
|
let _ai_sdk_provider_utils = require("@ai-sdk/provider-utils");
|
|
5
5
|
let aws4fetch = require("aws4fetch");
|
|
6
6
|
//#region src/version.ts
|
|
7
|
-
const VERSION = "5.0.
|
|
7
|
+
const VERSION = "5.0.107";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/amazon-bedrock-sigv4-fetch.ts
|
|
10
10
|
/**
|
package/dist/mantle/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
|
|
|
3
3
|
import { combineHeaders, getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSetting, loadSetting, normalizeHeaders, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
|
|
4
4
|
import { AwsV4Signer } from "aws4fetch";
|
|
5
5
|
//#region src/version.ts
|
|
6
|
-
const VERSION = "5.0.
|
|
6
|
+
const VERSION = "5.0.107";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/amazon-bedrock-sigv4-fetch.ts
|
|
9
9
|
/**
|
|
@@ -635,6 +635,24 @@ Amazon Bedrock supports model creator-specific reasoning features:
|
|
|
635
635
|
- Anthropic (e.g. `claude-sonnet-4-5-20250929`): enable via the `reasoningConfig` provider option and specifying a thinking budget in tokens (minimum: `1024`, maximum: `64000`).
|
|
636
636
|
- Amazon (e.g. `us.amazon.nova-2-lite-v1:0`): enable via the `reasoningConfig` provider option and specifying a maximum reasoning effort level (`'low' | 'medium' | 'high'`).
|
|
637
637
|
|
|
638
|
+
You can also use the top-level `reasoning` parameter. For Amazon Nova 2, `'xhigh'` and `'max'` are mapped to `'high'` with a compatibility warning. Anthropic and OpenAI effort mappings preserve `'max'`.
|
|
639
|
+
|
|
640
|
+
Bedrock combines partial `providerOptions.amazonBedrock.reasoningConfig` with
|
|
641
|
+
portable reasoning, preserving explicit values and deriving missing fields for
|
|
642
|
+
the model's reasoning API. An explicit `maxReasoningEffort` replaces the effort
|
|
643
|
+
mapping without emitting a coercion warning for the overridden value. For
|
|
644
|
+
budget-based Anthropic models, `{ budgetTokens: 5000 }` preserves that budget and
|
|
645
|
+
uses portable reasoning to fill a missing `type: 'enabled'`. Type-only,
|
|
646
|
+
display-only, and empty configurations also retain portable reasoning.
|
|
647
|
+
|
|
648
|
+
Effort-based Anthropic models can combine portable effort with an explicit
|
|
649
|
+
thinking configuration. A disabled type prevents effort/budget derivation;
|
|
650
|
+
portable `reasoning: 'none'` disables thinking on Anthropic models even when an
|
|
651
|
+
enabled type or budget is supplied. Omitting portable reasoning or using
|
|
652
|
+
`'provider-default'` leaves the provider configuration unchanged. The legacy
|
|
653
|
+
`bedrock` provider options key follows the same rules. See the
|
|
654
|
+
[reasoning guide](/docs/ai-sdk-core/reasoning#precedence-rules) for precedence details.
|
|
655
|
+
|
|
638
656
|
```ts
|
|
639
657
|
import {
|
|
640
658
|
amazonBedrock,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/amazon-bedrock",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.107",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@ai-sdk/anthropic": "4.0.
|
|
45
|
-
"@ai-sdk/openai": "4.0.
|
|
46
|
-
"@ai-sdk/provider": "4.0.
|
|
47
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
44
|
+
"@ai-sdk/anthropic": "4.0.73",
|
|
45
|
+
"@ai-sdk/openai": "4.0.85",
|
|
46
|
+
"@ai-sdk/provider": "4.0.23",
|
|
47
|
+
"@ai-sdk/provider-utils": "5.0.55",
|
|
48
48
|
"@smithy/eventstream-codec": "^4.3.3",
|
|
49
49
|
"@smithy/util-utf8": "^4.3.3",
|
|
50
50
|
"aws4fetch": "^1.0.20"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@ai-sdk/test-server": "2.0.
|
|
53
|
+
"@ai-sdk/test-server": "2.0.4",
|
|
54
54
|
"@types/node": "22.19.19",
|
|
55
55
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
56
56
|
"tsdown": "^0.23.0",
|
|
57
|
-
"typescript": "
|
|
57
|
+
"typescript": "6.0.3",
|
|
58
58
|
"zod": "3.25.76"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1624,6 +1624,18 @@ const amazonBedrockReasoningEffortMap: Partial<
|
|
|
1624
1624
|
medium: 'medium',
|
|
1625
1625
|
high: 'high',
|
|
1626
1626
|
xhigh: 'max',
|
|
1627
|
+
max: 'max',
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
const amazonNovaReasoningEffortMap: Partial<
|
|
1631
|
+
Record<string, 'low' | 'medium' | 'high'>
|
|
1632
|
+
> = {
|
|
1633
|
+
minimal: 'low',
|
|
1634
|
+
low: 'low',
|
|
1635
|
+
medium: 'medium',
|
|
1636
|
+
high: 'high',
|
|
1637
|
+
xhigh: 'high',
|
|
1638
|
+
max: 'high',
|
|
1627
1639
|
};
|
|
1628
1640
|
|
|
1629
1641
|
function isNova2ReasoningModel(modelId: string): boolean {
|
|
@@ -1645,16 +1657,27 @@ function resolveAmazonBedrockReasoningConfig({
|
|
|
1645
1657
|
isOpenAIModel: boolean;
|
|
1646
1658
|
modelId: string;
|
|
1647
1659
|
}): AmazonBedrockLanguageModelChatOptions {
|
|
1660
|
+
const reasoningConfig = amazonBedrockOptions.reasoningConfig;
|
|
1661
|
+
|
|
1648
1662
|
if (!isCustomReasoning(reasoning)) {
|
|
1649
1663
|
return amazonBedrockOptions;
|
|
1650
1664
|
}
|
|
1651
1665
|
|
|
1652
1666
|
const result = { ...amazonBedrockOptions };
|
|
1667
|
+
|
|
1668
|
+
// Preserve disabled thinking without deriving settings or warnings that will
|
|
1669
|
+
// not be sent. Clone the configuration before removing effort and budget.
|
|
1670
|
+
if (reasoningConfig?.type === 'disabled') {
|
|
1671
|
+
result.reasoningConfig = { ...reasoningConfig };
|
|
1672
|
+
delete result.reasoningConfig.maxReasoningEffort;
|
|
1673
|
+
delete result.reasoningConfig.budgetTokens;
|
|
1674
|
+
return result;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1653
1677
|
const hasPortableReasoning = reasoning !== 'none';
|
|
1654
|
-
const hasExplicitReasoningConfig =
|
|
1655
|
-
amazonBedrockOptions.reasoningConfig != null;
|
|
1656
1678
|
const isNovaReasoningModel = isNova2ReasoningModel(modelId);
|
|
1657
|
-
const supportsPortableReasoning =
|
|
1679
|
+
const supportsPortableReasoning =
|
|
1680
|
+
isOpenAIModel || isNovaReasoningModel || reasoningConfig != null;
|
|
1658
1681
|
|
|
1659
1682
|
if (isAnthropicModel) {
|
|
1660
1683
|
const capabilities = getModelCapabilities(modelId);
|
|
@@ -1662,42 +1685,52 @@ function resolveAmazonBedrockReasoningConfig({
|
|
|
1662
1685
|
if (reasoning === 'none') {
|
|
1663
1686
|
result.reasoningConfig = { type: 'disabled' };
|
|
1664
1687
|
} else if (capabilities.supportsAdaptiveThinking) {
|
|
1665
|
-
const effort =
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1688
|
+
const effort =
|
|
1689
|
+
reasoningConfig?.maxReasoningEffort ??
|
|
1690
|
+
mapReasoningToProviderEffort({
|
|
1691
|
+
reasoning,
|
|
1692
|
+
effortMap: amazonBedrockReasoningEffortMap,
|
|
1693
|
+
warnings,
|
|
1694
|
+
});
|
|
1670
1695
|
result.reasoningConfig = {
|
|
1671
|
-
|
|
1696
|
+
...reasoningConfig,
|
|
1697
|
+
type: reasoningConfig?.type ?? 'adaptive',
|
|
1672
1698
|
maxReasoningEffort: effort,
|
|
1673
|
-
...amazonBedrockOptions.reasoningConfig,
|
|
1674
1699
|
};
|
|
1675
1700
|
} else {
|
|
1676
|
-
const budgetTokens =
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1701
|
+
const budgetTokens =
|
|
1702
|
+
reasoningConfig?.budgetTokens ??
|
|
1703
|
+
mapReasoningToProviderBudget({
|
|
1704
|
+
reasoning,
|
|
1705
|
+
maxOutputTokens: capabilities.maxOutputTokens,
|
|
1706
|
+
maxReasoningBudget: capabilities.maxOutputTokens,
|
|
1707
|
+
warnings,
|
|
1708
|
+
});
|
|
1682
1709
|
if (budgetTokens != null) {
|
|
1683
1710
|
result.reasoningConfig = {
|
|
1684
|
-
|
|
1711
|
+
...reasoningConfig,
|
|
1712
|
+
type: reasoningConfig?.type ?? 'enabled',
|
|
1685
1713
|
budgetTokens,
|
|
1686
|
-
...amazonBedrockOptions.reasoningConfig,
|
|
1687
1714
|
};
|
|
1688
1715
|
}
|
|
1689
1716
|
}
|
|
1690
1717
|
} else if (hasPortableReasoning) {
|
|
1691
|
-
if (supportsPortableReasoning
|
|
1692
|
-
const effort =
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1718
|
+
if (supportsPortableReasoning) {
|
|
1719
|
+
const effort =
|
|
1720
|
+
reasoningConfig?.maxReasoningEffort ??
|
|
1721
|
+
mapReasoningToProviderEffort({
|
|
1722
|
+
reasoning,
|
|
1723
|
+
effortMap: isNovaReasoningModel
|
|
1724
|
+
? amazonNovaReasoningEffortMap
|
|
1725
|
+
: amazonBedrockReasoningEffortMap,
|
|
1726
|
+
warnings,
|
|
1727
|
+
});
|
|
1697
1728
|
result.reasoningConfig = {
|
|
1698
|
-
...
|
|
1729
|
+
...reasoningConfig,
|
|
1730
|
+
...(isNovaReasoningModel && {
|
|
1731
|
+
type: reasoningConfig?.type ?? 'enabled',
|
|
1732
|
+
}),
|
|
1699
1733
|
maxReasoningEffort: effort,
|
|
1700
|
-
...amazonBedrockOptions.reasoningConfig,
|
|
1701
1734
|
};
|
|
1702
1735
|
} else {
|
|
1703
1736
|
warnings.push({
|
|
@@ -1709,16 +1742,5 @@ function resolveAmazonBedrockReasoningConfig({
|
|
|
1709
1742
|
}
|
|
1710
1743
|
}
|
|
1711
1744
|
|
|
1712
|
-
/*
|
|
1713
|
-
* Mirror anthropic-messages-language-model.ts: when the merged type ends up
|
|
1714
|
-
* 'disabled' (user override combined with a non-none reasoning), strip
|
|
1715
|
-
* derived effort/budget so downstream does not emit output_config.effort
|
|
1716
|
-
* alongside disabled thinking.
|
|
1717
|
-
*/
|
|
1718
|
-
if (result.reasoningConfig?.type === 'disabled') {
|
|
1719
|
-
delete result.reasoningConfig.maxReasoningEffort;
|
|
1720
|
-
delete result.reasoningConfig.budgetTokens;
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
1745
|
return result;
|
|
1724
1746
|
}
|