@ai-sdk/anthropic 3.0.101 → 3.0.103

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/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.101" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.103" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -366,6 +366,9 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
366
366
  usage: import_v42.z.looseObject({
367
367
  input_tokens: import_v42.z.number(),
368
368
  output_tokens: import_v42.z.number(),
369
+ output_tokens_details: import_v42.z.object({
370
+ thinking_tokens: import_v42.z.number().nullish()
371
+ }).nullish(),
369
372
  cache_creation_input_tokens: import_v42.z.number().nullish(),
370
373
  cache_read_input_tokens: import_v42.z.number().nullish(),
371
374
  iterations: import_v42.z.array(
@@ -813,6 +816,9 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
813
816
  usage: import_v42.z.looseObject({
814
817
  input_tokens: import_v42.z.number().nullish(),
815
818
  output_tokens: import_v42.z.number(),
819
+ output_tokens_details: import_v42.z.object({
820
+ thinking_tokens: import_v42.z.number().nullish()
821
+ }).nullish(),
816
822
  cache_creation_input_tokens: import_v42.z.number().nullish(),
817
823
  cache_read_input_tokens: import_v42.z.number().nullish(),
818
824
  iterations: import_v42.z.array(
@@ -894,6 +900,34 @@ var anthropicFilePartProviderOptions = import_v43.z.object({
894
900
  */
895
901
  context: import_v43.z.string().optional()
896
902
  });
903
+ var anthropicSystemMessageProviderOptions = import_v43.z.object({
904
+ /**
905
+ * Mid-conversation tool changes. Adds or removes tools from the
906
+ * conversation's tool set between turns without invalidating the prompt
907
+ * cache.
908
+ *
909
+ * Only supported on system messages that appear mid-conversation (not the
910
+ * initial system prompt). A system message carrying tool changes must come
911
+ * right before an assistant message or at the end of the messages.
912
+ *
913
+ * Tools referenced by a `tool_addition` must be declared in the `tools`
914
+ * option (typically with `deferLoading: true` so they are not loaded until
915
+ * the addition surfaces them). The required
916
+ * `mid-conversation-tool-changes-2026-07-01` beta is added automatically.
917
+ */
918
+ toolChanges: import_v43.z.array(
919
+ import_v43.z.discriminatedUnion("type", [
920
+ import_v43.z.object({
921
+ type: import_v43.z.literal("tool_addition"),
922
+ toolName: import_v43.z.string()
923
+ }),
924
+ import_v43.z.object({
925
+ type: import_v43.z.literal("tool_removal"),
926
+ toolName: import_v43.z.string()
927
+ })
928
+ ])
929
+ ).optional()
930
+ });
897
931
  var anthropicLanguageModelOptions = import_v43.z.object({
898
932
  /**
899
933
  * Whether to send reasoning to the model.
@@ -1033,30 +1067,35 @@ var anthropicLanguageModelOptions = import_v43.z.object({
1033
1067
  */
1034
1068
  inferenceGeo: import_v43.z.enum(["us", "global"]).optional(),
1035
1069
  /**
1036
- * Server-side fallback chain.
1070
+ * Server-side fallback configuration.
1037
1071
  *
1038
1072
  * When the primary model's safety classifiers block a turn, the API
1039
- * automatically retries it on the next model in the chain, server-side. A
1040
- * `content-filter` finish reason means the entire chain refused.
1041
- *
1042
- * Each entry is merged into the request as a direct request to that entry's
1043
- * model, so it must be formatted accordingly: `model` is required, and an
1044
- * entry may additionally override `max_tokens`, `thinking`, `output_config`,
1045
- * and `speed` for that attempt only (`speed` additionally requires the speed
1046
- * beta). The value is passed through to the API as-is.
1073
+ * automatically retries it server-side on a fallback model. A
1074
+ * `content-filter` finish reason means the fallback(s) refused as well.
1047
1075
  *
1048
- * The required `server-side-fallback-2026-06-01` beta is added automatically
1049
- * when this option is set.
1076
+ * - `'default'` (recommended): the API routes the retry to Anthropic's
1077
+ * recommended fallback model based on the refusal category. Requires the
1078
+ * `server-side-fallback-2026-07-01` beta, which is added automatically.
1079
+ * - Array form: an explicit fallback chain. Each entry is merged into the
1080
+ * request as a direct request to that entry's model, so it must be
1081
+ * formatted accordingly: `model` is required, and an entry may
1082
+ * additionally override `max_tokens`, `thinking`, `output_config`, and
1083
+ * `speed` for that attempt only (`speed` additionally requires the speed
1084
+ * beta). The value is passed through to the API as-is, and the
1085
+ * `server-side-fallback-2026-06-01` beta is added automatically.
1050
1086
  */
1051
- fallbacks: import_v43.z.array(
1052
- import_v43.z.object({
1053
- model: import_v43.z.string(),
1054
- max_tokens: import_v43.z.number().int().optional(),
1055
- thinking: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1056
- output_config: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1057
- speed: import_v43.z.enum(["fast", "standard"]).optional()
1058
- })
1059
- ).optional(),
1087
+ fallbacks: import_v43.z.union([
1088
+ import_v43.z.literal("default"),
1089
+ import_v43.z.array(
1090
+ import_v43.z.object({
1091
+ model: import_v43.z.string(),
1092
+ max_tokens: import_v43.z.number().int().optional(),
1093
+ thinking: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1094
+ output_config: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
1095
+ speed: import_v43.z.enum(["fast", "standard"]).optional()
1096
+ })
1097
+ )
1098
+ ]).optional(),
1060
1099
  /**
1061
1100
  * A set of beta features to enable.
1062
1101
  * Allow a provider to receive the full `betas` set if it needs it.
@@ -1811,12 +1850,13 @@ function convertAnthropicMessagesUsage({
1811
1850
  usage,
1812
1851
  rawUsage
1813
1852
  }) {
1814
- var _a, _b, _c;
1853
+ var _a, _b, _c, _d, _e;
1815
1854
  const cacheCreationTokens = (_a = usage.cache_creation_input_tokens) != null ? _a : 0;
1816
1855
  const cacheReadTokens = (_b = usage.cache_read_input_tokens) != null ? _b : 0;
1856
+ const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.thinking_tokens) != null ? _d : void 0;
1817
1857
  let inputTokens;
1818
1858
  let outputTokens;
1819
- const servedByFallback = (_c = usage.iterations) == null ? void 0 : _c.some(
1859
+ const servedByFallback = (_e = usage.iterations) == null ? void 0 : _e.some(
1820
1860
  (iter) => iter.type === "fallback_message"
1821
1861
  );
1822
1862
  if (usage.iterations && usage.iterations.length > 0 && !servedByFallback) {
@@ -1850,8 +1890,8 @@ function convertAnthropicMessagesUsage({
1850
1890
  },
1851
1891
  outputTokens: {
1852
1892
  total: outputTokens,
1853
- text: void 0,
1854
- reasoning: void 0
1893
+ text: reasoningTokens == null ? void 0 : outputTokens - reasoningTokens,
1894
+ reasoning: reasoningTokens
1855
1895
  },
1856
1896
  raw: rawUsage != null ? rawUsage : usage
1857
1897
  };
@@ -2214,7 +2254,7 @@ async function convertToAnthropicMessagesPrompt({
2214
2254
  cacheControlValidator,
2215
2255
  toolNameMapping
2216
2256
  }) {
2217
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2257
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2218
2258
  const betas = /* @__PURE__ */ new Set();
2219
2259
  const blocks = groupIntoBlocks(prompt);
2220
2260
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2246,19 +2286,52 @@ async function convertToAnthropicMessagesPrompt({
2246
2286
  const type = block.type;
2247
2287
  switch (type) {
2248
2288
  case "system": {
2249
- const content = block.messages.map(({ content: content2, providerOptions }) => ({
2250
- type: "text",
2251
- text: content2,
2252
- cache_control: validator.getCacheControl(providerOptions, {
2253
- type: "system message",
2254
- canCache: true
2255
- })
2256
- }));
2257
- if (system == null) {
2258
- system = content;
2289
+ const content = [];
2290
+ let toolChangeCount = 0;
2291
+ for (const { content: text, providerOptions } of block.messages) {
2292
+ const systemMessageOptions = await (0, import_provider_utils14.parseProviderOptions)({
2293
+ provider: "anthropic",
2294
+ providerOptions,
2295
+ schema: anthropicSystemMessageProviderOptions
2296
+ });
2297
+ const toolChanges = (_a = systemMessageOptions == null ? void 0 : systemMessageOptions.toolChanges) != null ? _a : [];
2298
+ if (text !== "" || toolChanges.length === 0) {
2299
+ content.push({
2300
+ type: "text",
2301
+ text,
2302
+ cache_control: validator.getCacheControl(providerOptions, {
2303
+ type: "system message",
2304
+ canCache: true
2305
+ })
2306
+ });
2307
+ }
2308
+ for (const toolChange of toolChanges) {
2309
+ toolChangeCount++;
2310
+ content.push({
2311
+ type: toolChange.type,
2312
+ tool: {
2313
+ type: "tool_reference",
2314
+ name: toolNameMapping.toProviderToolName(toolChange.toolName)
2315
+ }
2316
+ });
2317
+ }
2318
+ }
2319
+ if (i === 0 || system == null && toolChangeCount === 0) {
2320
+ if (toolChangeCount > 0) {
2321
+ warnings.push({
2322
+ type: "other",
2323
+ message: "tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."
2324
+ });
2325
+ }
2326
+ system = content.filter(
2327
+ (part) => part.type === "text"
2328
+ );
2259
2329
  } else {
2260
2330
  messages.push({ role: "system", content });
2261
2331
  betas.add("mid-conversation-system-2026-04-07");
2332
+ if (toolChangeCount > 0) {
2333
+ betas.add("mid-conversation-tool-changes-2026-07-01");
2334
+ }
2262
2335
  }
2263
2336
  break;
2264
2337
  }
@@ -2271,10 +2344,10 @@ async function convertToAnthropicMessagesPrompt({
2271
2344
  for (let j = 0; j < content.length; j++) {
2272
2345
  const part = content[j];
2273
2346
  const isLastPart = j === content.length - 1;
2274
- const cacheControl = (_a = validator.getCacheControl(part.providerOptions, {
2347
+ const cacheControl = (_b = validator.getCacheControl(part.providerOptions, {
2275
2348
  type: "user message part",
2276
2349
  canCache: true
2277
- })) != null ? _a : isLastPart ? validator.getCacheControl(message.providerOptions, {
2350
+ })) != null ? _b : isLastPart ? validator.getCacheControl(message.providerOptions, {
2278
2351
  type: "user message",
2279
2352
  canCache: true
2280
2353
  }) : void 0;
@@ -2319,7 +2392,7 @@ async function convertToAnthropicMessagesPrompt({
2319
2392
  media_type: "application/pdf",
2320
2393
  data: (0, import_provider_utils14.convertToBase64)(part.data)
2321
2394
  },
2322
- title: (_b = metadata.title) != null ? _b : part.filename,
2395
+ title: (_c = metadata.title) != null ? _c : part.filename,
2323
2396
  ...metadata.context && { context: metadata.context },
2324
2397
  ...enableCitations && {
2325
2398
  citations: { enabled: true }
@@ -2343,7 +2416,7 @@ async function convertToAnthropicMessagesPrompt({
2343
2416
  media_type: "text/plain",
2344
2417
  data: convertToString(part.data)
2345
2418
  },
2346
- title: (_c = metadata.title) != null ? _c : part.filename,
2419
+ title: (_d = metadata.title) != null ? _d : part.filename,
2347
2420
  ...metadata.context && { context: metadata.context },
2348
2421
  ...enableCitations && {
2349
2422
  citations: { enabled: true }
@@ -2368,17 +2441,17 @@ async function convertToAnthropicMessagesPrompt({
2368
2441
  continue;
2369
2442
  }
2370
2443
  const output = part.output;
2371
- const outputProviderOptions = "providerOptions" in output ? output.providerOptions : output.type === "content" ? (_d = output.value.find(
2444
+ const outputProviderOptions = "providerOptions" in output ? output.providerOptions : output.type === "content" ? (_e = output.value.find(
2372
2445
  (contentPart) => contentPart.providerOptions != null
2373
- )) == null ? void 0 : _d.providerOptions : void 0;
2446
+ )) == null ? void 0 : _e.providerOptions : void 0;
2374
2447
  const isLastPart = i2 === content.length - 1;
2375
- const cacheControl = (_f = (_e = validator.getCacheControl(part.providerOptions, {
2448
+ const cacheControl = (_g = (_f = validator.getCacheControl(part.providerOptions, {
2376
2449
  type: "tool result part",
2377
2450
  canCache: true
2378
- })) != null ? _e : validator.getCacheControl(outputProviderOptions, {
2451
+ })) != null ? _f : validator.getCacheControl(outputProviderOptions, {
2379
2452
  type: "tool result output",
2380
2453
  canCache: true
2381
- })) != null ? _f : isLastPart ? validator.getCacheControl(message.providerOptions, {
2454
+ })) != null ? _g : isLastPart ? validator.getCacheControl(message.providerOptions, {
2382
2455
  type: "tool result message",
2383
2456
  canCache: true
2384
2457
  }) : void 0;
@@ -2468,7 +2541,7 @@ async function convertToAnthropicMessagesPrompt({
2468
2541
  contentValue = output.value;
2469
2542
  break;
2470
2543
  case "execution-denied":
2471
- contentValue = (_g = output.reason) != null ? _g : "Tool call execution denied.";
2544
+ contentValue = (_h = output.reason) != null ? _h : "Tool call execution denied.";
2472
2545
  break;
2473
2546
  case "json":
2474
2547
  case "error-json":
@@ -2505,16 +2578,16 @@ async function convertToAnthropicMessagesPrompt({
2505
2578
  for (let k = 0; k < content.length; k++) {
2506
2579
  const part = content[k];
2507
2580
  const isLastContentPart = k === content.length - 1;
2508
- const cacheControl = (_h = validator.getCacheControl(part.providerOptions, {
2581
+ const cacheControl = (_i = validator.getCacheControl(part.providerOptions, {
2509
2582
  type: "assistant message part",
2510
2583
  canCache: true
2511
- })) != null ? _h : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2584
+ })) != null ? _i : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2512
2585
  type: "assistant message",
2513
2586
  canCache: true
2514
2587
  }) : void 0;
2515
2588
  switch (part.type) {
2516
2589
  case "text": {
2517
- const textMetadata = (_i = part.providerOptions) == null ? void 0 : _i.anthropic;
2590
+ const textMetadata = (_j = part.providerOptions) == null ? void 0 : _j.anthropic;
2518
2591
  if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
2519
2592
  anthropicContent.push({
2520
2593
  type: "compaction",
@@ -2590,10 +2663,10 @@ async function convertToAnthropicMessagesPrompt({
2590
2663
  const providerToolName = toolNameMapping.toProviderToolName(
2591
2664
  part.toolName
2592
2665
  );
2593
- const isMcpToolUse = ((_k = (_j = part.providerOptions) == null ? void 0 : _j.anthropic) == null ? void 0 : _k.type) === "mcp-tool-use";
2666
+ const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.type) === "mcp-tool-use";
2594
2667
  if (isMcpToolUse) {
2595
2668
  mcpToolUseIds.add(part.toolCallId);
2596
- const serverName = (_m = (_l = part.providerOptions) == null ? void 0 : _l.anthropic) == null ? void 0 : _m.serverName;
2669
+ const serverName = (_n = (_m = part.providerOptions) == null ? void 0 : _m.anthropic) == null ? void 0 : _n.serverName;
2597
2670
  if (serverName == null || typeof serverName !== "string") {
2598
2671
  warnings.push({
2599
2672
  type: "other",
@@ -2669,7 +2742,7 @@ async function convertToAnthropicMessagesPrompt({
2669
2742
  }
2670
2743
  break;
2671
2744
  }
2672
- const callerOptions = (_n = part.providerOptions) == null ? void 0 : _n.anthropic;
2745
+ const callerOptions = (_o = part.providerOptions) == null ? void 0 : _o.anthropic;
2673
2746
  const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
2674
2747
  type: callerOptions.caller.type,
2675
2748
  tool_id: callerOptions.caller.toolId
@@ -2722,7 +2795,7 @@ async function convertToAnthropicMessagesPrompt({
2722
2795
  tool_use_id: part.toolCallId,
2723
2796
  content: {
2724
2797
  type: "code_execution_tool_result_error",
2725
- error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
2798
+ error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
2726
2799
  },
2727
2800
  cache_control: cacheControl
2728
2801
  });
@@ -2733,7 +2806,7 @@ async function convertToAnthropicMessagesPrompt({
2733
2806
  cache_control: cacheControl,
2734
2807
  content: {
2735
2808
  type: "bash_code_execution_tool_result_error",
2736
- error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
2809
+ error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
2737
2810
  }
2738
2811
  });
2739
2812
  }
@@ -2766,7 +2839,7 @@ async function convertToAnthropicMessagesPrompt({
2766
2839
  stdout: codeExecutionOutput.stdout,
2767
2840
  stderr: codeExecutionOutput.stderr,
2768
2841
  return_code: codeExecutionOutput.return_code,
2769
- content: (_q = codeExecutionOutput.content) != null ? _q : []
2842
+ content: (_r = codeExecutionOutput.content) != null ? _r : []
2770
2843
  },
2771
2844
  cache_control: cacheControl
2772
2845
  });
@@ -2784,7 +2857,7 @@ async function convertToAnthropicMessagesPrompt({
2784
2857
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2785
2858
  stderr: codeExecutionOutput.stderr,
2786
2859
  return_code: codeExecutionOutput.return_code,
2787
- content: (_r = codeExecutionOutput.content) != null ? _r : []
2860
+ content: (_s = codeExecutionOutput.content) != null ? _s : []
2788
2861
  },
2789
2862
  cache_control: cacheControl
2790
2863
  });
@@ -2803,7 +2876,7 @@ async function convertToAnthropicMessagesPrompt({
2803
2876
  stdout: codeExecutionOutput.stdout,
2804
2877
  stderr: codeExecutionOutput.stderr,
2805
2878
  return_code: codeExecutionOutput.return_code,
2806
- content: (_s = codeExecutionOutput.content) != null ? _s : []
2879
+ content: (_t = codeExecutionOutput.content) != null ? _t : []
2807
2880
  },
2808
2881
  cache_control: cacheControl
2809
2882
  });
@@ -2833,7 +2906,7 @@ async function convertToAnthropicMessagesPrompt({
2833
2906
  tool_use_id: part.toolCallId,
2834
2907
  content: {
2835
2908
  type: "web_fetch_tool_result_error",
2836
- error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
2909
+ error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
2837
2910
  },
2838
2911
  cache_control: cacheControl
2839
2912
  });
@@ -2880,7 +2953,7 @@ async function convertToAnthropicMessagesPrompt({
2880
2953
  tool_use_id: part.toolCallId,
2881
2954
  content: {
2882
2955
  type: "web_search_tool_result_error",
2883
- error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
2956
+ error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
2884
2957
  },
2885
2958
  cache_control: cacheControl
2886
2959
  });
@@ -3338,7 +3411,7 @@ var AnthropicMessagesLanguageModel = class {
3338
3411
  providerOptions,
3339
3412
  stream
3340
3413
  }) {
3341
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3414
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3342
3415
  const warnings = [];
3343
3416
  if (frequencyPenalty != null) {
3344
3417
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -3394,6 +3467,7 @@ var AnthropicMessagesLanguageModel = class {
3394
3467
  maxOutputTokens: maxOutputTokensForModel,
3395
3468
  supportsStructuredOutput: modelSupportsStructuredOutput,
3396
3469
  rejectsSamplingParameters,
3470
+ rejectsThinkingDisabledAboveHighEffort,
3397
3471
  isKnownModel
3398
3472
  } = getModelCapabilities(this.modelId);
3399
3473
  if (!isKnownModel && maxOutputTokens == null) {
@@ -3480,11 +3554,19 @@ var AnthropicMessagesLanguageModel = class {
3480
3554
  cacheControlValidator,
3481
3555
  toolNameMapping
3482
3556
  });
3483
- const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3557
+ if (rejectsThinkingDisabledAboveHighEffort && ((_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type) === "disabled" && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
3558
+ warnings.push({
3559
+ type: "unsupported",
3560
+ feature: "providerOptions.anthropic.effort",
3561
+ details: `effort '${anthropicOptions.effort}' is not supported by ${this.modelId} when thinking is disabled. The effort has been lowered to 'high'.`
3562
+ });
3563
+ anthropicOptions.effort = "high";
3564
+ }
3565
+ const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
3484
3566
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3485
3567
  const sendThinking = isThinking || thinkingType === "disabled";
3486
- let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3487
- const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.display : void 0;
3568
+ let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3569
+ const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
3488
3570
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3489
3571
  const baseArgs = {
3490
3572
  // model id:
@@ -3531,13 +3613,13 @@ var AnthropicMessagesLanguageModel = class {
3531
3613
  ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3532
3614
  inference_geo: anthropicOptions.inferenceGeo
3533
3615
  },
3534
- ...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0 && {
3616
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) != null && (anthropicOptions.fallbacks === "default" || anthropicOptions.fallbacks.length > 0) && {
3535
3617
  fallbacks: anthropicOptions.fallbacks
3536
3618
  },
3537
3619
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3538
3620
  cache_control: anthropicOptions.cacheControl
3539
3621
  },
3540
- ...((_h = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _h.userId) != null && {
3622
+ ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3541
3623
  metadata: { user_id: anthropicOptions.metadata.userId }
3542
3624
  },
3543
3625
  // mcp servers:
@@ -3710,10 +3792,12 @@ var AnthropicMessagesLanguageModel = class {
3710
3792
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3711
3793
  betas.add("fast-mode-2026-02-01");
3712
3794
  }
3713
- if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
3795
+ if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) === "default") {
3796
+ betas.add("server-side-fallback-2026-07-01");
3797
+ } else if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
3714
3798
  betas.add("server-side-fallback-2026-06-01");
3715
3799
  }
3716
- const defaultEagerInputStreaming = stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true);
3800
+ const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
3717
3801
  const {
3718
3802
  tools: anthropicTools2,
3719
3803
  toolChoice: anthropicToolChoice,
@@ -3752,7 +3836,7 @@ var AnthropicMessagesLanguageModel = class {
3752
3836
  ...betas,
3753
3837
  ...toolsBetas,
3754
3838
  ...userSuppliedBetas,
3755
- ...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
3839
+ ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
3756
3840
  ]),
3757
3841
  usesJsonResponseTool: jsonResponseTool != null,
3758
3842
  toolNameMapping,
@@ -5077,6 +5161,9 @@ var AnthropicMessagesLanguageModel = class {
5077
5161
  usage.input_tokens = value.usage.input_tokens;
5078
5162
  }
5079
5163
  usage.output_tokens = value.usage.output_tokens;
5164
+ if (value.usage.output_tokens_details != null) {
5165
+ usage.output_tokens_details = value.usage.output_tokens_details;
5166
+ }
5080
5167
  if (value.usage.cache_read_input_tokens != null) {
5081
5168
  usage.cache_read_input_tokens = value.usage.cache_read_input_tokens;
5082
5169
  }
@@ -5198,11 +5285,20 @@ var AnthropicMessagesLanguageModel = class {
5198
5285
  }
5199
5286
  };
5200
5287
  function getModelCapabilities(modelId) {
5201
- if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
5288
+ if (modelId.includes("claude-opus-5")) {
5289
+ return {
5290
+ maxOutputTokens: 128e3,
5291
+ supportsStructuredOutput: true,
5292
+ rejectsSamplingParameters: true,
5293
+ rejectsThinkingDisabledAboveHighEffort: true,
5294
+ isKnownModel: true
5295
+ };
5296
+ } else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
5202
5297
  return {
5203
5298
  maxOutputTokens: 128e3,
5204
5299
  supportsStructuredOutput: true,
5205
5300
  rejectsSamplingParameters: true,
5301
+ rejectsThinkingDisabledAboveHighEffort: false,
5206
5302
  isKnownModel: true
5207
5303
  };
5208
5304
  } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
@@ -5210,6 +5306,7 @@ function getModelCapabilities(modelId) {
5210
5306
  maxOutputTokens: 128e3,
5211
5307
  supportsStructuredOutput: true,
5212
5308
  rejectsSamplingParameters: false,
5309
+ rejectsThinkingDisabledAboveHighEffort: false,
5213
5310
  isKnownModel: true
5214
5311
  };
5215
5312
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -5217,6 +5314,7 @@ function getModelCapabilities(modelId) {
5217
5314
  maxOutputTokens: 64e3,
5218
5315
  supportsStructuredOutput: true,
5219
5316
  rejectsSamplingParameters: false,
5317
+ rejectsThinkingDisabledAboveHighEffort: false,
5220
5318
  isKnownModel: true
5221
5319
  };
5222
5320
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -5224,6 +5322,7 @@ function getModelCapabilities(modelId) {
5224
5322
  maxOutputTokens: 32e3,
5225
5323
  supportsStructuredOutput: true,
5226
5324
  rejectsSamplingParameters: false,
5325
+ rejectsThinkingDisabledAboveHighEffort: false,
5227
5326
  isKnownModel: true
5228
5327
  };
5229
5328
  } else if (modelId.includes("claude-sonnet-4-")) {
@@ -5231,6 +5330,7 @@ function getModelCapabilities(modelId) {
5231
5330
  maxOutputTokens: 64e3,
5232
5331
  supportsStructuredOutput: false,
5233
5332
  rejectsSamplingParameters: false,
5333
+ rejectsThinkingDisabledAboveHighEffort: false,
5234
5334
  isKnownModel: true
5235
5335
  };
5236
5336
  } else if (modelId.includes("claude-opus-4-")) {
@@ -5238,6 +5338,7 @@ function getModelCapabilities(modelId) {
5238
5338
  maxOutputTokens: 32e3,
5239
5339
  supportsStructuredOutput: false,
5240
5340
  rejectsSamplingParameters: false,
5341
+ rejectsThinkingDisabledAboveHighEffort: false,
5241
5342
  isKnownModel: true
5242
5343
  };
5243
5344
  } else if (modelId.includes("claude-3-haiku")) {
@@ -5245,6 +5346,7 @@ function getModelCapabilities(modelId) {
5245
5346
  maxOutputTokens: 4096,
5246
5347
  supportsStructuredOutput: false,
5247
5348
  rejectsSamplingParameters: false,
5349
+ rejectsThinkingDisabledAboveHighEffort: false,
5248
5350
  isKnownModel: true
5249
5351
  };
5250
5352
  } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
@@ -5252,6 +5354,7 @@ function getModelCapabilities(modelId) {
5252
5354
  maxOutputTokens: 4096,
5253
5355
  supportsStructuredOutput: false,
5254
5356
  rejectsSamplingParameters: false,
5357
+ rejectsThinkingDisabledAboveHighEffort: false,
5255
5358
  isKnownModel: false
5256
5359
  };
5257
5360
  } else if (modelId.includes("claude-")) {
@@ -5259,6 +5362,7 @@ function getModelCapabilities(modelId) {
5259
5362
  maxOutputTokens: 128e3,
5260
5363
  supportsStructuredOutput: true,
5261
5364
  rejectsSamplingParameters: true,
5365
+ rejectsThinkingDisabledAboveHighEffort: true,
5262
5366
  isKnownModel: false
5263
5367
  };
5264
5368
  } else {
@@ -5266,6 +5370,7 @@ function getModelCapabilities(modelId) {
5266
5370
  maxOutputTokens: 4096,
5267
5371
  supportsStructuredOutput: false,
5268
5372
  rejectsSamplingParameters: false,
5373
+ rejectsThinkingDisabledAboveHighEffort: false,
5269
5374
  isKnownModel: false
5270
5375
  };
5271
5376
  }