@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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - de2399b: fix(anthropic): assign type urls in file parts correctly
8
+
9
+ ## 3.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - bee4f82: fix(anthropic): enable structured output support for claude-haiku-4-5
14
+
15
+ This fixes an issue where the `strict: true` property was not included in the request body when using tools with Claude Haiku 4.5, because `supportsStructuredOutput` was incorrectly set to `false` for this model.
16
+
17
+ Claude Haiku 4.5 supports structured outputs, so the `strict` property should be forwarded to the Anthropic API when specified on tools.
18
+
3
19
  ## 3.0.7
4
20
 
5
21
  ### Patch Changes
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils22 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.7" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.9" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -1549,6 +1549,15 @@ function convertToString(data) {
1549
1549
  functionality: `unsupported data type for text documents: ${typeof data}`
1550
1550
  });
1551
1551
  }
1552
+ function isUrlData(data) {
1553
+ return data instanceof URL || isUrlString(data);
1554
+ }
1555
+ function isUrlString(data) {
1556
+ return typeof data === "string" && /^https?:\/\//i.test(data);
1557
+ }
1558
+ function getUrlString(data) {
1559
+ return data instanceof URL ? data.toString() : data;
1560
+ }
1552
1561
  async function convertToAnthropicMessagesPrompt({
1553
1562
  prompt,
1554
1563
  sendReasoning,
@@ -1632,9 +1641,9 @@ async function convertToAnthropicMessagesPrompt({
1632
1641
  if (part.mediaType.startsWith("image/")) {
1633
1642
  anthropicContent.push({
1634
1643
  type: "image",
1635
- source: part.data instanceof URL ? {
1644
+ source: isUrlData(part.data) ? {
1636
1645
  type: "url",
1637
- url: part.data.toString()
1646
+ url: getUrlString(part.data)
1638
1647
  } : {
1639
1648
  type: "base64",
1640
1649
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
@@ -1652,9 +1661,9 @@ async function convertToAnthropicMessagesPrompt({
1652
1661
  );
1653
1662
  anthropicContent.push({
1654
1663
  type: "document",
1655
- source: part.data instanceof URL ? {
1664
+ source: isUrlData(part.data) ? {
1656
1665
  type: "url",
1657
- url: part.data.toString()
1666
+ url: getUrlString(part.data)
1658
1667
  } : {
1659
1668
  type: "base64",
1660
1669
  media_type: "application/pdf",
@@ -1676,9 +1685,9 @@ async function convertToAnthropicMessagesPrompt({
1676
1685
  );
1677
1686
  anthropicContent.push({
1678
1687
  type: "document",
1679
- source: part.data instanceof URL ? {
1688
+ source: isUrlData(part.data) ? {
1680
1689
  type: "url",
1681
- url: part.data.toString()
1690
+ url: getUrlString(part.data)
1682
1691
  } : {
1683
1692
  type: "text",
1684
1693
  media_type: "text/plain",
@@ -3756,7 +3765,7 @@ var AnthropicMessagesLanguageModel = class {
3756
3765
  }
3757
3766
  };
3758
3767
  function getModelCapabilities(modelId) {
3759
- if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
3768
+ if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3760
3769
  return {
3761
3770
  maxOutputTokens: 64e3,
3762
3771
  supportsStructuredOutput: true,
@@ -3768,7 +3777,7 @@ function getModelCapabilities(modelId) {
3768
3777
  supportsStructuredOutput: true,
3769
3778
  isKnownModel: true
3770
3779
  };
3771
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
3780
+ } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3772
3781
  return {
3773
3782
  maxOutputTokens: 64e3,
3774
3783
  supportsStructuredOutput: false,