@ai-sdk/anthropic 2.0.66 → 2.0.68

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.
@@ -728,7 +728,12 @@ var anthropicProviderOptions = z3.object({
728
728
  })
729
729
  ])
730
730
  )
731
- }).optional()
731
+ }).optional(),
732
+ /**
733
+ * A set of beta features to enable.
734
+ * Allow a provider to receive the full `betas` set if it needs it.
735
+ */
736
+ anthropicBeta: z3.array(z3.string()).optional()
732
737
  });
733
738
 
734
739
  // src/anthropic-prepare-tools.ts
@@ -1946,7 +1951,7 @@ var AnthropicMessagesLanguageModel = class {
1946
1951
  toolChoice,
1947
1952
  providerOptions
1948
1953
  }) {
1949
- var _a, _b, _c, _d, _e;
1954
+ var _a, _b, _c, _d, _e, _f;
1950
1955
  const warnings = [];
1951
1956
  if (frequencyPenalty != null) {
1952
1957
  warnings.push({
@@ -2047,6 +2052,9 @@ var AnthropicMessagesLanguageModel = class {
2047
2052
  ...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
2048
2053
  speed: anthropicOptions.speed
2049
2054
  },
2055
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2056
+ cache_control: anthropicOptions.cacheControl
2057
+ },
2050
2058
  // structured output:
2051
2059
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2052
2060
  output_format: {
@@ -2217,7 +2225,12 @@ var AnthropicMessagesLanguageModel = class {
2217
2225
  tool_choice: anthropicToolChoice
2218
2226
  },
2219
2227
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2220
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
2228
+ betas: /* @__PURE__ */ new Set([
2229
+ ...betas,
2230
+ ...toolsBetas,
2231
+ ...userSuppliedBetas,
2232
+ ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2233
+ ]),
2221
2234
  usesJsonResponseTool: jsonResponseTool != null
2222
2235
  };
2223
2236
  }
@@ -2247,9 +2260,9 @@ var AnthropicMessagesLanguageModel = class {
2247
2260
  var _a, _b, _c;
2248
2261
  return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
2249
2262
  }
2250
- transformRequestBody(args) {
2263
+ transformRequestBody(args, betas) {
2251
2264
  var _a, _b, _c;
2252
- return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
2265
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args, betas)) != null ? _c : args;
2253
2266
  }
2254
2267
  extractCitationDocuments(prompt) {
2255
2268
  const isCitationPart = (part) => {
@@ -2288,7 +2301,7 @@ var AnthropicMessagesLanguageModel = class {
2288
2301
  } = await postJsonToApi({
2289
2302
  url: this.buildRequestUrl(false),
2290
2303
  headers: await this.getHeaders({ betas, headers: options.headers }),
2291
- body: this.transformRequestBody(args),
2304
+ body: this.transformRequestBody(args, betas),
2292
2305
  failedResponseHandler: anthropicFailedResponseHandler,
2293
2306
  successfulResponseHandler: createJsonResponseHandler(
2294
2307
  anthropicMessagesResponseSchema
@@ -2613,7 +2626,7 @@ var AnthropicMessagesLanguageModel = class {
2613
2626
  const { responseHeaders, value: response } = await postJsonToApi({
2614
2627
  url,
2615
2628
  headers: await this.getHeaders({ betas, headers: options.headers }),
2616
- body: this.transformRequestBody(body),
2629
+ body: this.transformRequestBody(body, betas),
2617
2630
  failedResponseHandler: anthropicFailedResponseHandler,
2618
2631
  successfulResponseHandler: createEventSourceResponseHandler(
2619
2632
  anthropicMessagesChunkSchema