@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 2.0.60
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 368f270: feat(anthropic): add support for Opus 4.6 fast mode
|
|
8
|
+
|
|
9
|
+
## 2.0.59
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ca1f53a: feat(anthropic): add support for Opus 4.6
|
|
14
|
+
|
|
3
15
|
## 2.0.58
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -42,7 +42,7 @@ interface AnthropicMessageMetadata {
|
|
|
42
42
|
} | null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
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 & {});
|
|
45
|
+
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 & {});
|
|
46
46
|
declare const anthropicProviderOptions: z.ZodObject<{
|
|
47
47
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
48
48
|
structuredOutputMode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -50,10 +50,14 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
50
50
|
jsonTool: "jsonTool";
|
|
51
51
|
auto: "auto";
|
|
52
52
|
}>>;
|
|
53
|
-
thinking: z.ZodOptional<z.ZodObject<{
|
|
54
|
-
type: z.
|
|
53
|
+
thinking: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"adaptive">;
|
|
55
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"enabled">;
|
|
55
57
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
56
|
-
}, z.core.$strip
|
|
58
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"disabled">;
|
|
60
|
+
}, z.core.$strip>]>>;
|
|
57
61
|
disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
|
|
58
62
|
cacheControl: z.ZodOptional<z.ZodObject<{
|
|
59
63
|
type: z.ZodLiteral<"ephemeral">;
|
|
@@ -71,7 +75,9 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
71
75
|
low: "low";
|
|
72
76
|
medium: "medium";
|
|
73
77
|
high: "high";
|
|
78
|
+
max: "max";
|
|
74
79
|
}>>;
|
|
80
|
+
speed: z.ZodOptional<z.ZodLiteral<"fast">>;
|
|
75
81
|
}, z.core.$strip>;
|
|
76
82
|
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
77
83
|
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ interface AnthropicMessageMetadata {
|
|
|
42
42
|
} | null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
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 & {});
|
|
45
|
+
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 & {});
|
|
46
46
|
declare const anthropicProviderOptions: z.ZodObject<{
|
|
47
47
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
48
48
|
structuredOutputMode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -50,10 +50,14 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
50
50
|
jsonTool: "jsonTool";
|
|
51
51
|
auto: "auto";
|
|
52
52
|
}>>;
|
|
53
|
-
thinking: z.ZodOptional<z.ZodObject<{
|
|
54
|
-
type: z.
|
|
53
|
+
thinking: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"adaptive">;
|
|
55
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"enabled">;
|
|
55
57
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
56
|
-
}, z.core.$strip
|
|
58
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"disabled">;
|
|
60
|
+
}, z.core.$strip>]>>;
|
|
57
61
|
disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
|
|
58
62
|
cacheControl: z.ZodOptional<z.ZodObject<{
|
|
59
63
|
type: z.ZodLiteral<"ephemeral">;
|
|
@@ -71,7 +75,9 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
71
75
|
low: "low";
|
|
72
76
|
medium: "medium";
|
|
73
77
|
high: "high";
|
|
78
|
+
max: "max";
|
|
74
79
|
}>>;
|
|
80
|
+
speed: z.ZodOptional<z.ZodLiteral<"fast">>;
|
|
75
81
|
}, z.core.$strip>;
|
|
76
82
|
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
77
83
|
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
31
31
|
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/version.ts
|
|
34
|
-
var VERSION = true ? "2.0.
|
|
34
|
+
var VERSION = true ? "2.0.60" : "0.0.0-test";
|
|
35
35
|
|
|
36
36
|
// src/anthropic-messages-language-model.ts
|
|
37
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -582,10 +582,20 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
582
582
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
583
583
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
584
584
|
*/
|
|
585
|
-
thinking: import_v43.z.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
585
|
+
thinking: import_v43.z.discriminatedUnion("type", [
|
|
586
|
+
import_v43.z.object({
|
|
587
|
+
/** for Opus 4.6 and newer models */
|
|
588
|
+
type: import_v43.z.literal("adaptive")
|
|
589
|
+
}),
|
|
590
|
+
import_v43.z.object({
|
|
591
|
+
/** for models before Opus 4.6 */
|
|
592
|
+
type: import_v43.z.literal("enabled"),
|
|
593
|
+
budgetTokens: import_v43.z.number().optional()
|
|
594
|
+
}),
|
|
595
|
+
import_v43.z.object({
|
|
596
|
+
type: import_v43.z.literal("disabled")
|
|
597
|
+
})
|
|
598
|
+
]).optional(),
|
|
589
599
|
/**
|
|
590
600
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
591
601
|
* When set to true, Claude will use at most one tool per response.
|
|
@@ -617,7 +627,12 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
617
627
|
/**
|
|
618
628
|
* @default 'high'
|
|
619
629
|
*/
|
|
620
|
-
effort: import_v43.z.enum(["low", "medium", "high"]).optional()
|
|
630
|
+
effort: import_v43.z.enum(["low", "medium", "high", "max"]).optional(),
|
|
631
|
+
/**
|
|
632
|
+
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
633
|
+
* Only supported with claude-opus-4-6.
|
|
634
|
+
*/
|
|
635
|
+
speed: import_v43.z.literal("fast").optional()
|
|
621
636
|
});
|
|
622
637
|
|
|
623
638
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1875,8 +1890,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1875
1890
|
warnings,
|
|
1876
1891
|
cacheControlValidator
|
|
1877
1892
|
});
|
|
1878
|
-
const
|
|
1879
|
-
const
|
|
1893
|
+
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
1894
|
+
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
1895
|
+
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
1880
1896
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
1881
1897
|
const baseArgs = {
|
|
1882
1898
|
// model id:
|
|
@@ -1889,11 +1905,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1889
1905
|
stop_sequences: stopSequences,
|
|
1890
1906
|
// provider specific settings:
|
|
1891
1907
|
...isThinking && {
|
|
1892
|
-
thinking: {
|
|
1908
|
+
thinking: {
|
|
1909
|
+
type: thinkingType,
|
|
1910
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
1911
|
+
}
|
|
1893
1912
|
},
|
|
1894
1913
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
1895
1914
|
output_config: { effort: anthropicOptions.effort }
|
|
1896
1915
|
},
|
|
1916
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
1917
|
+
speed: anthropicOptions.speed
|
|
1918
|
+
},
|
|
1897
1919
|
// structured output:
|
|
1898
1920
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
1899
1921
|
output_format: {
|
|
@@ -1917,7 +1939,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1917
1939
|
messages: messagesPrompt.messages
|
|
1918
1940
|
};
|
|
1919
1941
|
if (isThinking) {
|
|
1920
|
-
if (thinkingBudget == null) {
|
|
1942
|
+
if (thinkingType === "enabled" && thinkingBudget == null) {
|
|
1921
1943
|
throw new import_provider3.UnsupportedFunctionalityError({
|
|
1922
1944
|
functionality: "thinking requires a budget"
|
|
1923
1945
|
});
|
|
@@ -1946,7 +1968,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1946
1968
|
details: "topP is not supported when thinking is enabled"
|
|
1947
1969
|
});
|
|
1948
1970
|
}
|
|
1949
|
-
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
1971
|
+
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
1950
1972
|
}
|
|
1951
1973
|
if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
1952
1974
|
if (maxOutputTokens != null) {
|
|
@@ -1974,6 +1996,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1974
1996
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
1975
1997
|
betas.add("effort-2025-11-24");
|
|
1976
1998
|
}
|
|
1999
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.speed) {
|
|
2000
|
+
betas.add("fast-mode-2026-02-01");
|
|
2001
|
+
}
|
|
1977
2002
|
if (useStructuredOutput) {
|
|
1978
2003
|
betas.add("structured-outputs-2025-11-13");
|
|
1979
2004
|
}
|
|
@@ -2835,7 +2860,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2835
2860
|
}
|
|
2836
2861
|
};
|
|
2837
2862
|
function getModelCapabilities(modelId) {
|
|
2838
|
-
if (modelId.includes("claude-
|
|
2863
|
+
if (modelId.includes("claude-opus-4-6")) {
|
|
2864
|
+
return {
|
|
2865
|
+
maxOutputTokens: 128e3,
|
|
2866
|
+
supportsStructuredOutput: true,
|
|
2867
|
+
isKnownModel: true
|
|
2868
|
+
};
|
|
2869
|
+
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
|
|
2839
2870
|
return {
|
|
2840
2871
|
maxOutputTokens: 64e3,
|
|
2841
2872
|
supportsStructuredOutput: true,
|