@ai-sdk/anthropic 3.0.0-beta.35 → 3.0.0-beta.37

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.
@@ -1385,6 +1385,24 @@ async function convertToAnthropicMessagesPrompt({
1385
1385
  }
1386
1386
  };
1387
1387
  }
1388
+ case "image-url": {
1389
+ return {
1390
+ type: "image",
1391
+ source: {
1392
+ type: "url",
1393
+ url: contentPart.url
1394
+ }
1395
+ };
1396
+ }
1397
+ case "file-url": {
1398
+ return {
1399
+ type: "document",
1400
+ source: {
1401
+ type: "url",
1402
+ url: contentPart.url
1403
+ }
1404
+ };
1405
+ }
1388
1406
  case "file-data": {
1389
1407
  if (contentPart.mediaType === "application/pdf") {
1390
1408
  betas.add("pdfs-2024-09-25");
@@ -1923,7 +1941,7 @@ var AnthropicMessagesLanguageModel = class {
1923
1941
  });
1924
1942
  const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
1925
1943
  const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
1926
- const maxOutputTokensForModel = getMaxOutputTokensForModel(this.modelId);
1944
+ const { maxOutputTokens: maxOutputTokensForModel, knownModel } = getMaxOutputTokensForModel(this.modelId);
1927
1945
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
1928
1946
  const baseArgs = {
1929
1947
  // model id:
@@ -1998,7 +2016,7 @@ var AnthropicMessagesLanguageModel = class {
1998
2016
  }
1999
2017
  baseArgs.max_tokens = maxTokens + thinkingBudget;
2000
2018
  }
2001
- if (baseArgs.max_tokens > maxOutputTokensForModel) {
2019
+ if (knownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
2002
2020
  if (maxOutputTokens != null) {
2003
2021
  warnings.push({
2004
2022
  type: "unsupported-setting",
@@ -2888,13 +2906,15 @@ var AnthropicMessagesLanguageModel = class {
2888
2906
  };
2889
2907
  function getMaxOutputTokensForModel(modelId) {
2890
2908
  if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
2891
- return 64e3;
2909
+ return { maxOutputTokens: 64e3, knownModel: true };
2892
2910
  } else if (modelId.includes("claude-opus-4-")) {
2893
- return 32e3;
2911
+ return { maxOutputTokens: 32e3, knownModel: true };
2894
2912
  } else if (modelId.includes("claude-3-5-haiku")) {
2895
- return 8192;
2913
+ return { maxOutputTokens: 8192, knownModel: true };
2914
+ } else if (modelId.includes("claude-3-haiku")) {
2915
+ return { maxOutputTokens: 4096, knownModel: true };
2896
2916
  } else {
2897
- return 4096;
2917
+ return { maxOutputTokens: 4096, knownModel: false };
2898
2918
  }
2899
2919
  }
2900
2920