@ai-sdk/anthropic 2.0.58 → 2.0.59

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,11 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.59
4
+
5
+ ### Patch Changes
6
+
7
+ - ca1f53a: feat(anthropic): add support for Opus 4.6
8
+
3
9
  ## 2.0.58
4
10
 
5
11
  ### 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.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
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,6 +75,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
71
75
  low: "low";
72
76
  medium: "medium";
73
77
  high: "high";
78
+ max: "max";
74
79
  }>>;
75
80
  }, z.core.$strip>;
76
81
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
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.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
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,6 +75,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
71
75
  low: "low";
72
76
  medium: "medium";
73
77
  high: "high";
78
+ max: "max";
74
79
  }>>;
75
80
  }, z.core.$strip>;
76
81
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
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.58" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.59" : "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.object({
586
- type: import_v43.z.union([import_v43.z.literal("enabled"), import_v43.z.literal("disabled")]),
587
- budgetTokens: import_v43.z.number().optional()
588
- }).optional(),
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,7 @@ 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()
621
631
  });
622
632
 
623
633
  // src/anthropic-prepare-tools.ts
@@ -1875,8 +1885,9 @@ var AnthropicMessagesLanguageModel = class {
1875
1885
  warnings,
1876
1886
  cacheControlValidator
1877
1887
  });
1878
- const isThinking = ((_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type) === "enabled";
1879
- const thinkingBudget = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens;
1888
+ const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
1889
+ const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
1890
+ let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
1880
1891
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
1881
1892
  const baseArgs = {
1882
1893
  // model id:
@@ -1889,7 +1900,10 @@ var AnthropicMessagesLanguageModel = class {
1889
1900
  stop_sequences: stopSequences,
1890
1901
  // provider specific settings:
1891
1902
  ...isThinking && {
1892
- thinking: { type: "enabled", budget_tokens: thinkingBudget }
1903
+ thinking: {
1904
+ type: thinkingType,
1905
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget }
1906
+ }
1893
1907
  },
1894
1908
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
1895
1909
  output_config: { effort: anthropicOptions.effort }
@@ -1917,7 +1931,7 @@ var AnthropicMessagesLanguageModel = class {
1917
1931
  messages: messagesPrompt.messages
1918
1932
  };
1919
1933
  if (isThinking) {
1920
- if (thinkingBudget == null) {
1934
+ if (thinkingType === "enabled" && thinkingBudget == null) {
1921
1935
  throw new import_provider3.UnsupportedFunctionalityError({
1922
1936
  functionality: "thinking requires a budget"
1923
1937
  });
@@ -1946,7 +1960,7 @@ var AnthropicMessagesLanguageModel = class {
1946
1960
  details: "topP is not supported when thinking is enabled"
1947
1961
  });
1948
1962
  }
1949
- baseArgs.max_tokens = maxTokens + thinkingBudget;
1963
+ baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
1950
1964
  }
1951
1965
  if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
1952
1966
  if (maxOutputTokens != null) {
@@ -2835,7 +2849,13 @@ var AnthropicMessagesLanguageModel = class {
2835
2849
  }
2836
2850
  };
2837
2851
  function getModelCapabilities(modelId) {
2838
- if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
2852
+ if (modelId.includes("claude-opus-4-6")) {
2853
+ return {
2854
+ maxOutputTokens: 128e3,
2855
+ supportsStructuredOutput: true,
2856
+ isKnownModel: true
2857
+ };
2858
+ } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
2839
2859
  return {
2840
2860
  maxOutputTokens: 64e3,
2841
2861
  supportsStructuredOutput: true,