@ai-sdk/anthropic 3.0.0-beta.59 → 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.
@@ -1907,6 +1907,7 @@ var AnthropicMessagesLanguageModel = class {
1907
1907
  return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
1908
1908
  }
1909
1909
  async getArgs({
1910
+ userSuppliedBetas,
1910
1911
  prompt,
1911
1912
  maxOutputTokens,
1912
1913
  temperature,
@@ -2140,7 +2141,7 @@ var AnthropicMessagesLanguageModel = class {
2140
2141
  // do not send when not streaming
2141
2142
  },
2142
2143
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2143
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
2144
+ betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
2144
2145
  usesJsonResponseTool: jsonResponseTool != null
2145
2146
  };
2146
2147
  }
@@ -2150,8 +2151,20 @@ var AnthropicMessagesLanguageModel = class {
2150
2151
  }) {
2151
2152
  return combineHeaders(
2152
2153
  await resolve(this.config.headers),
2153
- betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
2154
- headers
2154
+ headers,
2155
+ betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2156
+ );
2157
+ }
2158
+ async getBetasFromHeaders(requestHeaders) {
2159
+ var _a, _b;
2160
+ const configHeaders = await resolve(this.config.headers);
2161
+ const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2162
+ const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2163
+ return new Set(
2164
+ [
2165
+ ...configBetaHeader.toLowerCase().split(","),
2166
+ ...requestBetaHeader.toLowerCase().split(",")
2167
+ ].map((beta) => beta.trim()).filter((beta) => beta !== "")
2155
2168
  );
2156
2169
  }
2157
2170
  buildRequestUrl(isStreaming) {
@@ -2189,7 +2202,8 @@ var AnthropicMessagesLanguageModel = class {
2189
2202
  var _a, _b, _c, _d, _e, _f, _g, _h;
2190
2203
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs({
2191
2204
  ...options,
2192
- stream: false
2205
+ stream: false,
2206
+ userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
2193
2207
  });
2194
2208
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2195
2209
  const {
@@ -2490,7 +2504,8 @@ var AnthropicMessagesLanguageModel = class {
2490
2504
  usesJsonResponseTool
2491
2505
  } = await this.getArgs({
2492
2506
  ...options,
2493
- stream: true
2507
+ stream: true,
2508
+ userSuppliedBetas: await this.getBetasFromHeaders(options.headers)
2494
2509
  });
2495
2510
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2496
2511
  const { responseHeaders, value: response } = await postJsonToApi({