@ai-sdk/anthropic 3.0.0-beta.58 → 3.0.0-beta.60

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,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.0-beta.60
4
+
5
+ ### Patch Changes
6
+
7
+ - 6fc35cb: Retain user-supplied betas.
8
+
9
+ ## 3.0.0-beta.59
10
+
11
+ ### Patch Changes
12
+
13
+ - 2109385: 'fix(anthropic): Opus 4.5 `maxOutputTokens` bump `32000` -> `64000`'
14
+
3
15
  ## 3.0.0-beta.58
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var import_provider4 = require("@ai-sdk/provider");
31
31
  var import_provider_utils20 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "3.0.0-beta.58" : "0.0.0-test";
34
+ var VERSION = true ? "3.0.0-beta.60" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -1903,6 +1903,7 @@ var AnthropicMessagesLanguageModel = class {
1903
1903
  return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
1904
1904
  }
1905
1905
  async getArgs({
1906
+ userSuppliedBetas,
1906
1907
  prompt,
1907
1908
  maxOutputTokens,
1908
1909
  temperature,
@@ -2136,7 +2137,7 @@ var AnthropicMessagesLanguageModel = class {
2136
2137
  // do not send when not streaming
2137
2138
  },
2138
2139
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2139
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
2140
+ betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
2140
2141
  usesJsonResponseTool: jsonResponseTool != null
2141
2142
  };
2142
2143
  }
@@ -2146,8 +2147,20 @@ var AnthropicMessagesLanguageModel = class {
2146
2147
  }) {
2147
2148
  return (0, import_provider_utils11.combineHeaders)(
2148
2149
  await (0, import_provider_utils11.resolve)(this.config.headers),
2149
- betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
2150
- headers
2150
+ headers,
2151
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2152
+ );
2153
+ }
2154
+ async getBetasFromHeaders(requestHeaders) {
2155
+ var _a, _b;
2156
+ const configHeaders = await (0, import_provider_utils11.resolve)(this.config.headers);
2157
+ const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2158
+ const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2159
+ return new Set(
2160
+ [
2161
+ ...configBetaHeader.toLowerCase().split(","),
2162
+ ...requestBetaHeader.toLowerCase().split(",")
2163
+ ].map((beta) => beta.trim()).filter((beta) => beta !== "")
2151
2164
  );
2152
2165
  }
2153
2166
  buildRequestUrl(isStreaming) {
@@ -2185,7 +2198,8 @@ var AnthropicMessagesLanguageModel = class {
2185
2198
  var _a, _b, _c, _d, _e, _f, _g, _h;
2186
2199
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
2187
2200
  ...options,
2188
- stream: false
2201
+ stream: false,
2202
+ userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
2189
2203
  });
2190
2204
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2191
2205
  const {
@@ -2486,7 +2500,8 @@ var AnthropicMessagesLanguageModel = class {
2486
2500
  usesJsonResponseTool
2487
2501
  } = await this.getArgs({
2488
2502
  ...options,
2489
- stream: true
2503
+ stream: true,
2504
+ userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
2490
2505
  });
2491
2506
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2492
2507
  const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
@@ -2985,13 +3000,13 @@ var AnthropicMessagesLanguageModel = class {
2985
3000
  }
2986
3001
  };
2987
3002
  function getModelCapabilities(modelId) {
2988
- if (modelId.includes("claude-sonnet-4-5")) {
3003
+ if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
2989
3004
  return {
2990
3005
  maxOutputTokens: 64e3,
2991
3006
  supportsStructuredOutput: true,
2992
3007
  isKnownModel: true
2993
3008
  };
2994
- } else if (modelId.includes("claude-opus-4-1") || modelId.includes("claude-opus-4-5")) {
3009
+ } else if (modelId.includes("claude-opus-4-1")) {
2995
3010
  return {
2996
3011
  maxOutputTokens: 32e3,
2997
3012
  supportsStructuredOutput: true,