@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.
@@ -1557,6 +1557,15 @@ function convertToString(data) {
1557
1557
  functionality: `unsupported data type for text documents: ${typeof data}`
1558
1558
  });
1559
1559
  }
1560
+ function isUrlData(data) {
1561
+ return data instanceof URL || isUrlString(data);
1562
+ }
1563
+ function isUrlString(data) {
1564
+ return typeof data === "string" && /^https?:\/\//i.test(data);
1565
+ }
1566
+ function getUrlString(data) {
1567
+ return data instanceof URL ? data.toString() : data;
1568
+ }
1560
1569
  async function convertToAnthropicMessagesPrompt({
1561
1570
  prompt,
1562
1571
  sendReasoning,
@@ -1640,9 +1649,9 @@ async function convertToAnthropicMessagesPrompt({
1640
1649
  if (part.mediaType.startsWith("image/")) {
1641
1650
  anthropicContent.push({
1642
1651
  type: "image",
1643
- source: part.data instanceof URL ? {
1652
+ source: isUrlData(part.data) ? {
1644
1653
  type: "url",
1645
- url: part.data.toString()
1654
+ url: getUrlString(part.data)
1646
1655
  } : {
1647
1656
  type: "base64",
1648
1657
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
@@ -1660,9 +1669,9 @@ async function convertToAnthropicMessagesPrompt({
1660
1669
  );
1661
1670
  anthropicContent.push({
1662
1671
  type: "document",
1663
- source: part.data instanceof URL ? {
1672
+ source: isUrlData(part.data) ? {
1664
1673
  type: "url",
1665
- url: part.data.toString()
1674
+ url: getUrlString(part.data)
1666
1675
  } : {
1667
1676
  type: "base64",
1668
1677
  media_type: "application/pdf",
@@ -1684,9 +1693,9 @@ async function convertToAnthropicMessagesPrompt({
1684
1693
  );
1685
1694
  anthropicContent.push({
1686
1695
  type: "document",
1687
- source: part.data instanceof URL ? {
1696
+ source: isUrlData(part.data) ? {
1688
1697
  type: "url",
1689
- url: part.data.toString()
1698
+ url: getUrlString(part.data)
1690
1699
  } : {
1691
1700
  type: "text",
1692
1701
  media_type: "text/plain",
@@ -3764,7 +3773,7 @@ var AnthropicMessagesLanguageModel = class {
3764
3773
  }
3765
3774
  };
3766
3775
  function getModelCapabilities(modelId) {
3767
- if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
3776
+ if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3768
3777
  return {
3769
3778
  maxOutputTokens: 64e3,
3770
3779
  supportsStructuredOutput: true,
@@ -3776,7 +3785,7 @@ function getModelCapabilities(modelId) {
3776
3785
  supportsStructuredOutput: true,
3777
3786
  isKnownModel: true
3778
3787
  };
3779
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
3788
+ } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3780
3789
  return {
3781
3790
  maxOutputTokens: 64e3,
3782
3791
  supportsStructuredOutput: false,