@ai-sdk/anthropic 2.0.58 → 2.0.60
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 +12 -0
- package/dist/index.d.mts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +42 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +42 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@ai-sdk/provider-utils";
|
|
12
12
|
|
|
13
13
|
// src/version.ts
|
|
14
|
-
var VERSION = true ? "2.0.
|
|
14
|
+
var VERSION = true ? "2.0.60" : "0.0.0-test";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-messages-language-model.ts
|
|
17
17
|
import {
|
|
@@ -577,10 +577,20 @@ var anthropicProviderOptions = z3.object({
|
|
|
577
577
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
578
578
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
579
579
|
*/
|
|
580
|
-
thinking: z3.
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
580
|
+
thinking: z3.discriminatedUnion("type", [
|
|
581
|
+
z3.object({
|
|
582
|
+
/** for Opus 4.6 and newer models */
|
|
583
|
+
type: z3.literal("adaptive")
|
|
584
|
+
}),
|
|
585
|
+
z3.object({
|
|
586
|
+
/** for models before Opus 4.6 */
|
|
587
|
+
type: z3.literal("enabled"),
|
|
588
|
+
budgetTokens: z3.number().optional()
|
|
589
|
+
}),
|
|
590
|
+
z3.object({
|
|
591
|
+
type: z3.literal("disabled")
|
|
592
|
+
})
|
|
593
|
+
]).optional(),
|
|
584
594
|
/**
|
|
585
595
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
586
596
|
* When set to true, Claude will use at most one tool per response.
|
|
@@ -612,7 +622,12 @@ var anthropicProviderOptions = z3.object({
|
|
|
612
622
|
/**
|
|
613
623
|
* @default 'high'
|
|
614
624
|
*/
|
|
615
|
-
effort: z3.enum(["low", "medium", "high"]).optional()
|
|
625
|
+
effort: z3.enum(["low", "medium", "high", "max"]).optional(),
|
|
626
|
+
/**
|
|
627
|
+
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
628
|
+
* Only supported with claude-opus-4-6.
|
|
629
|
+
*/
|
|
630
|
+
speed: z3.literal("fast").optional()
|
|
616
631
|
});
|
|
617
632
|
|
|
618
633
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1894,8 +1909,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1894
1909
|
warnings,
|
|
1895
1910
|
cacheControlValidator
|
|
1896
1911
|
});
|
|
1897
|
-
const
|
|
1898
|
-
const
|
|
1912
|
+
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
1913
|
+
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
1914
|
+
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
1899
1915
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
1900
1916
|
const baseArgs = {
|
|
1901
1917
|
// model id:
|
|
@@ -1908,11 +1924,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1908
1924
|
stop_sequences: stopSequences,
|
|
1909
1925
|
// provider specific settings:
|
|
1910
1926
|
...isThinking && {
|
|
1911
|
-
thinking: {
|
|
1927
|
+
thinking: {
|
|
1928
|
+
type: thinkingType,
|
|
1929
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
1930
|
+
}
|
|
1912
1931
|
},
|
|
1913
1932
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
1914
1933
|
output_config: { effort: anthropicOptions.effort }
|
|
1915
1934
|
},
|
|
1935
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
1936
|
+
speed: anthropicOptions.speed
|
|
1937
|
+
},
|
|
1916
1938
|
// structured output:
|
|
1917
1939
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
1918
1940
|
output_format: {
|
|
@@ -1936,7 +1958,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1936
1958
|
messages: messagesPrompt.messages
|
|
1937
1959
|
};
|
|
1938
1960
|
if (isThinking) {
|
|
1939
|
-
if (thinkingBudget == null) {
|
|
1961
|
+
if (thinkingType === "enabled" && thinkingBudget == null) {
|
|
1940
1962
|
throw new UnsupportedFunctionalityError3({
|
|
1941
1963
|
functionality: "thinking requires a budget"
|
|
1942
1964
|
});
|
|
@@ -1965,7 +1987,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1965
1987
|
details: "topP is not supported when thinking is enabled"
|
|
1966
1988
|
});
|
|
1967
1989
|
}
|
|
1968
|
-
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
1990
|
+
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
1969
1991
|
}
|
|
1970
1992
|
if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
1971
1993
|
if (maxOutputTokens != null) {
|
|
@@ -1993,6 +2015,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1993
2015
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
1994
2016
|
betas.add("effort-2025-11-24");
|
|
1995
2017
|
}
|
|
2018
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.speed) {
|
|
2019
|
+
betas.add("fast-mode-2026-02-01");
|
|
2020
|
+
}
|
|
1996
2021
|
if (useStructuredOutput) {
|
|
1997
2022
|
betas.add("structured-outputs-2025-11-13");
|
|
1998
2023
|
}
|
|
@@ -2854,7 +2879,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2854
2879
|
}
|
|
2855
2880
|
};
|
|
2856
2881
|
function getModelCapabilities(modelId) {
|
|
2857
|
-
if (modelId.includes("claude-
|
|
2882
|
+
if (modelId.includes("claude-opus-4-6")) {
|
|
2883
|
+
return {
|
|
2884
|
+
maxOutputTokens: 128e3,
|
|
2885
|
+
supportsStructuredOutput: true,
|
|
2886
|
+
isKnownModel: true
|
|
2887
|
+
};
|
|
2888
|
+
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
|
|
2858
2889
|
return {
|
|
2859
2890
|
maxOutputTokens: 64e3,
|
|
2860
2891
|
supportsStructuredOutput: true,
|