@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
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | (string & {});
|
|
5
|
+
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-opus-4-6' | (string & {});
|
|
6
6
|
|
|
7
7
|
type AnthropicMessagesConfig = {
|
|
8
8
|
provider: string;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | (string & {});
|
|
5
|
+
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-opus-4-6' | (string & {});
|
|
6
6
|
|
|
7
7
|
type AnthropicMessagesConfig = {
|
|
8
8
|
provider: string;
|
package/dist/internal/index.js
CHANGED
|
@@ -575,10 +575,20 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
575
575
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
576
576
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
577
577
|
*/
|
|
578
|
-
thinking: import_v43.z.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
578
|
+
thinking: import_v43.z.discriminatedUnion("type", [
|
|
579
|
+
import_v43.z.object({
|
|
580
|
+
/** for Opus 4.6 and newer models */
|
|
581
|
+
type: import_v43.z.literal("adaptive")
|
|
582
|
+
}),
|
|
583
|
+
import_v43.z.object({
|
|
584
|
+
/** for models before Opus 4.6 */
|
|
585
|
+
type: import_v43.z.literal("enabled"),
|
|
586
|
+
budgetTokens: import_v43.z.number().optional()
|
|
587
|
+
}),
|
|
588
|
+
import_v43.z.object({
|
|
589
|
+
type: import_v43.z.literal("disabled")
|
|
590
|
+
})
|
|
591
|
+
]).optional(),
|
|
582
592
|
/**
|
|
583
593
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
584
594
|
* When set to true, Claude will use at most one tool per response.
|
|
@@ -610,7 +620,12 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
610
620
|
/**
|
|
611
621
|
* @default 'high'
|
|
612
622
|
*/
|
|
613
|
-
effort: import_v43.z.enum(["low", "medium", "high"]).optional()
|
|
623
|
+
effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
|
|
624
|
+
/**
|
|
625
|
+
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
626
|
+
* Only supported with claude-opus-4-6.
|
|
627
|
+
*/
|
|
628
|
+
speed: import_v43.z.literal("fast").optional()
|
|
614
629
|
});
|
|
615
630
|
|
|
616
631
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1868,8 +1883,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1868
1883
|
warnings,
|
|
1869
1884
|
cacheControlValidator
|
|
1870
1885
|
});
|
|
1871
|
-
const
|
|
1872
|
-
const
|
|
1886
|
+
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
1887
|
+
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
1888
|
+
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
1873
1889
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
1874
1890
|
const baseArgs = {
|
|
1875
1891
|
// model id:
|
|
@@ -1882,11 +1898,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1882
1898
|
stop_sequences: stopSequences,
|
|
1883
1899
|
// provider specific settings:
|
|
1884
1900
|
...isThinking && {
|
|
1885
|
-
thinking: {
|
|
1901
|
+
thinking: {
|
|
1902
|
+
type: thinkingType,
|
|
1903
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
1904
|
+
}
|
|
1886
1905
|
},
|
|
1887
1906
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
1888
1907
|
output_config: { effort: anthropicOptions.effort }
|
|
1889
1908
|
},
|
|
1909
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
1910
|
+
speed: anthropicOptions.speed
|
|
1911
|
+
},
|
|
1890
1912
|
// structured output:
|
|
1891
1913
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
1892
1914
|
output_format: {
|
|
@@ -1910,7 +1932,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1910
1932
|
messages: messagesPrompt.messages
|
|
1911
1933
|
};
|
|
1912
1934
|
if (isThinking) {
|
|
1913
|
-
if (thinkingBudget == null) {
|
|
1935
|
+
if (thinkingType === "enabled" && thinkingBudget == null) {
|
|
1914
1936
|
throw new import_provider3.UnsupportedFunctionalityError({
|
|
1915
1937
|
functionality: "thinking requires a budget"
|
|
1916
1938
|
});
|
|
@@ -1939,7 +1961,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1939
1961
|
details: "topP is not supported when thinking is enabled"
|
|
1940
1962
|
});
|
|
1941
1963
|
}
|
|
1942
|
-
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
1964
|
+
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
1943
1965
|
}
|
|
1944
1966
|
if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
1945
1967
|
if (maxOutputTokens != null) {
|
|
@@ -1967,6 +1989,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1967
1989
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
1968
1990
|
betas.add("effort-2025-11-24");
|
|
1969
1991
|
}
|
|
1992
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.speed) {
|
|
1993
|
+
betas.add("fast-mode-2026-02-01");
|
|
1994
|
+
}
|
|
1970
1995
|
if (useStructuredOutput) {
|
|
1971
1996
|
betas.add("structured-outputs-2025-11-13");
|
|
1972
1997
|
}
|
|
@@ -2828,7 +2853,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2828
2853
|
}
|
|
2829
2854
|
};
|
|
2830
2855
|
function getModelCapabilities(modelId) {
|
|
2831
|
-
if (modelId.includes("claude-
|
|
2856
|
+
if (modelId.includes("claude-opus-4-6")) {
|
|
2857
|
+
return {
|
|
2858
|
+
maxOutputTokens: 128e3,
|
|
2859
|
+
supportsStructuredOutput: true,
|
|
2860
|
+
isKnownModel: true
|
|
2861
|
+
};
|
|
2862
|
+
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
|
|
2832
2863
|
return {
|
|
2833
2864
|
maxOutputTokens: 64e3,
|
|
2834
2865
|
supportsStructuredOutput: true,
|