@anthropic-ai/sdk 0.102.0 → 0.103.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.
- package/CHANGELOG.md +15 -0
- package/client.d.mts +30 -7
- package/client.d.mts.map +1 -1
- package/client.d.ts +30 -7
- package/client.d.ts.map +1 -1
- package/client.js +48 -25
- package/client.js.map +1 -1
- package/client.mjs +47 -24
- package/client.mjs.map +1 -1
- package/core/middleware.d.mts +42 -5
- package/core/middleware.d.mts.map +1 -1
- package/core/middleware.d.ts +42 -5
- package/core/middleware.d.ts.map +1 -1
- package/core/middleware.js +14 -7
- package/core/middleware.js.map +1 -1
- package/core/middleware.mjs +14 -7
- package/core/middleware.mjs.map +1 -1
- package/core/streaming.d.mts +9 -0
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +9 -0
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +11 -0
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +11 -0
- package/core/streaming.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +0 -3
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +0 -3
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +46 -3
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +46 -3
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js +12 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -1
- package/internal/utils/log.d.mts +11 -1
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +11 -1
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +34 -9
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +32 -8
- package/internal/utils/log.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +5 -0
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +5 -0
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/middleware.d.mts +96 -0
- package/lib/middleware.d.mts.map +1 -0
- package/lib/middleware.d.ts +96 -0
- package/lib/middleware.d.ts.map +1 -0
- package/lib/middleware.js +703 -0
- package/lib/middleware.js.map +1 -0
- package/lib/middleware.mjs +698 -0
- package/lib/middleware.mjs.map +1 -0
- package/lib/tools/BetaToolRunner.d.mts +1 -1
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts +1 -1
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +10 -2
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +10 -2
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/agents/agents.d.mts +1 -1
- package/resources/beta/agents/agents.d.mts.map +1 -1
- package/resources/beta/agents/agents.d.ts +1 -1
- package/resources/beta/agents/agents.d.ts.map +1 -1
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/beta.d.mts +3 -3
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +3 -3
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/messages/batches.d.mts +28 -0
- package/resources/beta/messages/batches.d.mts.map +1 -1
- package/resources/beta/messages/batches.d.ts +28 -0
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +234 -6
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +234 -6
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +7 -0
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +7 -0
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/models.d.mts +6 -0
- package/resources/beta/models.d.mts.map +1 -1
- package/resources/beta/models.d.ts +6 -0
- package/resources/beta/models.d.ts.map +1 -1
- package/resources/messages/messages.d.mts +2 -2
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +2 -2
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +1 -0
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +1 -0
- package/resources/messages/messages.mjs.map +1 -1
- package/src/client.ts +55 -24
- package/src/core/middleware.ts +53 -7
- package/src/core/streaming.ts +15 -0
- package/src/index.ts +6 -0
- package/src/internal/parse.ts +0 -4
- package/src/internal/request-options.ts +48 -3
- package/src/internal/utils/log.ts +39 -9
- package/src/lib/BetaMessageStream.ts +5 -0
- package/src/lib/middleware.ts +937 -0
- package/src/lib/tools/BetaToolRunner.ts +12 -3
- package/src/resources/beta/agents/agents.ts +1 -0
- package/src/resources/beta/beta.ts +15 -1
- package/src/resources/beta/index.ts +6 -0
- package/src/resources/beta/messages/batches.ts +30 -0
- package/src/resources/beta/messages/index.ts +6 -0
- package/src/resources/beta/messages/messages.ts +279 -5
- package/src/resources/beta/models.ts +7 -0
- package/src/resources/messages/messages.ts +4 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -199,8 +199,17 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
199
199
|
const isCompacted = await this.#checkAndCompact();
|
|
200
200
|
if (!isCompacted) {
|
|
201
201
|
if (!this.#mutated) {
|
|
202
|
-
const
|
|
203
|
-
this.#state.params.messages.push({ role, content });
|
|
202
|
+
const message = await this.#message;
|
|
203
|
+
this.#state.params.messages.push({ role: message.role, content: message.content });
|
|
204
|
+
|
|
205
|
+
// Refusal-terminated turns are terminal: the refusal may have cut a tool_use off
|
|
206
|
+
// with partial input, so executing this turn's tools would fire side effects the
|
|
207
|
+
// model never confirmed — and once middleware strips the refusal turn, their
|
|
208
|
+
// tool_results could never be replayed coherently. Surface the refusal as the
|
|
209
|
+
// final message instead.
|
|
210
|
+
if (message.stop_reason === 'refusal') {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
204
213
|
}
|
|
205
214
|
|
|
206
215
|
const toolMessage = await this.#generateToolResponse(this.#state.params.messages.at(-1)!);
|
|
@@ -521,4 +530,4 @@ export type BetaToolRunnerParams = Simplify<
|
|
|
521
530
|
}
|
|
522
531
|
>;
|
|
523
532
|
|
|
524
|
-
export type BetaToolRunnerRequestOptions = Pick<RequestOptions, 'headers' | 'signal'>;
|
|
533
|
+
export type BetaToolRunnerRequestOptions = Pick<RequestOptions, 'headers' | 'signal' | 'fallbackState'>;
|
|
@@ -239,6 +239,12 @@ import {
|
|
|
239
239
|
BetaDocumentBlock,
|
|
240
240
|
BetaEncryptedCodeExecutionResultBlock,
|
|
241
241
|
BetaEncryptedCodeExecutionResultBlockParam,
|
|
242
|
+
BetaFallbackBlock,
|
|
243
|
+
BetaFallbackBlockParam,
|
|
244
|
+
BetaFallbackInfo,
|
|
245
|
+
BetaFallbackInfoParam,
|
|
246
|
+
BetaFallbackMessageIterationUsage,
|
|
247
|
+
BetaFallbackParam,
|
|
242
248
|
BetaFileDocumentSource,
|
|
243
249
|
BetaFileImageSource,
|
|
244
250
|
BetaImageBlockParam,
|
|
@@ -472,7 +478,9 @@ export type AnthropicBeta =
|
|
|
472
478
|
| 'advisor-tool-2026-03-01'
|
|
473
479
|
| 'managed-agents-2026-04-01'
|
|
474
480
|
| 'cache-diagnosis-2026-04-07'
|
|
475
|
-
| 'thinking-token-count-2026-05-13'
|
|
481
|
+
| 'thinking-token-count-2026-05-13'
|
|
482
|
+
| 'server-side-fallback-2026-06-01'
|
|
483
|
+
| 'fallback-credit-2026-06-01';
|
|
476
484
|
|
|
477
485
|
export interface BetaAPIError {
|
|
478
486
|
message: string;
|
|
@@ -673,6 +681,12 @@ export declare namespace Beta {
|
|
|
673
681
|
type BetaDocumentBlock as BetaDocumentBlock,
|
|
674
682
|
type BetaEncryptedCodeExecutionResultBlock as BetaEncryptedCodeExecutionResultBlock,
|
|
675
683
|
type BetaEncryptedCodeExecutionResultBlockParam as BetaEncryptedCodeExecutionResultBlockParam,
|
|
684
|
+
type BetaFallbackBlock as BetaFallbackBlock,
|
|
685
|
+
type BetaFallbackBlockParam as BetaFallbackBlockParam,
|
|
686
|
+
type BetaFallbackInfo as BetaFallbackInfo,
|
|
687
|
+
type BetaFallbackInfoParam as BetaFallbackInfoParam,
|
|
688
|
+
type BetaFallbackMessageIterationUsage as BetaFallbackMessageIterationUsage,
|
|
689
|
+
type BetaFallbackParam as BetaFallbackParam,
|
|
676
690
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
677
691
|
type BetaFileImageSource as BetaFileImageSource,
|
|
678
692
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
@@ -192,6 +192,12 @@ export {
|
|
|
192
192
|
type BetaDocumentBlock,
|
|
193
193
|
type BetaEncryptedCodeExecutionResultBlock,
|
|
194
194
|
type BetaEncryptedCodeExecutionResultBlockParam,
|
|
195
|
+
type BetaFallbackBlock,
|
|
196
|
+
type BetaFallbackBlockParam,
|
|
197
|
+
type BetaFallbackInfo,
|
|
198
|
+
type BetaFallbackInfoParam,
|
|
199
|
+
type BetaFallbackMessageIterationUsage,
|
|
200
|
+
type BetaFallbackParam,
|
|
195
201
|
type BetaFileDocumentSource,
|
|
196
202
|
type BetaFileImageSource,
|
|
197
203
|
type BetaImageBlockParam,
|
|
@@ -570,6 +570,36 @@ export namespace BatchCreateParams {
|
|
|
570
570
|
*/
|
|
571
571
|
diagnostics?: BetaMessagesAPI.BetaDiagnosticsParam | null;
|
|
572
572
|
|
|
573
|
+
/**
|
|
574
|
+
* The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
575
|
+
*
|
|
576
|
+
* When a preceding request was refused and returned a `fallback_credit_token`,
|
|
577
|
+
* pass that code here on the retry to have the retry's cache-creation tokens for
|
|
578
|
+
* the prefix that was warm on the refused model billed at the cache-read rate.
|
|
579
|
+
* Must be redeemed by the same organization and workspace, with the same request
|
|
580
|
+
* body (optionally extended by one appended `assistant` message whose content is
|
|
581
|
+
* the partial text — with any trailing whitespace stripped from the final text
|
|
582
|
+
* block — and paired server-tool blocks streamed before the refusal; the
|
|
583
|
+
* appended-assistant form is not available for requests with `output_format` set
|
|
584
|
+
* or forced `tool_choice`), on an eligible fallback model, on the same platform,
|
|
585
|
+
* and within 5 minutes of the refusal; a mismatch is a 400. A token minted
|
|
586
|
+
* mid-server-tool-loop whose partial content was continuable may only be redeemed
|
|
587
|
+
* with the appended-assistant form — if an exact-body retry is rejected with a 400
|
|
588
|
+
* saying the token must be redeemed by continuing the partial response, retry with
|
|
589
|
+
* the appended-assistant form instead.
|
|
590
|
+
*
|
|
591
|
+
* When the appended-assistant form is used on a model that otherwise disallows
|
|
592
|
+
* assistant-turn prefill, this token also authorizes that one prefill.
|
|
593
|
+
*/
|
|
594
|
+
fallback_credit_token?: string | null;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Opt-in server-side retry on one or more substitute models when the requested
|
|
598
|
+
* model declines for policy reasons. Tried in order: if the first entry also
|
|
599
|
+
* declines, the second is tried, and so on.
|
|
600
|
+
*/
|
|
601
|
+
fallbacks?: Array<BetaMessagesAPI.BetaFallbackParam> | null;
|
|
602
|
+
|
|
573
603
|
/**
|
|
574
604
|
* Specifies the geographic region for inference processing. If not specified, the
|
|
575
605
|
* workspace's `default_inference_geo` is used.
|
|
@@ -103,6 +103,12 @@ export {
|
|
|
103
103
|
type BetaDocumentBlock,
|
|
104
104
|
type BetaEncryptedCodeExecutionResultBlock,
|
|
105
105
|
type BetaEncryptedCodeExecutionResultBlockParam,
|
|
106
|
+
type BetaFallbackBlock,
|
|
107
|
+
type BetaFallbackBlockParam,
|
|
108
|
+
type BetaFallbackInfo,
|
|
109
|
+
type BetaFallbackInfoParam,
|
|
110
|
+
type BetaFallbackMessageIterationUsage,
|
|
111
|
+
type BetaFallbackParam,
|
|
106
112
|
type BetaFileDocumentSource,
|
|
107
113
|
type BetaFileImageSource,
|
|
108
114
|
type BetaImageBlockParam,
|
|
@@ -60,8 +60,15 @@ const DEPRECATED_MODELS: {
|
|
|
60
60
|
'claude-2.0': 'July 21st, 2025',
|
|
61
61
|
'claude-3-7-sonnet-latest': 'February 19th, 2026',
|
|
62
62
|
'claude-3-7-sonnet-20250219': 'February 19th, 2026',
|
|
63
|
+
'claude-3-5-haiku-latest': 'February 19th, 2026',
|
|
64
|
+
'claude-3-5-haiku-20241022': 'February 19th, 2026',
|
|
65
|
+
'claude-opus-4-0': 'June 15th, 2026',
|
|
66
|
+
'claude-opus-4-20250514': 'June 15th, 2026',
|
|
67
|
+
'claude-sonnet-4-0': 'June 15th, 2026',
|
|
68
|
+
'claude-sonnet-4-20250514': 'June 15th, 2026',
|
|
63
69
|
'claude-opus-4-1': 'August 5th, 2026',
|
|
64
70
|
'claude-opus-4-1-20250805': 'August 5th, 2026',
|
|
71
|
+
'claude-mythos-preview': 'June 30th, 2026',
|
|
65
72
|
};
|
|
66
73
|
|
|
67
74
|
const MODELS_TO_WARN_WITH_THINKING_ENABLED: Model[] = ['claude-mythos-preview', 'claude-opus-4-6'];
|
|
@@ -1356,7 +1363,8 @@ export type BetaContentBlock =
|
|
|
1356
1363
|
| BetaMCPToolUseBlock
|
|
1357
1364
|
| BetaMCPToolResultBlock
|
|
1358
1365
|
| BetaContainerUploadBlock
|
|
1359
|
-
| BetaCompactionBlock
|
|
1366
|
+
| BetaCompactionBlock
|
|
1367
|
+
| BetaFallbackBlock;
|
|
1360
1368
|
|
|
1361
1369
|
/**
|
|
1362
1370
|
* Regular text content.
|
|
@@ -1382,7 +1390,8 @@ export type BetaContentBlockParam =
|
|
|
1382
1390
|
| BetaRequestMCPToolResultBlockParam
|
|
1383
1391
|
| BetaContainerUploadBlockParam
|
|
1384
1392
|
| BetaCompactionBlockParam
|
|
1385
|
-
| BetaMidConversationSystemBlockParam
|
|
1393
|
+
| BetaMidConversationSystemBlockParam
|
|
1394
|
+
| BetaFallbackBlockParam;
|
|
1386
1395
|
|
|
1387
1396
|
export interface BetaContentBlockSource {
|
|
1388
1397
|
content: string | Array<BetaContentBlockSourceContent>;
|
|
@@ -1502,6 +1511,170 @@ export interface BetaEncryptedCodeExecutionResultBlockParam {
|
|
|
1502
1511
|
type: 'encrypted_code_execution_result';
|
|
1503
1512
|
}
|
|
1504
1513
|
|
|
1514
|
+
/**
|
|
1515
|
+
* Marks the point in `content` where one model's output gives way to the next.
|
|
1516
|
+
*
|
|
1517
|
+
* One block appears per hop where a preceding model actually ran this turn and
|
|
1518
|
+
* declined. A turn routed directly by the sticky decision has no such boundary and
|
|
1519
|
+
* carries no block — the signal for whether a fallback model served the response
|
|
1520
|
+
* is the presence of a `fallback_message` entry in `usage.iterations`, not this
|
|
1521
|
+
* block.
|
|
1522
|
+
*
|
|
1523
|
+
* The block is treated like a server-tool content block for streaming: it arrives
|
|
1524
|
+
* via the standard `content_block_start` / `content_block_stop` pair and carries
|
|
1525
|
+
* no deltas.
|
|
1526
|
+
*/
|
|
1527
|
+
export interface BetaFallbackBlock {
|
|
1528
|
+
/**
|
|
1529
|
+
* The model whose output ends at this point — the model that declined at this hop.
|
|
1530
|
+
* When the declining hop is the requested model, its `model` echoes the top-level
|
|
1531
|
+
* `model` string the caller sent (alias or canonical); when the declining hop is a
|
|
1532
|
+
* fallback model, its `model` is that model's canonical id.
|
|
1533
|
+
*/
|
|
1534
|
+
from: BetaFallbackInfo;
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* The fallback model producing the content that follows this block. Its `model` is
|
|
1538
|
+
* always the canonical id.
|
|
1539
|
+
*/
|
|
1540
|
+
to: BetaFallbackInfo;
|
|
1541
|
+
|
|
1542
|
+
type: 'fallback';
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* A `fallback` block echoed back from a prior response.
|
|
1547
|
+
*
|
|
1548
|
+
* Accepted in `messages[].content` and never rendered into the prompt, not
|
|
1549
|
+
* validated against the request's `fallbacks` chain or top-level `model`, and
|
|
1550
|
+
* stripped before the sticky-routing cache key is computed.
|
|
1551
|
+
*
|
|
1552
|
+
* Callers should echo the assistant turn verbatim — block included. The block's
|
|
1553
|
+
* position is load-bearing for thinking verification: the thinking runs on either
|
|
1554
|
+
* side of a fallback hop carry independently-rooted verification hash chains, and
|
|
1555
|
+
* this block is the only record of where one chain ends and the next begins. When
|
|
1556
|
+
* thinking runs flank the boundary, omitting the block merges the runs into one
|
|
1557
|
+
* contiguous span whose hashes cannot verify (the request is rejected), and moving
|
|
1558
|
+
* it into the middle of a single run splits that run's chain and is likewise
|
|
1559
|
+
* rejected; between non-thinking blocks the block's placement has no verification
|
|
1560
|
+
* effect.
|
|
1561
|
+
*/
|
|
1562
|
+
export interface BetaFallbackBlockParam {
|
|
1563
|
+
/**
|
|
1564
|
+
* Identifies one hop of a fallback transition.
|
|
1565
|
+
*/
|
|
1566
|
+
from: BetaFallbackInfoParam;
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Identifies one hop of a fallback transition.
|
|
1570
|
+
*/
|
|
1571
|
+
to: BetaFallbackInfoParam;
|
|
1572
|
+
|
|
1573
|
+
type: 'fallback';
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
/**
|
|
1577
|
+
* Identifies one hop of a fallback transition.
|
|
1578
|
+
*/
|
|
1579
|
+
export interface BetaFallbackInfo {
|
|
1580
|
+
/**
|
|
1581
|
+
* The model that will complete your prompt.
|
|
1582
|
+
*
|
|
1583
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
1584
|
+
* details and options.
|
|
1585
|
+
*/
|
|
1586
|
+
model: MessagesAPI.Model;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
/**
|
|
1590
|
+
* Identifies one hop of a fallback transition.
|
|
1591
|
+
*/
|
|
1592
|
+
export interface BetaFallbackInfoParam {
|
|
1593
|
+
/**
|
|
1594
|
+
* The model that will complete your prompt.
|
|
1595
|
+
*
|
|
1596
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
1597
|
+
* details and options.
|
|
1598
|
+
*/
|
|
1599
|
+
model: MessagesAPI.Model;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* Token usage for the fallback-model attempt of a server-side fallback request.
|
|
1604
|
+
*
|
|
1605
|
+
* Produced in place of a `message` entry for whichever hop served the response. A
|
|
1606
|
+
* declined hop produces the existing `message` entry. Whether a fallback model
|
|
1607
|
+
* served the response is signalled by the presence of this entry in
|
|
1608
|
+
* `usage.iterations`.
|
|
1609
|
+
*/
|
|
1610
|
+
export interface BetaFallbackMessageIterationUsage {
|
|
1611
|
+
/**
|
|
1612
|
+
* Breakdown of cached tokens by TTL
|
|
1613
|
+
*/
|
|
1614
|
+
cache_creation: BetaCacheCreation | null;
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* The number of input tokens used to create the cache entry.
|
|
1618
|
+
*/
|
|
1619
|
+
cache_creation_input_tokens: number;
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* The number of input tokens read from the cache.
|
|
1623
|
+
*/
|
|
1624
|
+
cache_read_input_tokens: number;
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* The number of input tokens which were used.
|
|
1628
|
+
*/
|
|
1629
|
+
input_tokens: number;
|
|
1630
|
+
|
|
1631
|
+
/**
|
|
1632
|
+
* The model that will complete your prompt.
|
|
1633
|
+
*
|
|
1634
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
1635
|
+
* details and options.
|
|
1636
|
+
*/
|
|
1637
|
+
model: MessagesAPI.Model;
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* The number of output tokens which were used.
|
|
1641
|
+
*/
|
|
1642
|
+
output_tokens: number;
|
|
1643
|
+
|
|
1644
|
+
/**
|
|
1645
|
+
* Usage for the fallback-model attempt that served the response
|
|
1646
|
+
*/
|
|
1647
|
+
type: 'fallback_message';
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* One entry in the `fallbacks` chain on a `/v1/messages` request.
|
|
1652
|
+
*
|
|
1653
|
+
* `model` is required. The four override fields (`max_tokens`, `thinking`,
|
|
1654
|
+
* `output_config`, and `speed`) replace the corresponding top-level field for this
|
|
1655
|
+
* attempt only and are validated as if the request were made to `model`. Any other
|
|
1656
|
+
* key is rejected at parse time.
|
|
1657
|
+
*/
|
|
1658
|
+
export interface BetaFallbackParam {
|
|
1659
|
+
/**
|
|
1660
|
+
* The model that will complete your prompt.
|
|
1661
|
+
*
|
|
1662
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
1663
|
+
* details and options.
|
|
1664
|
+
*/
|
|
1665
|
+
model: MessagesAPI.Model;
|
|
1666
|
+
|
|
1667
|
+
max_tokens?: number | null;
|
|
1668
|
+
|
|
1669
|
+
output_config?: BetaOutputConfig | null;
|
|
1670
|
+
|
|
1671
|
+
speed?: 'standard' | 'fast' | null;
|
|
1672
|
+
|
|
1673
|
+
thinking?: BetaThinkingConfigEnabled | BetaThinkingConfigDisabled | BetaThinkingConfigAdaptive | null;
|
|
1674
|
+
|
|
1675
|
+
[k: string]: unknown;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1505
1678
|
export interface BetaFileDocumentSource {
|
|
1506
1679
|
file_id: string;
|
|
1507
1680
|
|
|
@@ -1554,7 +1727,10 @@ export interface BetaInputTokensTrigger {
|
|
|
1554
1727
|
* - Understand token accumulation across server-side tool use loops
|
|
1555
1728
|
*/
|
|
1556
1729
|
export type BetaIterationsUsage = Array<
|
|
1557
|
-
|
|
1730
|
+
| BetaMessageIterationUsage
|
|
1731
|
+
| BetaCompactionIterationUsage
|
|
1732
|
+
| BetaAdvisorMessageIterationUsage
|
|
1733
|
+
| BetaFallbackMessageIterationUsage
|
|
1558
1734
|
>;
|
|
1559
1735
|
|
|
1560
1736
|
export interface BetaJSONOutputFormat {
|
|
@@ -2018,6 +2194,14 @@ export interface BetaMessageIterationUsage {
|
|
|
2018
2194
|
*/
|
|
2019
2195
|
input_tokens: number;
|
|
2020
2196
|
|
|
2197
|
+
/**
|
|
2198
|
+
* The model that will complete your prompt.
|
|
2199
|
+
*
|
|
2200
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
2201
|
+
* details and options.
|
|
2202
|
+
*/
|
|
2203
|
+
model: MessagesAPI.Model;
|
|
2204
|
+
|
|
2021
2205
|
/**
|
|
2022
2206
|
* The number of output tokens which were used.
|
|
2023
2207
|
*/
|
|
@@ -2156,7 +2340,8 @@ export interface BetaRawContentBlockStartEvent {
|
|
|
2156
2340
|
| BetaMCPToolUseBlock
|
|
2157
2341
|
| BetaMCPToolResultBlock
|
|
2158
2342
|
| BetaContainerUploadBlock
|
|
2159
|
-
| BetaCompactionBlock
|
|
2343
|
+
| BetaCompactionBlock
|
|
2344
|
+
| BetaFallbackBlock;
|
|
2160
2345
|
|
|
2161
2346
|
index: number;
|
|
2162
2347
|
|
|
@@ -2257,7 +2442,7 @@ export interface BetaRefusalStopDetails {
|
|
|
2257
2442
|
*
|
|
2258
2443
|
* `null` when the refusal doesn't map to a named category.
|
|
2259
2444
|
*/
|
|
2260
|
-
category: 'cyber' | 'bio' | null;
|
|
2445
|
+
category: 'cyber' | 'bio' | 'reasoning_extraction' | null;
|
|
2261
2446
|
|
|
2262
2447
|
/**
|
|
2263
2448
|
* Human-readable explanation of the refusal.
|
|
@@ -2267,6 +2452,59 @@ export interface BetaRefusalStopDetails {
|
|
|
2267
2452
|
*/
|
|
2268
2453
|
explanation: string | null;
|
|
2269
2454
|
|
|
2455
|
+
/**
|
|
2456
|
+
* Opaque code that refunds the cache-miss cost when retrying this refused request
|
|
2457
|
+
* on the fallback model. Pass it as `fallback_credit_token` on the retry request.
|
|
2458
|
+
* Expires 5 minutes after the refusal.
|
|
2459
|
+
*
|
|
2460
|
+
* The retry is sent either with the same request body (`system`, `messages`,
|
|
2461
|
+
* `tools`, and other render-shaping fields), or with the same body plus one
|
|
2462
|
+
* appended `assistant` message whose content is the partial text (with any
|
|
2463
|
+
* trailing whitespace stripped from the final text block) and paired server-tool
|
|
2464
|
+
* blocks from this refusal — which also authorizes that appended turn as an
|
|
2465
|
+
* assistant-prefill continuation on models that otherwise disallow prefill. A
|
|
2466
|
+
* token minted mid-server-tool-loop whose partial content was continuable may only
|
|
2467
|
+
* be redeemed the second way — if a same-body retry is rejected with a 400 saying
|
|
2468
|
+
* the token must be redeemed by continuing the partial response, retry the second
|
|
2469
|
+
* way instead. Either way: same workspace, same platform; a mismatch is a 400.
|
|
2470
|
+
* Resending a token for an already-warm prefix is permitted but yields no
|
|
2471
|
+
* additional credit.
|
|
2472
|
+
*
|
|
2473
|
+
* `null` when the refused model isn't eligible for a fallback credit.
|
|
2474
|
+
*/
|
|
2475
|
+
fallback_credit_token: string | null;
|
|
2476
|
+
|
|
2477
|
+
/**
|
|
2478
|
+
* Whether the accompanying `fallback_credit_token` may be redeemed with the
|
|
2479
|
+
* appended-assistant retry form. Only set when `fallback_credit_token` is present.
|
|
2480
|
+
*
|
|
2481
|
+
* `true`: retry by resending the same request body plus one appended `assistant`
|
|
2482
|
+
* message whose content is this response's `content` with any trailing whitespace
|
|
2483
|
+
* stripped from the final text block and unpaired `tool_use` blocks omitted (the
|
|
2484
|
+
* same appended-turn shape described on `fallback_credit_token`), with the token
|
|
2485
|
+
* attached. `false`: retry by resending the original request body unchanged, with
|
|
2486
|
+
* the token attached — the appended-assistant form is not available for this
|
|
2487
|
+
* refusal (no continuable partial content, or the request uses `output_format` or
|
|
2488
|
+
* a `tool_choice` that forces tool use). One exception: when the request used
|
|
2489
|
+
* `output_format` or a forced `tool_choice` and the refusal arrived after server
|
|
2490
|
+
* tools (including MCP connector tools) had already executed, the token may not be
|
|
2491
|
+
* redeemable by either retry form; if the exact-body retry is then rejected with a
|
|
2492
|
+
* 400 saying the token must be redeemed by continuing the partial response,
|
|
2493
|
+
* discard the token and retry without it.
|
|
2494
|
+
*
|
|
2495
|
+
* Advisory: if an appended-assistant retry is rejected with a 400 despite `true`,
|
|
2496
|
+
* fall back to resending the original request body with the token.
|
|
2497
|
+
*/
|
|
2498
|
+
fallback_has_prefill_claim: boolean | null;
|
|
2499
|
+
|
|
2500
|
+
/**
|
|
2501
|
+
* The server's suggested retry target for this refusal. Populated when a fallback
|
|
2502
|
+
* attempt could not be made (the fallback model's rate limit was exhausted, or it
|
|
2503
|
+
* was overloaded); names the fallback model the caller can retry directly. Null
|
|
2504
|
+
* otherwise.
|
|
2505
|
+
*/
|
|
2506
|
+
recommended_model: string | null;
|
|
2507
|
+
|
|
2270
2508
|
type: 'refusal';
|
|
2271
2509
|
}
|
|
2272
2510
|
|
|
@@ -4150,6 +4388,36 @@ export interface MessageCreateParamsBase {
|
|
|
4150
4388
|
*/
|
|
4151
4389
|
diagnostics?: BetaDiagnosticsParam | null;
|
|
4152
4390
|
|
|
4391
|
+
/**
|
|
4392
|
+
* Body param: The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
4393
|
+
*
|
|
4394
|
+
* When a preceding request was refused and returned a `fallback_credit_token`,
|
|
4395
|
+
* pass that code here on the retry to have the retry's cache-creation tokens for
|
|
4396
|
+
* the prefix that was warm on the refused model billed at the cache-read rate.
|
|
4397
|
+
* Must be redeemed by the same organization and workspace, with the same request
|
|
4398
|
+
* body (optionally extended by one appended `assistant` message whose content is
|
|
4399
|
+
* the partial text — with any trailing whitespace stripped from the final text
|
|
4400
|
+
* block — and paired server-tool blocks streamed before the refusal; the
|
|
4401
|
+
* appended-assistant form is not available for requests with `output_format` set
|
|
4402
|
+
* or forced `tool_choice`), on an eligible fallback model, on the same platform,
|
|
4403
|
+
* and within 5 minutes of the refusal; a mismatch is a 400. A token minted
|
|
4404
|
+
* mid-server-tool-loop whose partial content was continuable may only be redeemed
|
|
4405
|
+
* with the appended-assistant form — if an exact-body retry is rejected with a 400
|
|
4406
|
+
* saying the token must be redeemed by continuing the partial response, retry with
|
|
4407
|
+
* the appended-assistant form instead.
|
|
4408
|
+
*
|
|
4409
|
+
* When the appended-assistant form is used on a model that otherwise disallows
|
|
4410
|
+
* assistant-turn prefill, this token also authorizes that one prefill.
|
|
4411
|
+
*/
|
|
4412
|
+
fallback_credit_token?: string | null;
|
|
4413
|
+
|
|
4414
|
+
/**
|
|
4415
|
+
* Body param: Opt-in server-side retry on one or more substitute models when the
|
|
4416
|
+
* requested model declines for policy reasons. Tried in order: if the first entry
|
|
4417
|
+
* also declines, the second is tried, and so on.
|
|
4418
|
+
*/
|
|
4419
|
+
fallbacks?: Array<BetaFallbackParam> | null;
|
|
4420
|
+
|
|
4153
4421
|
/**
|
|
4154
4422
|
* Body param: Specifies the geographic region for inference processing. If not
|
|
4155
4423
|
* specified, the workspace's `default_inference_geo` is used.
|
|
@@ -4728,6 +4996,12 @@ export declare namespace Messages {
|
|
|
4728
4996
|
type BetaDocumentBlock as BetaDocumentBlock,
|
|
4729
4997
|
type BetaEncryptedCodeExecutionResultBlock as BetaEncryptedCodeExecutionResultBlock,
|
|
4730
4998
|
type BetaEncryptedCodeExecutionResultBlockParam as BetaEncryptedCodeExecutionResultBlockParam,
|
|
4999
|
+
type BetaFallbackBlock as BetaFallbackBlock,
|
|
5000
|
+
type BetaFallbackBlockParam as BetaFallbackBlockParam,
|
|
5001
|
+
type BetaFallbackInfo as BetaFallbackInfo,
|
|
5002
|
+
type BetaFallbackInfoParam as BetaFallbackInfoParam,
|
|
5003
|
+
type BetaFallbackMessageIterationUsage as BetaFallbackMessageIterationUsage,
|
|
5004
|
+
type BetaFallbackParam as BetaFallbackParam,
|
|
4731
5005
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
4732
5006
|
type BetaFileImageSource as BetaFileImageSource,
|
|
4733
5007
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
@@ -195,6 +195,13 @@ export interface BetaModelInfo {
|
|
|
195
195
|
*/
|
|
196
196
|
id: string;
|
|
197
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Model IDs this model accepts as `fallbacks[i].model` on the Messages API. An
|
|
200
|
+
* empty list means the `fallbacks` parameter is not supported for this model as
|
|
201
|
+
* primary.
|
|
202
|
+
*/
|
|
203
|
+
allowed_fallback_models: Array<string> | null;
|
|
204
|
+
|
|
198
205
|
/**
|
|
199
206
|
* Model capability information.
|
|
200
207
|
*/
|
|
@@ -1197,6 +1197,8 @@ export interface MidConversationSystemBlockParam {
|
|
|
1197
1197
|
* details and options.
|
|
1198
1198
|
*/
|
|
1199
1199
|
export type Model =
|
|
1200
|
+
| 'claude-fable-5'
|
|
1201
|
+
| 'claude-mythos-5'
|
|
1200
1202
|
| 'claude-opus-4-8'
|
|
1201
1203
|
| 'claude-opus-4-7'
|
|
1202
1204
|
| 'claude-mythos-preview'
|
|
@@ -1265,6 +1267,7 @@ const DEPRECATED_MODELS: {
|
|
|
1265
1267
|
'claude-sonnet-4-20250514': 'June 15th, 2026',
|
|
1266
1268
|
'claude-opus-4-1': 'August 5th, 2026',
|
|
1267
1269
|
'claude-opus-4-1-20250805': 'August 5th, 2026',
|
|
1270
|
+
'claude-mythos-preview': 'June 30th, 2026',
|
|
1268
1271
|
};
|
|
1269
1272
|
|
|
1270
1273
|
const MODELS_TO_WARN_WITH_THINKING_ENABLED: Model[] = ['claude-mythos-preview', 'claude-opus-4-6'];
|
|
@@ -1404,7 +1407,7 @@ export interface RefusalStopDetails {
|
|
|
1404
1407
|
*
|
|
1405
1408
|
* `null` when the refusal doesn't map to a named category.
|
|
1406
1409
|
*/
|
|
1407
|
-
category: 'cyber' | 'bio' | null;
|
|
1410
|
+
category: 'cyber' | 'bio' | 'reasoning_extraction' | null;
|
|
1408
1411
|
|
|
1409
1412
|
/**
|
|
1410
1413
|
* Human-readable explanation of the refusal.
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.103.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.103.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.103.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.103.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|