@ai-sdk/anthropic 3.0.7 → 3.0.9

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
@@ -11,7 +11,7 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "3.0.7" : "0.0.0-test";
14
+ var VERSION = true ? "3.0.9" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -1572,6 +1572,15 @@ function convertToString(data) {
1572
1572
  functionality: `unsupported data type for text documents: ${typeof data}`
1573
1573
  });
1574
1574
  }
1575
+ function isUrlData(data) {
1576
+ return data instanceof URL || isUrlString(data);
1577
+ }
1578
+ function isUrlString(data) {
1579
+ return typeof data === "string" && /^https?:\/\//i.test(data);
1580
+ }
1581
+ function getUrlString(data) {
1582
+ return data instanceof URL ? data.toString() : data;
1583
+ }
1575
1584
  async function convertToAnthropicMessagesPrompt({
1576
1585
  prompt,
1577
1586
  sendReasoning,
@@ -1655,9 +1664,9 @@ async function convertToAnthropicMessagesPrompt({
1655
1664
  if (part.mediaType.startsWith("image/")) {
1656
1665
  anthropicContent.push({
1657
1666
  type: "image",
1658
- source: part.data instanceof URL ? {
1667
+ source: isUrlData(part.data) ? {
1659
1668
  type: "url",
1660
- url: part.data.toString()
1669
+ url: getUrlString(part.data)
1661
1670
  } : {
1662
1671
  type: "base64",
1663
1672
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
@@ -1675,9 +1684,9 @@ async function convertToAnthropicMessagesPrompt({
1675
1684
  );
1676
1685
  anthropicContent.push({
1677
1686
  type: "document",
1678
- source: part.data instanceof URL ? {
1687
+ source: isUrlData(part.data) ? {
1679
1688
  type: "url",
1680
- url: part.data.toString()
1689
+ url: getUrlString(part.data)
1681
1690
  } : {
1682
1691
  type: "base64",
1683
1692
  media_type: "application/pdf",
@@ -1699,9 +1708,9 @@ async function convertToAnthropicMessagesPrompt({
1699
1708
  );
1700
1709
  anthropicContent.push({
1701
1710
  type: "document",
1702
- source: part.data instanceof URL ? {
1711
+ source: isUrlData(part.data) ? {
1703
1712
  type: "url",
1704
- url: part.data.toString()
1713
+ url: getUrlString(part.data)
1705
1714
  } : {
1706
1715
  type: "text",
1707
1716
  media_type: "text/plain",
@@ -3779,7 +3788,7 @@ var AnthropicMessagesLanguageModel = class {
3779
3788
  }
3780
3789
  };
3781
3790
  function getModelCapabilities(modelId) {
3782
- if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
3791
+ if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3783
3792
  return {
3784
3793
  maxOutputTokens: 64e3,
3785
3794
  supportsStructuredOutput: true,
@@ -3791,7 +3800,7 @@ function getModelCapabilities(modelId) {
3791
3800
  supportsStructuredOutput: true,
3792
3801
  isKnownModel: true
3793
3802
  };
3794
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
3803
+ } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3795
3804
  return {
3796
3805
  maxOutputTokens: 64e3,
3797
3806
  supportsStructuredOutput: false,