@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.
@@ -562,10 +562,20 @@ var anthropicProviderOptions = z3.object({
562
562
  * When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
563
563
  * Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
564
564
  */
565
- thinking: z3.object({
566
- type: z3.union([z3.literal("enabled"), z3.literal("disabled")]),
567
- budgetTokens: z3.number().optional()
568
- }).optional(),
565
+ thinking: z3.discriminatedUnion("type", [
566
+ z3.object({
567
+ /** for Opus 4.6 and newer models */
568
+ type: z3.literal("adaptive")
569
+ }),
570
+ z3.object({
571
+ /** for models before Opus 4.6 */
572
+ type: z3.literal("enabled"),
573
+ budgetTokens: z3.number().optional()
574
+ }),
575
+ z3.object({
576
+ type: z3.literal("disabled")
577
+ })
578
+ ]).optional(),
569
579
  /**
570
580
  * Whether to disable parallel function calling during tool use. Default is false.
571
581
  * When set to true, Claude will use at most one tool per response.
@@ -597,7 +607,12 @@ var anthropicProviderOptions = z3.object({
597
607
  /**
598
608
  * @default 'high'
599
609
  */
600
- effort: z3.enum(["low", "medium", "high"]).optional()
610
+ effort: z3.enum(["low", "medium", "high", "max"]).optional(),
611
+ /**
612
+ * Enable fast mode for faster inference (2.5x faster output token speeds).
613
+ * Only supported with claude-opus-4-6.
614
+ */
615
+ speed: z3.literal("fast").optional()
601
616
  });
602
617
 
603
618
  // src/anthropic-prepare-tools.ts
@@ -1879,8 +1894,9 @@ var AnthropicMessagesLanguageModel = class {
1879
1894
  warnings,
1880
1895
  cacheControlValidator
1881
1896
  });
1882
- const isThinking = ((_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type) === "enabled";
1883
- const thinkingBudget = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens;
1897
+ const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
1898
+ const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
1899
+ let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
1884
1900
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
1885
1901
  const baseArgs = {
1886
1902
  // model id:
@@ -1893,11 +1909,17 @@ var AnthropicMessagesLanguageModel = class {
1893
1909
  stop_sequences: stopSequences,
1894
1910
  // provider specific settings:
1895
1911
  ...isThinking && {
1896
- thinking: { type: "enabled", budget_tokens: thinkingBudget }
1912
+ thinking: {
1913
+ type: thinkingType,
1914
+ ...thinkingBudget != null && { budget_tokens: thinkingBudget }
1915
+ }
1897
1916
  },
1898
1917
  ...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
1899
1918
  output_config: { effort: anthropicOptions.effort }
1900
1919
  },
1920
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
1921
+ speed: anthropicOptions.speed
1922
+ },
1901
1923
  // structured output:
1902
1924
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
1903
1925
  output_format: {
@@ -1921,7 +1943,7 @@ var AnthropicMessagesLanguageModel = class {
1921
1943
  messages: messagesPrompt.messages
1922
1944
  };
1923
1945
  if (isThinking) {
1924
- if (thinkingBudget == null) {
1946
+ if (thinkingType === "enabled" && thinkingBudget == null) {
1925
1947
  throw new UnsupportedFunctionalityError3({
1926
1948
  functionality: "thinking requires a budget"
1927
1949
  });
@@ -1950,7 +1972,7 @@ var AnthropicMessagesLanguageModel = class {
1950
1972
  details: "topP is not supported when thinking is enabled"
1951
1973
  });
1952
1974
  }
1953
- baseArgs.max_tokens = maxTokens + thinkingBudget;
1975
+ baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
1954
1976
  }
1955
1977
  if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
1956
1978
  if (maxOutputTokens != null) {
@@ -1978,6 +2000,9 @@ var AnthropicMessagesLanguageModel = class {
1978
2000
  if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
1979
2001
  betas.add("effort-2025-11-24");
1980
2002
  }
2003
+ if (anthropicOptions == null ? void 0 : anthropicOptions.speed) {
2004
+ betas.add("fast-mode-2026-02-01");
2005
+ }
1981
2006
  if (useStructuredOutput) {
1982
2007
  betas.add("structured-outputs-2025-11-13");
1983
2008
  }
@@ -2839,7 +2864,13 @@ var AnthropicMessagesLanguageModel = class {
2839
2864
  }
2840
2865
  };
2841
2866
  function getModelCapabilities(modelId) {
2842
- if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
2867
+ if (modelId.includes("claude-opus-4-6")) {
2868
+ return {
2869
+ maxOutputTokens: 128e3,
2870
+ supportsStructuredOutput: true,
2871
+ isKnownModel: true
2872
+ };
2873
+ } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
2843
2874
  return {
2844
2875
  maxOutputTokens: 64e3,
2845
2876
  supportsStructuredOutput: true,