@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.
@@ -1374,6 +1374,24 @@ async function convertToAnthropicMessagesPrompt({
1374
1374
  }
1375
1375
  };
1376
1376
  }
1377
+ case "image-url": {
1378
+ return {
1379
+ type: "image",
1380
+ source: {
1381
+ type: "url",
1382
+ url: contentPart.url
1383
+ }
1384
+ };
1385
+ }
1386
+ case "file-url": {
1387
+ return {
1388
+ type: "document",
1389
+ source: {
1390
+ type: "url",
1391
+ url: contentPart.url
1392
+ }
1393
+ };
1394
+ }
1377
1395
  case "file-data": {
1378
1396
  if (contentPart.mediaType === "application/pdf") {
1379
1397
  betas.add("pdfs-2024-09-25");
@@ -1912,7 +1930,7 @@ var AnthropicMessagesLanguageModel = class {
1912
1930
  });
1913
1931
  const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
1914
1932
  const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
1915
- const maxOutputTokensForModel = getMaxOutputTokensForModel(this.modelId);
1933
+ const { maxOutputTokens: maxOutputTokensForModel, knownModel } = getMaxOutputTokensForModel(this.modelId);
1916
1934
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
1917
1935
  const baseArgs = {
1918
1936
  // model id:
@@ -1987,7 +2005,7 @@ var AnthropicMessagesLanguageModel = class {
1987
2005
  }
1988
2006
  baseArgs.max_tokens = maxTokens + thinkingBudget;
1989
2007
  }
1990
- if (baseArgs.max_tokens > maxOutputTokensForModel) {
2008
+ if (knownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
1991
2009
  if (maxOutputTokens != null) {
1992
2010
  warnings.push({
1993
2011
  type: "unsupported-setting",
@@ -2877,13 +2895,15 @@ var AnthropicMessagesLanguageModel = class {
2877
2895
  };
2878
2896
  function getMaxOutputTokensForModel(modelId) {
2879
2897
  if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
2880
- return 64e3;
2898
+ return { maxOutputTokens: 64e3, knownModel: true };
2881
2899
  } else if (modelId.includes("claude-opus-4-")) {
2882
- return 32e3;
2900
+ return { maxOutputTokens: 32e3, knownModel: true };
2883
2901
  } else if (modelId.includes("claude-3-5-haiku")) {
2884
- return 8192;
2902
+ return { maxOutputTokens: 8192, knownModel: true };
2903
+ } else if (modelId.includes("claude-3-haiku")) {
2904
+ return { maxOutputTokens: 4096, knownModel: true };
2885
2905
  } else {
2886
- return 4096;
2906
+ return { maxOutputTokens: 4096, knownModel: false };
2887
2907
  }
2888
2908
  }
2889
2909