@ai-sdk/anthropic 2.0.67 → 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.
@@ -10,7 +10,7 @@ type AnthropicMessagesConfig = {
10
10
  headers: Resolvable<Record<string, string | undefined>>;
11
11
  fetch?: FetchFunction;
12
12
  buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
- transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
13
+ transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
14
14
  supportedUrls?: () => LanguageModelV2['supportedUrls'];
15
15
  generateId?: () => string;
16
16
  };
@@ -10,7 +10,7 @@ type AnthropicMessagesConfig = {
10
10
  headers: Resolvable<Record<string, string | undefined>>;
11
11
  fetch?: FetchFunction;
12
12
  buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
- transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
13
+ transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
14
14
  supportedUrls?: () => LanguageModelV2['supportedUrls'];
15
15
  generateId?: () => string;
16
16
  };
@@ -741,7 +741,12 @@ var anthropicProviderOptions = import_v43.z.object({
741
741
  })
742
742
  ])
743
743
  )
744
- }).optional()
744
+ }).optional(),
745
+ /**
746
+ * A set of beta features to enable.
747
+ * Allow a provider to receive the full `betas` set if it needs it.
748
+ */
749
+ anthropicBeta: import_v43.z.array(import_v43.z.string()).optional()
745
750
  });
746
751
 
747
752
  // src/anthropic-prepare-tools.ts
@@ -1935,7 +1940,7 @@ var AnthropicMessagesLanguageModel = class {
1935
1940
  toolChoice,
1936
1941
  providerOptions
1937
1942
  }) {
1938
- var _a, _b, _c, _d, _e;
1943
+ var _a, _b, _c, _d, _e, _f;
1939
1944
  const warnings = [];
1940
1945
  if (frequencyPenalty != null) {
1941
1946
  warnings.push({
@@ -2209,7 +2214,12 @@ var AnthropicMessagesLanguageModel = class {
2209
2214
  tool_choice: anthropicToolChoice
2210
2215
  },
2211
2216
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
2212
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
2217
+ betas: /* @__PURE__ */ new Set([
2218
+ ...betas,
2219
+ ...toolsBetas,
2220
+ ...userSuppliedBetas,
2221
+ ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2222
+ ]),
2213
2223
  usesJsonResponseTool: jsonResponseTool != null
2214
2224
  };
2215
2225
  }
@@ -2239,9 +2249,9 @@ var AnthropicMessagesLanguageModel = class {
2239
2249
  var _a, _b, _c;
2240
2250
  return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
2241
2251
  }
2242
- transformRequestBody(args) {
2252
+ transformRequestBody(args, betas) {
2243
2253
  var _a, _b, _c;
2244
- return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
2254
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args, betas)) != null ? _c : args;
2245
2255
  }
2246
2256
  extractCitationDocuments(prompt) {
2247
2257
  const isCitationPart = (part) => {
@@ -2280,7 +2290,7 @@ var AnthropicMessagesLanguageModel = class {
2280
2290
  } = await (0, import_provider_utils11.postJsonToApi)({
2281
2291
  url: this.buildRequestUrl(false),
2282
2292
  headers: await this.getHeaders({ betas, headers: options.headers }),
2283
- body: this.transformRequestBody(args),
2293
+ body: this.transformRequestBody(args, betas),
2284
2294
  failedResponseHandler: anthropicFailedResponseHandler,
2285
2295
  successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2286
2296
  anthropicMessagesResponseSchema
@@ -2605,7 +2615,7 @@ var AnthropicMessagesLanguageModel = class {
2605
2615
  const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2606
2616
  url,
2607
2617
  headers: await this.getHeaders({ betas, headers: options.headers }),
2608
- body: this.transformRequestBody(body),
2618
+ body: this.transformRequestBody(body, betas),
2609
2619
  failedResponseHandler: anthropicFailedResponseHandler,
2610
2620
  successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2611
2621
  anthropicMessagesChunkSchema