@anthropic-ai/sdk 0.114.0 → 0.115.0

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.
Files changed (116) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/client.d.mts.map +1 -1
  3. package/client.d.ts.map +1 -1
  4. package/client.js +8 -1
  5. package/client.js.map +1 -1
  6. package/client.mjs +8 -1
  7. package/client.mjs.map +1 -1
  8. package/core/streaming.d.mts.map +1 -1
  9. package/core/streaming.d.ts.map +1 -1
  10. package/core/streaming.js +3 -0
  11. package/core/streaming.js.map +1 -1
  12. package/core/streaming.mjs +3 -0
  13. package/core/streaming.mjs.map +1 -1
  14. package/internal/parse.d.mts.map +1 -1
  15. package/internal/parse.d.ts.map +1 -1
  16. package/internal/parse.js +10 -1
  17. package/internal/parse.js.map +1 -1
  18. package/internal/parse.mjs +10 -1
  19. package/internal/parse.mjs.map +1 -1
  20. package/internal/request-signal.d.mts +4 -0
  21. package/internal/request-signal.d.mts.map +1 -0
  22. package/internal/request-signal.d.ts +4 -0
  23. package/internal/request-signal.d.ts.map +1 -0
  24. package/internal/request-signal.js +50 -0
  25. package/internal/request-signal.js.map +1 -0
  26. package/internal/request-signal.mjs +45 -0
  27. package/internal/request-signal.mjs.map +1 -0
  28. package/lib/BetaMessageStream.d.mts.map +1 -1
  29. package/lib/BetaMessageStream.d.ts.map +1 -1
  30. package/lib/BetaMessageStream.js +3 -0
  31. package/lib/BetaMessageStream.js.map +1 -1
  32. package/lib/BetaMessageStream.mjs +3 -0
  33. package/lib/BetaMessageStream.mjs.map +1 -1
  34. package/lib/middleware.d.mts +5 -3
  35. package/lib/middleware.d.mts.map +1 -1
  36. package/lib/middleware.d.ts +5 -3
  37. package/lib/middleware.d.ts.map +1 -1
  38. package/lib/middleware.js +58 -15
  39. package/lib/middleware.js.map +1 -1
  40. package/lib/middleware.mjs +58 -15
  41. package/lib/middleware.mjs.map +1 -1
  42. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  43. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  44. package/lib/tools/BetaToolRunner.js +80 -7
  45. package/lib/tools/BetaToolRunner.js.map +1 -1
  46. package/lib/tools/BetaToolRunner.mjs +80 -7
  47. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  48. package/package.json +1 -1
  49. package/resources/beta/agents/agents.d.mts +1 -1
  50. package/resources/beta/agents/agents.d.mts.map +1 -1
  51. package/resources/beta/agents/agents.d.ts +1 -1
  52. package/resources/beta/agents/agents.d.ts.map +1 -1
  53. package/resources/beta/agents/agents.js.map +1 -1
  54. package/resources/beta/agents/agents.mjs.map +1 -1
  55. package/resources/beta/beta.d.mts +3 -3
  56. package/resources/beta/beta.d.mts.map +1 -1
  57. package/resources/beta/beta.d.ts +3 -3
  58. package/resources/beta/beta.d.ts.map +1 -1
  59. package/resources/beta/beta.js.map +1 -1
  60. package/resources/beta/beta.mjs.map +1 -1
  61. package/resources/beta/index.d.mts +1 -1
  62. package/resources/beta/index.d.mts.map +1 -1
  63. package/resources/beta/index.d.ts +1 -1
  64. package/resources/beta/index.d.ts.map +1 -1
  65. package/resources/beta/index.js.map +1 -1
  66. package/resources/beta/index.mjs.map +1 -1
  67. package/resources/beta/messages/batches.d.mts +4 -3
  68. package/resources/beta/messages/batches.d.mts.map +1 -1
  69. package/resources/beta/messages/batches.d.ts +4 -3
  70. package/resources/beta/messages/batches.d.ts.map +1 -1
  71. package/resources/beta/messages/index.d.mts +1 -1
  72. package/resources/beta/messages/index.d.mts.map +1 -1
  73. package/resources/beta/messages/index.d.ts +1 -1
  74. package/resources/beta/messages/index.d.ts.map +1 -1
  75. package/resources/beta/messages/index.js.map +1 -1
  76. package/resources/beta/messages/index.mjs.map +1 -1
  77. package/resources/beta/messages/messages.d.mts +154 -6
  78. package/resources/beta/messages/messages.d.mts.map +1 -1
  79. package/resources/beta/messages/messages.d.ts +154 -6
  80. package/resources/beta/messages/messages.d.ts.map +1 -1
  81. package/resources/beta/messages/messages.js.map +1 -1
  82. package/resources/beta/messages/messages.mjs.map +1 -1
  83. package/resources/messages/messages.d.mts +1 -1
  84. package/resources/messages/messages.d.mts.map +1 -1
  85. package/resources/messages/messages.d.ts +1 -1
  86. package/resources/messages/messages.d.ts.map +1 -1
  87. package/resources/messages/messages.js.map +1 -1
  88. package/resources/messages/messages.mjs.map +1 -1
  89. package/src/client.ts +13 -1
  90. package/src/core/streaming.ts +3 -0
  91. package/src/internal/parse.ts +10 -1
  92. package/src/internal/request-signal.ts +68 -0
  93. package/src/lib/BetaMessageStream.ts +4 -0
  94. package/src/lib/middleware.ts +61 -16
  95. package/src/lib/tools/BetaToolRunner.ts +101 -8
  96. package/src/resources/beta/agents/agents.ts +1 -0
  97. package/src/resources/beta/beta.ts +22 -0
  98. package/src/resources/beta/index.ts +10 -0
  99. package/src/resources/beta/messages/batches.ts +4 -3
  100. package/src/resources/beta/messages/index.ts +10 -0
  101. package/src/resources/beta/messages/messages.ts +199 -4
  102. package/src/resources/messages/messages.ts +1 -0
  103. package/src/version.ts +1 -1
  104. package/version.d.mts +1 -1
  105. package/version.d.ts +1 -1
  106. package/version.js +1 -1
  107. package/version.mjs +1 -1
  108. package/lib/tools/ToolRunner.d.mts +0 -132
  109. package/lib/tools/ToolRunner.d.mts.map +0 -1
  110. package/lib/tools/ToolRunner.d.ts +0 -132
  111. package/lib/tools/ToolRunner.d.ts.map +0 -1
  112. package/lib/tools/ToolRunner.js +0 -294
  113. package/lib/tools/ToolRunner.js.map +0 -1
  114. package/lib/tools/ToolRunner.mjs +0 -290
  115. package/lib/tools/ToolRunner.mjs.map +0 -1
  116. package/src/lib/tools/ToolRunner.ts +0 -381
@@ -610,6 +610,10 @@ export class BetaMessageStream<ParsedT = null> implements AsyncIterable<BetaMess
610
610
  snapshot.usage.iterations = event.usage.iterations;
611
611
  }
612
612
 
613
+ if (event.usage.fallback_credit != null) {
614
+ snapshot.usage.fallback_credit = event.usage.fallback_credit;
615
+ }
616
+
613
617
  return snapshot;
614
618
  case 'content_block_start':
615
619
  snapshot.content.push(event.content_block);
@@ -10,6 +10,7 @@ import type { AnthropicBeta } from '../resources/beta/beta';
10
10
  import type {
11
11
  BetaContentBlockParam,
12
12
  BetaFallbackBlock,
13
+ BetaFallbackCreditTokenParam,
13
14
  BetaFallbackMessageIterationUsage,
14
15
  BetaFallbackParam,
15
16
  BetaMessage,
@@ -31,7 +32,7 @@ export { BetaFallbackState } from '../internal/request-options';
31
32
  const encoder = new TextEncoder();
32
33
 
33
34
  /** Betas sent by default; override with {@link BetaRefusalFallbackOptions.betas}. */
34
- const DEFAULT_BETAS: readonly AnthropicBeta[] = ['fallback-credit-2026-06-01'];
35
+ const DEFAULT_BETAS: readonly AnthropicBeta[] = ['fallback-credit-2026-07-01'];
35
36
 
36
37
  /**
37
38
  * Remove `fallback` blocks replayed in history. They only parse under the
@@ -50,6 +51,42 @@ function stripFallbackBlocks(body: MessageCreateParams): MessageCreateParams {
50
51
  return { ...body, messages };
51
52
  }
52
53
 
54
+ /**
55
+ * Apply one chain entry to the original request params as a patch: a field
56
+ * set to a value overrides the original, a field explicitly `null` removes
57
+ * the field from the retried request, and an absent (or `undefined`) field
58
+ * keeps the original value. `output_config` patches one level deep — its
59
+ * subfields follow the same set/`null`/absent rules against the original
60
+ * `output_config` (created if the entry sets any subfield). Every hop patches
61
+ * the original params — never a previous hop's patched body — and `body` is
62
+ * never mutated.
63
+ */
64
+ function applyFallbackPatch(body: MessageCreateParams, entry: BetaFallbackParam): MessageCreateParams {
65
+ const patched = { ...body } as Record<string, unknown>;
66
+ for (const [key, value] of Object.entries(entry)) {
67
+ if (key === 'output_config' && value != null) {
68
+ const merged = { ...((patched[key] as Record<string, unknown> | undefined) ?? {}) };
69
+ for (const [subKey, subValue] of Object.entries(value)) {
70
+ patchField(merged, subKey, subValue);
71
+ }
72
+ patchField(patched, key, Object.keys(merged).length ? merged : null);
73
+ } else {
74
+ patchField(patched, key, value);
75
+ }
76
+ }
77
+ return patched as unknown as MessageCreateParams;
78
+ }
79
+
80
+ /** Set/`null`-unset/absent-keep one field on `target` (mutated). */
81
+ function patchField(target: Record<string, unknown>, key: string, value: unknown): void {
82
+ if (value === undefined) return;
83
+ if (value === null) {
84
+ delete target[key];
85
+ } else {
86
+ target[key] = value;
87
+ }
88
+ }
89
+
53
90
  /** Why {@link BetaRefusalFallbackOptions.onError} fired. */
54
91
  export type BetaRefusalFallbackError =
55
92
  | {
@@ -83,7 +120,7 @@ export interface BetaRefusalFallbackOptions {
83
120
  * Betas added to the `anthropic-beta` header of every `/v1/messages`
84
121
  * request this middleware handles — the original request included, since
85
122
  * refusals only carry a `fallback_credit_token` when the beta is enabled.
86
- * Defaults to `['fallback-credit-2026-06-01']`; pass `[]` to send none.
123
+ * Defaults to `['fallback-credit-2026-07-01']`; pass `[]` to send none.
87
124
  */
88
125
  betas?: readonly AnthropicBeta[] | undefined;
89
126
 
@@ -100,8 +137,10 @@ export interface BetaRefusalFallbackOptions {
100
137
  * Middleware that retries refused `/v1/messages` requests down a fallback chain.
101
138
  *
102
139
  * Non-streaming: when a response comes back with `stop_reason: 'refusal'`, the
103
- * request is retried with each entry of `fallbacks` merged over the original
104
- * params passing along the refusal's `fallback_credit_token` until a model
140
+ * request is retried with each entry of `fallbacks` applied as a patch to the
141
+ * original params (a set field overrides, an explicit `null` unsets, an absent
142
+ * field keeps the original value; entries never patch each other's requests)
143
+ * — passing along the refusal's `fallback_credit_token` — until a model
105
144
  * accepts or the chain is exhausted. A message served by a fallback carries a
106
145
  * `fallback` content block prepended at each model boundary — the same seam
107
146
  * block shape the server-side `fallbacks` param places in `content`, though
@@ -171,7 +210,7 @@ export function betaRefusalFallbackMiddleware(
171
210
  if ((ctx.options.body as MessageCreateParams).fallbacks != null) {
172
211
  throw new AnthropicError(
173
212
  'Sending the `fallbacks:` request param is not supported when using the `betaRefusalFallbackMiddleware`. ' +
174
- 'You should either remove the middleware and send `fallbacks:` with the `server-side-fallback-2026-06-01` beta header to let the API handle refusal fallbacks, ' +
213
+ 'You should either remove the middleware and send `fallbacks:` with the `server-side-fallback-2026-07-01` beta header to let the API handle refusal fallbacks, ' +
175
214
  "or omit the `fallbacks:` param if you'd like `betaRefusalFallbackMiddleware` to handle fallbacks on the client side.",
176
215
  );
177
216
  }
@@ -208,15 +247,12 @@ export function betaRefusalFallbackMiddleware(
208
247
  }
209
248
  };
210
249
 
250
+ const initialBody = startIndex === -1 ? body : applyFallbackPatch(body, fallbacks[startIndex]!);
251
+
211
252
  // a non-string body can't be respliced or redeemed against — leave the
212
253
  // request untouched (the streaming path stands down on it below too)
213
254
  const initialRequest =
214
- typeof request.body !== 'string' ?
215
- request
216
- : {
217
- ...request,
218
- body: JSON.stringify(startIndex === -1 ? body : { ...body, ...fallbacks[startIndex] }),
219
- };
255
+ typeof request.body !== 'string' ? request : { ...request, body: JSON.stringify(initialBody) };
220
256
 
221
257
  const response = await next(initialRequest);
222
258
  if (!response.ok) {
@@ -248,7 +284,7 @@ export function betaRefusalFallbackMiddleware(
248
284
  let res = response;
249
285
  // The model the current hop was requested as — the caller's spelling, not
250
286
  // the server's `message.model` echo; the seam block's `from` carries it.
251
- let requestedModel = (startIndex === -1 ? body : { ...body, ...fallbacks[startIndex] }).model;
287
+ let requestedModel = initialBody.model;
252
288
  const fallbackBlocks: BetaFallbackBlock[] = [];
253
289
  while (index < fallbacks.length - 1) {
254
290
  const message = await ctx.parse<BetaMessage | null>(res);
@@ -274,10 +310,9 @@ export function betaRefusalFallbackMiddleware(
274
310
  res = await next({
275
311
  ...request,
276
312
  body: JSON.stringify({
277
- ...body,
278
- ...entry,
313
+ ...applyFallbackPatch(body, entry),
279
314
  ...(message.stop_details?.fallback_credit_token ?
280
- { fallback_credit_token: message.stop_details.fallback_credit_token }
315
+ { fallback_credit_token: creditTokenParam(message.stop_details.fallback_credit_token) }
281
316
  : undefined),
282
317
  }),
283
318
  });
@@ -759,6 +794,16 @@ class BlockTracker {
759
794
 
760
795
  // --- fallback request construction (appended-assistant continuation) -------
761
796
 
797
+ /**
798
+ * Object form of the redeemed credit token. `best_effort` keeps the retry
799
+ * served if the token layer rejects it — the retry then proceeds at normal
800
+ * price and the outcome lands on `usage.fallback_credit` — where the
801
+ * bare-string (`strict`) form would 400 the whole request.
802
+ */
803
+ function creditTokenParam(token: string): BetaFallbackCreditTokenParam {
804
+ return { token, mode: 'best_effort' };
805
+ }
806
+
762
807
  function buildFallbackRequest(
763
808
  orig: APIRequest,
764
809
  {
@@ -775,7 +820,7 @@ function buildFallbackRequest(
775
820
  const body = JSON.parse(orig.body as string);
776
821
 
777
822
  body.model = model;
778
- body.fallback_credit_token = creditToken;
823
+ body.fallback_credit_token = creditTokenParam(creditToken);
779
824
 
780
825
  // Append the continuation (decided by the chain loop) as a trailing
781
826
  // assistant turn; everything else must stay identical to the refused
@@ -2,7 +2,18 @@ import { BetaRunnableTool } from './BetaRunnableTool';
2
2
  import { ToolError } from './ToolError';
3
3
  import { Anthropic } from '../..';
4
4
  import { AnthropicError } from '../../core/error';
5
- import { BetaMessage, BetaMessageParam, BetaToolUnion, MessageCreateParams } from '../../resources/beta';
5
+ import {
6
+ BetaContentBlockParam,
7
+ BetaMessage,
8
+ BetaMessageParam,
9
+ BetaRequestToolAdditionBlock,
10
+ BetaRequestToolRemovalBlock,
11
+ BetaToolChangeMCPToolReference,
12
+ BetaToolChangeMCPToolsetReference,
13
+ BetaToolChangeToolReference,
14
+ BetaToolUnion,
15
+ MessageCreateParams,
16
+ } from '../../resources/beta';
6
17
  import { BetaMessageStream } from '../BetaMessageStream';
7
18
  import { RequestOptions } from '../../internal/request-options';
8
19
  import { buildHeaders } from '../../internal/headers';
@@ -467,16 +478,14 @@ async function generateToolResponse(
467
478
  return null;
468
479
  }
469
480
 
481
+ const available = availableToolNames(params);
470
482
  const toolResults = await Promise.all(
471
483
  toolUseBlocks.map(async (toolUse) => {
472
484
  const tool = params.tools.find((t) => ('name' in t ? t.name : t.mcp_server_name) === toolUse.name);
473
- if (!tool || !('run' in tool)) {
474
- return {
475
- type: 'tool_result' as const,
476
- tool_use_id: toolUse.id,
477
- content: `Error: Tool '${toolUse.name}' not found`,
478
- is_error: true,
479
- };
485
+ // A `tool_removal` is only a hint to the model, which may still emit a tool_use for a
486
+ // withdrawn tool — treat those exactly like a tool that was never defined.
487
+ if (!tool || !('run' in tool) || !available.has(toolUse.name)) {
488
+ return toolNotFoundResult(toolUse);
480
489
  }
481
490
 
482
491
  try {
@@ -515,6 +524,90 @@ async function generateToolResponse(
515
524
  };
516
525
  }
517
526
 
527
+ function toolNotFoundResult(toolUse: { id: string; name: string }) {
528
+ return {
529
+ type: 'tool_result' as const,
530
+ tool_use_id: toolUse.id,
531
+ content: `Error: Tool '${toolUse.name}' not found`,
532
+ is_error: true,
533
+ };
534
+ }
535
+
536
+ /**
537
+ * Computes the names of locally runnable tools that are still available for the assistant
538
+ * turn being answered, by folding `tool_removal` / `tool_addition` blocks from the
539
+ * `role: "system"` messages over the runnable tools. The assistant turn being answered is
540
+ * terminal-or-absent and only `system` messages are inspected, so folding the whole current
541
+ * history is exactly folding the messages preceding that turn — call this before appending
542
+ * anything after it. MCP references are ignored — those tools are executed server-side and
543
+ * never dispatched by this runner.
544
+ */
545
+ function availableToolNames(params: BetaToolRunnerParams): Set<string> {
546
+ const available = new Set<string>();
547
+ for (const tool of params.tools) {
548
+ if ('run' in tool) {
549
+ available.add(tool.name);
550
+ }
551
+ }
552
+
553
+ for (const message of params.messages) {
554
+ if (message.role !== 'system' || typeof message.content === 'string') {
555
+ continue;
556
+ }
557
+ for (const block of message.content) {
558
+ applyToolChange(block, available);
559
+ }
560
+ }
561
+ return available;
562
+ }
563
+
564
+ function applyToolChange(block: BetaContentBlockParam, available: Set<string>): void {
565
+ switch (block.type) {
566
+ case 'tool_removal':
567
+ case 'tool_addition':
568
+ applyToolReference(block, available);
569
+ break;
570
+ case 'mid_conv_system':
571
+ // A `mid_conv_system` block's content is limited by the API schema to
572
+ // text / tool_addition / tool_removal, so we walk exactly one level — no recursion.
573
+ for (const inner of block.content) {
574
+ if (inner.type === 'tool_removal' || inner.type === 'tool_addition') {
575
+ applyToolReference(inner, available);
576
+ }
577
+ }
578
+ break;
579
+ default:
580
+ // Other and unknown/newer block types leave the set untouched (forward compatibility).
581
+ break;
582
+ }
583
+ }
584
+
585
+ function applyToolReference(
586
+ block: BetaRequestToolAdditionBlock | BetaRequestToolRemovalBlock,
587
+ available: Set<string>,
588
+ ): void {
589
+ const name = referencedToolName(block.tool);
590
+ if (name === undefined) return;
591
+ if (block.type === 'tool_removal') {
592
+ available.delete(name);
593
+ } else {
594
+ available.add(name);
595
+ }
596
+ }
597
+
598
+ function referencedToolName(
599
+ ref: BetaToolChangeToolReference | BetaToolChangeMCPToolReference | BetaToolChangeMCPToolsetReference,
600
+ ): string | undefined {
601
+ switch (ref.type) {
602
+ case 'tool_reference':
603
+ return ref.name;
604
+ default:
605
+ // mcp_tool_reference / mcp_toolset_reference run server-side; unknown reference
606
+ // types are ignored rather than rejected.
607
+ return undefined;
608
+ }
609
+ }
610
+
518
611
  // vendored from typefest just to make things look a bit nicer on hover
519
612
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
520
613
 
@@ -707,6 +707,7 @@ export interface BetaManagedAgentsMCPToolsetParams {
707
707
  export type BetaManagedAgentsModel =
708
708
  | 'claude-sonnet-5'
709
709
  | 'claude-fable-5'
710
+ | 'claude-opus-5'
710
711
  | 'claude-opus-4-8'
711
712
  | 'claude-opus-4-7'
712
713
  | 'claude-opus-4-6'
@@ -363,11 +363,16 @@ import {
363
363
  BetaEncryptedCodeExecutionResultBlockParam,
364
364
  BetaFallbackBlock,
365
365
  BetaFallbackBlockParam,
366
+ BetaFallbackCreditNotApplied,
367
+ BetaFallbackCreditRedeemed,
368
+ BetaFallbackCreditTokenParam,
369
+ BetaFallbackCreditUsage,
366
370
  BetaFallbackInfo,
367
371
  BetaFallbackInfoParam,
368
372
  BetaFallbackMessageIterationUsage,
369
373
  BetaFallbackParam,
370
374
  BetaFallbackRefusalTrigger,
375
+ BetaFallbacksParam,
371
376
  BetaFileDocumentSource,
372
377
  BetaFileImageSource,
373
378
  BetaImageBlockParam,
@@ -412,6 +417,8 @@ import {
412
417
  BetaRequestMCPServerToolConfiguration,
413
418
  BetaRequestMCPServerURLDefinition,
414
419
  BetaRequestMCPToolResultBlockParam,
420
+ BetaRequestToolAdditionBlock,
421
+ BetaRequestToolRemovalBlock,
415
422
  BetaSearchResultBlockParam,
416
423
  BetaServerToolCaller,
417
424
  BetaServerToolCaller20260120,
@@ -449,6 +456,9 @@ import {
449
456
  BetaTool,
450
457
  BetaToolBash20241022,
451
458
  BetaToolBash20250124,
459
+ BetaToolChangeMCPToolReference,
460
+ BetaToolChangeMCPToolsetReference,
461
+ BetaToolChangeToolReference,
452
462
  BetaToolChoice,
453
463
  BetaToolChoiceAny,
454
464
  BetaToolChoiceAuto,
@@ -633,7 +643,9 @@ export type AnthropicBeta =
633
643
  | 'dreaming-2026-04-21'
634
644
  | 'thinking-token-count-2026-05-13'
635
645
  | 'server-side-fallback-2026-06-01'
646
+ | 'server-side-fallback-2026-07-01'
636
647
  | 'fallback-credit-2026-06-01'
648
+ | 'fallback-credit-2026-07-01'
637
649
  | 'agent-memory-2026-07-22';
638
650
 
639
651
  export interface BetaAPIError {
@@ -842,11 +854,16 @@ export declare namespace Beta {
842
854
  type BetaEncryptedCodeExecutionResultBlockParam as BetaEncryptedCodeExecutionResultBlockParam,
843
855
  type BetaFallbackBlock as BetaFallbackBlock,
844
856
  type BetaFallbackBlockParam as BetaFallbackBlockParam,
857
+ type BetaFallbackCreditNotApplied as BetaFallbackCreditNotApplied,
858
+ type BetaFallbackCreditRedeemed as BetaFallbackCreditRedeemed,
859
+ type BetaFallbackCreditTokenParam as BetaFallbackCreditTokenParam,
860
+ type BetaFallbackCreditUsage as BetaFallbackCreditUsage,
845
861
  type BetaFallbackInfo as BetaFallbackInfo,
846
862
  type BetaFallbackInfoParam as BetaFallbackInfoParam,
847
863
  type BetaFallbackMessageIterationUsage as BetaFallbackMessageIterationUsage,
848
864
  type BetaFallbackParam as BetaFallbackParam,
849
865
  type BetaFallbackRefusalTrigger as BetaFallbackRefusalTrigger,
866
+ type BetaFallbacksParam as BetaFallbacksParam,
850
867
  type BetaFileDocumentSource as BetaFileDocumentSource,
851
868
  type BetaFileImageSource as BetaFileImageSource,
852
869
  type BetaImageBlockParam as BetaImageBlockParam,
@@ -893,6 +910,8 @@ export declare namespace Beta {
893
910
  type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
894
911
  type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
895
912
  type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
913
+ type BetaRequestToolAdditionBlock as BetaRequestToolAdditionBlock,
914
+ type BetaRequestToolRemovalBlock as BetaRequestToolRemovalBlock,
896
915
  type BetaSearchResultBlockParam as BetaSearchResultBlockParam,
897
916
  type BetaServerToolCaller as BetaServerToolCaller,
898
917
  type BetaServerToolCaller20260120 as BetaServerToolCaller20260120,
@@ -930,6 +949,9 @@ export declare namespace Beta {
930
949
  type BetaTool as BetaTool,
931
950
  type BetaToolBash20241022 as BetaToolBash20241022,
932
951
  type BetaToolBash20250124 as BetaToolBash20250124,
952
+ type BetaToolChangeMCPToolReference as BetaToolChangeMCPToolReference,
953
+ type BetaToolChangeMCPToolsetReference as BetaToolChangeMCPToolsetReference,
954
+ type BetaToolChangeToolReference as BetaToolChangeToolReference,
933
955
  type BetaToolChoice as BetaToolChoice,
934
956
  type BetaToolChoiceAny as BetaToolChoiceAny,
935
957
  type BetaToolChoiceAuto as BetaToolChoiceAuto,
@@ -292,11 +292,16 @@ export {
292
292
  type BetaEncryptedCodeExecutionResultBlockParam,
293
293
  type BetaFallbackBlock,
294
294
  type BetaFallbackBlockParam,
295
+ type BetaFallbackCreditNotApplied,
296
+ type BetaFallbackCreditRedeemed,
297
+ type BetaFallbackCreditTokenParam,
298
+ type BetaFallbackCreditUsage,
295
299
  type BetaFallbackInfo,
296
300
  type BetaFallbackInfoParam,
297
301
  type BetaFallbackMessageIterationUsage,
298
302
  type BetaFallbackParam,
299
303
  type BetaFallbackRefusalTrigger,
304
+ type BetaFallbacksParam,
300
305
  type BetaFileDocumentSource,
301
306
  type BetaFileImageSource,
302
307
  type BetaImageBlockParam,
@@ -344,6 +349,8 @@ export {
344
349
  type BetaRequestMCPServerToolConfiguration,
345
350
  type BetaRequestMCPServerURLDefinition,
346
351
  type BetaRequestMCPToolResultBlockParam,
352
+ type BetaRequestToolAdditionBlock,
353
+ type BetaRequestToolRemovalBlock,
347
354
  type BetaSearchResultBlockParam,
348
355
  type BetaServerToolCaller,
349
356
  type BetaServerToolCaller20260120,
@@ -381,6 +388,9 @@ export {
381
388
  type BetaTool,
382
389
  type BetaToolBash20241022,
383
390
  type BetaToolBash20250124,
391
+ type BetaToolChangeMCPToolReference,
392
+ type BetaToolChangeMCPToolsetReference,
393
+ type BetaToolChangeToolReference,
384
394
  type BetaToolChoice,
385
395
  type BetaToolChoiceAny,
386
396
  type BetaToolChoiceAuto,
@@ -607,14 +607,15 @@ export namespace BatchCreateParams {
607
607
  * When the appended-assistant form is used on a model that otherwise disallows
608
608
  * assistant-turn prefill, this token also authorizes that one prefill.
609
609
  */
610
- fallback_credit_token?: string | null;
610
+ fallback_credit_token?: string | BetaMessagesAPI.BetaFallbackCreditTokenParam | null;
611
611
 
612
612
  /**
613
613
  * Opt-in server-side retry on one or more substitute models when the requested
614
614
  * model declines for policy reasons. Tried in order: if the first entry also
615
- * declines, the second is tried, and so on.
615
+ * declines, the second is tried, and so on. The string "default" requests the
616
+ * requested model's server-defined default fallback configuration.
616
617
  */
617
- fallbacks?: Array<BetaMessagesAPI.BetaFallbackParam> | null;
618
+ fallbacks?: BetaMessagesAPI.BetaFallbacksParam | null;
618
619
 
619
620
  /**
620
621
  * Specifies the geographic region for inference processing. If not specified, the
@@ -106,11 +106,16 @@ export {
106
106
  type BetaEncryptedCodeExecutionResultBlockParam,
107
107
  type BetaFallbackBlock,
108
108
  type BetaFallbackBlockParam,
109
+ type BetaFallbackCreditNotApplied,
110
+ type BetaFallbackCreditRedeemed,
111
+ type BetaFallbackCreditTokenParam,
112
+ type BetaFallbackCreditUsage,
109
113
  type BetaFallbackInfo,
110
114
  type BetaFallbackInfoParam,
111
115
  type BetaFallbackMessageIterationUsage,
112
116
  type BetaFallbackParam,
113
117
  type BetaFallbackRefusalTrigger,
118
+ type BetaFallbacksParam,
114
119
  type BetaFileDocumentSource,
115
120
  type BetaFileImageSource,
116
121
  type BetaImageBlockParam,
@@ -156,6 +161,8 @@ export {
156
161
  type BetaRequestMCPServerToolConfiguration,
157
162
  type BetaRequestMCPServerURLDefinition,
158
163
  type BetaRequestMCPToolResultBlockParam,
164
+ type BetaRequestToolAdditionBlock,
165
+ type BetaRequestToolRemovalBlock,
159
166
  type BetaSearchResultBlockParam,
160
167
  type BetaServerToolCaller,
161
168
  type BetaServerToolCaller20260120,
@@ -193,6 +200,9 @@ export {
193
200
  type BetaTool,
194
201
  type BetaToolBash20241022,
195
202
  type BetaToolBash20250124,
203
+ type BetaToolChangeMCPToolReference,
204
+ type BetaToolChangeMCPToolsetReference,
205
+ type BetaToolChangeToolReference,
196
206
  type BetaToolChoice,
197
207
  type BetaToolChoiceAny,
198
208
  type BetaToolChoiceAuto,