@ai-sdk/anthropic 3.0.0-beta.25 → 3.0.0-beta.27

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/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "3.0.0-beta.25" : "0.0.0-test";
13
+ var VERSION = true ? "3.0.0-beta.27" : "0.0.0-test";
14
14
 
15
15
  // src/anthropic-messages-language-model.ts
16
16
  import {
@@ -1656,8 +1656,7 @@ var AnthropicMessagesLanguageModel = class {
1656
1656
  }
1657
1657
  async getArgs({
1658
1658
  prompt,
1659
- maxOutputTokens = 4096,
1660
- // 4096: max model output tokens TODO update default in v5
1659
+ maxOutputTokens,
1661
1660
  temperature,
1662
1661
  topP,
1663
1662
  topK,
@@ -1723,11 +1722,13 @@ var AnthropicMessagesLanguageModel = class {
1723
1722
  });
1724
1723
  const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
1725
1724
  const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
1725
+ const maxOutputTokensForModel = getMaxOutputTokensForModel(this.modelId);
1726
+ const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
1726
1727
  const baseArgs = {
1727
1728
  // model id:
1728
1729
  model: this.modelId,
1729
1730
  // standardized settings:
1730
- max_tokens: maxOutputTokens,
1731
+ max_tokens: maxTokens,
1731
1732
  temperature,
1732
1733
  top_k: topK,
1733
1734
  top_p: topP,
@@ -1770,7 +1771,17 @@ var AnthropicMessagesLanguageModel = class {
1770
1771
  details: "topP is not supported when thinking is enabled"
1771
1772
  });
1772
1773
  }
1773
- baseArgs.max_tokens = maxOutputTokens + thinkingBudget;
1774
+ baseArgs.max_tokens = maxTokens + thinkingBudget;
1775
+ }
1776
+ if (baseArgs.max_tokens > maxOutputTokensForModel) {
1777
+ if (maxOutputTokens != null) {
1778
+ warnings.push({
1779
+ type: "unsupported-setting",
1780
+ setting: "maxOutputTokens",
1781
+ details: `${maxTokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${maxOutputTokensForModel} max output tokens. The max output tokens have been limited to ${maxOutputTokensForModel}.`
1782
+ });
1783
+ }
1784
+ baseArgs.max_tokens = maxOutputTokensForModel;
1774
1785
  }
1775
1786
  const {
1776
1787
  tools: anthropicTools2,
@@ -2550,6 +2561,17 @@ var AnthropicMessagesLanguageModel = class {
2550
2561
  };
2551
2562
  }
2552
2563
  };
2564
+ function getMaxOutputTokensForModel(modelId) {
2565
+ if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
2566
+ return 64e3;
2567
+ } else if (modelId.includes("claude-opus-4-")) {
2568
+ return 32e3;
2569
+ } else if (modelId.includes("claude-3-5-haiku")) {
2570
+ return 8192;
2571
+ } else {
2572
+ return 4096;
2573
+ }
2574
+ }
2553
2575
 
2554
2576
  // src/tool/bash_20241022.ts
2555
2577
  import {