@anthropic-ai/sdk 0.36.3 → 0.37.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 +26 -0
- package/README.md +30 -3
- package/core.d.ts +1 -0
- package/core.d.ts.map +1 -1
- package/core.js +33 -6
- package/core.js.map +1 -1
- package/core.mjs +33 -6
- package/core.mjs.map +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/internal/decoders/line.d.ts +3 -2
- package/internal/decoders/line.d.ts.map +1 -1
- package/internal/decoders/line.js +97 -35
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +95 -34
- package/internal/decoders/line.mjs.map +1 -1
- package/lib/BetaMessageStream.d.ts +2 -0
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +24 -0
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +24 -0
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.ts +2 -0
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +24 -0
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +24 -0
- package/lib/MessageStream.mjs.map +1 -1
- package/package.json +29 -8
- package/pagination.d.ts +1 -0
- package/pagination.d.ts.map +1 -1
- package/pagination.js +6 -0
- package/pagination.js.map +1 -1
- package/pagination.mjs +6 -0
- package/pagination.mjs.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.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.ts +18 -0
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/batches.js +3 -0
- package/resources/beta/messages/batches.js.map +1 -1
- package/resources/beta/messages/batches.mjs +3 -0
- package/resources/beta/messages/batches.mjs.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.ts +148 -13
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +5 -1
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +5 -1
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/batches.d.ts +18 -0
- package/resources/messages/batches.d.ts.map +1 -1
- package/resources/messages/batches.js +15 -0
- package/resources/messages/batches.js.map +1 -1
- package/resources/messages/batches.mjs +15 -0
- package/resources/messages/batches.mjs.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.ts +129 -14
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +5 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +5 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/src/core.ts +39 -6
- package/src/index.ts +26 -0
- package/src/internal/decoders/line.ts +100 -38
- package/src/lib/BetaMessageStream.ts +26 -0
- package/src/lib/MessageStream.ts +26 -0
- package/src/pagination.ts +8 -0
- package/src/resources/beta/beta.ts +28 -1
- package/src/resources/beta/index.ts +12 -0
- package/src/resources/beta/messages/batches.ts +18 -0
- package/src/resources/beta/messages/index.ts +12 -0
- package/src/resources/beta/messages/messages.ts +212 -14
- package/src/resources/index.ts +13 -0
- package/src/resources/messages/batches.ts +18 -0
- package/src/resources/messages/index.ts +13 -0
- package/src/resources/messages/messages.ts +177 -15
- package/src/streaming.ts +1 -43
- package/src/version.ts +1 -1
- package/streaming.d.ts +0 -2
- package/streaming.d.ts.map +1 -1
- package/streaming.js +2 -38
- package/streaming.js.map +1 -1
- package/streaming.mjs +1 -36
- package/streaming.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -48,20 +48,32 @@ export {
|
|
|
48
48
|
type BetaRawMessageStartEvent,
|
|
49
49
|
type BetaRawMessageStopEvent,
|
|
50
50
|
type BetaRawMessageStreamEvent,
|
|
51
|
+
type BetaRedactedThinkingBlock,
|
|
52
|
+
type BetaRedactedThinkingBlockParam,
|
|
53
|
+
type BetaSignatureDelta,
|
|
51
54
|
type BetaTextBlock,
|
|
52
55
|
type BetaTextBlockParam,
|
|
53
56
|
type BetaTextCitation,
|
|
54
57
|
type BetaTextCitationParam,
|
|
55
58
|
type BetaTextDelta,
|
|
59
|
+
type BetaThinkingBlock,
|
|
60
|
+
type BetaThinkingBlockParam,
|
|
61
|
+
type BetaThinkingConfigDisabled,
|
|
62
|
+
type BetaThinkingConfigEnabled,
|
|
63
|
+
type BetaThinkingConfigParam,
|
|
64
|
+
type BetaThinkingDelta,
|
|
56
65
|
type BetaTool,
|
|
57
66
|
type BetaToolBash20241022,
|
|
67
|
+
type BetaToolBash20250124,
|
|
58
68
|
type BetaToolChoice,
|
|
59
69
|
type BetaToolChoiceAny,
|
|
60
70
|
type BetaToolChoiceAuto,
|
|
61
71
|
type BetaToolChoiceTool,
|
|
62
72
|
type BetaToolComputerUse20241022,
|
|
73
|
+
type BetaToolComputerUse20250124,
|
|
63
74
|
type BetaToolResultBlockParam,
|
|
64
75
|
type BetaToolTextEditor20241022,
|
|
76
|
+
type BetaToolTextEditor20250124,
|
|
65
77
|
type BetaToolUnion,
|
|
66
78
|
type BetaToolUseBlock,
|
|
67
79
|
type BetaToolUseBlockParam,
|
|
@@ -16,6 +16,9 @@ export class Batches extends APIResource {
|
|
|
16
16
|
* The Message Batches API can be used to process multiple Messages API requests at
|
|
17
17
|
* once. Once a Message Batch is created, it begins processing immediately. Batches
|
|
18
18
|
* can take up to 24 hours to complete.
|
|
19
|
+
*
|
|
20
|
+
* Learn more about the Message Batches API in our
|
|
21
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
19
22
|
*/
|
|
20
23
|
create(params: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<BetaMessageBatch> {
|
|
21
24
|
const { betas, ...body } = params;
|
|
@@ -33,6 +36,9 @@ export class Batches extends APIResource {
|
|
|
33
36
|
* This endpoint is idempotent and can be used to poll for Message Batch
|
|
34
37
|
* completion. To access the results of a Message Batch, make a request to the
|
|
35
38
|
* `results_url` field in the response.
|
|
39
|
+
*
|
|
40
|
+
* Learn more about the Message Batches API in our
|
|
41
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
36
42
|
*/
|
|
37
43
|
retrieve(
|
|
38
44
|
messageBatchId: string,
|
|
@@ -61,6 +67,9 @@ export class Batches extends APIResource {
|
|
|
61
67
|
/**
|
|
62
68
|
* List all Message Batches within a Workspace. Most recently created batches are
|
|
63
69
|
* returned first.
|
|
70
|
+
*
|
|
71
|
+
* Learn more about the Message Batches API in our
|
|
72
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
64
73
|
*/
|
|
65
74
|
list(
|
|
66
75
|
params?: BatchListParams,
|
|
@@ -90,6 +99,9 @@ export class Batches extends APIResource {
|
|
|
90
99
|
*
|
|
91
100
|
* Message Batches can only be deleted once they've finished processing. If you'd
|
|
92
101
|
* like to delete an in-progress batch, you must first cancel it.
|
|
102
|
+
*
|
|
103
|
+
* Learn more about the Message Batches API in our
|
|
104
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
93
105
|
*/
|
|
94
106
|
delete(
|
|
95
107
|
messageBatchId: string,
|
|
@@ -125,6 +137,9 @@ export class Batches extends APIResource {
|
|
|
125
137
|
* which requests were canceled, check the individual results within the batch.
|
|
126
138
|
* Note that cancellation may not result in any canceled requests if they were
|
|
127
139
|
* non-interruptible.
|
|
140
|
+
*
|
|
141
|
+
* Learn more about the Message Batches API in our
|
|
142
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
128
143
|
*/
|
|
129
144
|
cancel(
|
|
130
145
|
messageBatchId: string,
|
|
@@ -156,6 +171,9 @@ export class Batches extends APIResource {
|
|
|
156
171
|
* Each line in the file is a JSON object containing the result of a single request
|
|
157
172
|
* in the Message Batch. Results are not guaranteed to be in the same order as
|
|
158
173
|
* requests. Use the `custom_id` field to match results to requests.
|
|
174
|
+
*
|
|
175
|
+
* Learn more about the Message Batches API in our
|
|
176
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
159
177
|
*/
|
|
160
178
|
async results(
|
|
161
179
|
messageBatchId: string,
|
|
@@ -51,20 +51,32 @@ export {
|
|
|
51
51
|
type BetaRawMessageStartEvent,
|
|
52
52
|
type BetaRawMessageStopEvent,
|
|
53
53
|
type BetaRawMessageStreamEvent,
|
|
54
|
+
type BetaRedactedThinkingBlock,
|
|
55
|
+
type BetaRedactedThinkingBlockParam,
|
|
56
|
+
type BetaSignatureDelta,
|
|
54
57
|
type BetaTextBlock,
|
|
55
58
|
type BetaTextBlockParam,
|
|
56
59
|
type BetaTextCitation,
|
|
57
60
|
type BetaTextCitationParam,
|
|
58
61
|
type BetaTextDelta,
|
|
62
|
+
type BetaThinkingBlock,
|
|
63
|
+
type BetaThinkingBlockParam,
|
|
64
|
+
type BetaThinkingConfigDisabled,
|
|
65
|
+
type BetaThinkingConfigEnabled,
|
|
66
|
+
type BetaThinkingConfigParam,
|
|
67
|
+
type BetaThinkingDelta,
|
|
59
68
|
type BetaTool,
|
|
60
69
|
type BetaToolBash20241022,
|
|
70
|
+
type BetaToolBash20250124,
|
|
61
71
|
type BetaToolChoice,
|
|
62
72
|
type BetaToolChoiceAny,
|
|
63
73
|
type BetaToolChoiceAuto,
|
|
64
74
|
type BetaToolChoiceTool,
|
|
65
75
|
type BetaToolComputerUse20241022,
|
|
76
|
+
type BetaToolComputerUse20250124,
|
|
66
77
|
type BetaToolResultBlockParam,
|
|
67
78
|
type BetaToolTextEditor20241022,
|
|
79
|
+
type BetaToolTextEditor20250124,
|
|
68
80
|
type BetaToolUnion,
|
|
69
81
|
type BetaToolUseBlock,
|
|
70
82
|
type BetaToolUseBlockParam,
|
|
@@ -52,6 +52,8 @@ export class Messages extends APIResource {
|
|
|
52
52
|
*
|
|
53
53
|
* The Messages API can be used for either single queries or stateless multi-turn
|
|
54
54
|
* conversations.
|
|
55
|
+
*
|
|
56
|
+
* Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
|
|
55
57
|
*/
|
|
56
58
|
create(params: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<BetaMessage>;
|
|
57
59
|
create(
|
|
@@ -78,7 +80,9 @@ export class Messages extends APIResource {
|
|
|
78
80
|
|
|
79
81
|
return this._client.post('/v1/messages?beta=true', {
|
|
80
82
|
body,
|
|
81
|
-
timeout:
|
|
83
|
+
timeout:
|
|
84
|
+
(this._client as any)._options.timeout ??
|
|
85
|
+
(body.stream ? 600000 : this._client._calculateNonstreamingTimeout(body.max_tokens)),
|
|
82
86
|
...options,
|
|
83
87
|
headers: {
|
|
84
88
|
...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
|
|
@@ -100,6 +104,9 @@ export class Messages extends APIResource {
|
|
|
100
104
|
*
|
|
101
105
|
* The Token Count API can be used to count the number of tokens in a Message,
|
|
102
106
|
* including tools, images, and documents, without creating it.
|
|
107
|
+
*
|
|
108
|
+
* Learn more about token counting in our
|
|
109
|
+
* [user guide](/en/docs/build-with-claude/token-counting)
|
|
103
110
|
*/
|
|
104
111
|
countTokens(
|
|
105
112
|
params: MessageCountTokensParams,
|
|
@@ -239,14 +246,20 @@ export interface BetaCitationsDelta {
|
|
|
239
246
|
type: 'citations_delta';
|
|
240
247
|
}
|
|
241
248
|
|
|
242
|
-
export type BetaContentBlock =
|
|
249
|
+
export type BetaContentBlock =
|
|
250
|
+
| BetaTextBlock
|
|
251
|
+
| BetaToolUseBlock
|
|
252
|
+
| BetaThinkingBlock
|
|
253
|
+
| BetaRedactedThinkingBlock;
|
|
243
254
|
|
|
244
255
|
export type BetaContentBlockParam =
|
|
245
256
|
| BetaTextBlockParam
|
|
246
257
|
| BetaImageBlockParam
|
|
247
258
|
| BetaToolUseBlockParam
|
|
248
259
|
| BetaToolResultBlockParam
|
|
249
|
-
| BetaBase64PDFBlock
|
|
260
|
+
| BetaBase64PDFBlock
|
|
261
|
+
| BetaThinkingBlockParam
|
|
262
|
+
| BetaRedactedThinkingBlockParam;
|
|
250
263
|
|
|
251
264
|
export interface BetaContentBlockSource {
|
|
252
265
|
content: string | Array<BetaContentBlockSourceContent>;
|
|
@@ -381,6 +394,9 @@ export interface BetaMessage {
|
|
|
381
394
|
*
|
|
382
395
|
* For example, `output_tokens` will be non-zero, even for an empty string response
|
|
383
396
|
* from Claude.
|
|
397
|
+
*
|
|
398
|
+
* Total input tokens in a request is the summation of `input_tokens`,
|
|
399
|
+
* `cache_creation_input_tokens`, and `cache_read_input_tokens`.
|
|
384
400
|
*/
|
|
385
401
|
usage: BetaUsage;
|
|
386
402
|
}
|
|
@@ -426,7 +442,7 @@ export interface BetaPlainTextSource {
|
|
|
426
442
|
}
|
|
427
443
|
|
|
428
444
|
export interface BetaRawContentBlockDeltaEvent {
|
|
429
|
-
delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta;
|
|
445
|
+
delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta | BetaThinkingDelta | BetaSignatureDelta;
|
|
430
446
|
|
|
431
447
|
index: number;
|
|
432
448
|
|
|
@@ -434,7 +450,7 @@ export interface BetaRawContentBlockDeltaEvent {
|
|
|
434
450
|
}
|
|
435
451
|
|
|
436
452
|
export interface BetaRawContentBlockStartEvent {
|
|
437
|
-
content_block: BetaTextBlock | BetaToolUseBlock;
|
|
453
|
+
content_block: BetaTextBlock | BetaToolUseBlock | BetaThinkingBlock | BetaRedactedThinkingBlock;
|
|
438
454
|
|
|
439
455
|
index: number;
|
|
440
456
|
|
|
@@ -465,6 +481,9 @@ export interface BetaRawMessageDeltaEvent {
|
|
|
465
481
|
*
|
|
466
482
|
* For example, `output_tokens` will be non-zero, even for an empty string response
|
|
467
483
|
* from Claude.
|
|
484
|
+
*
|
|
485
|
+
* Total input tokens in a request is the summation of `input_tokens`,
|
|
486
|
+
* `cache_creation_input_tokens`, and `cache_read_input_tokens`.
|
|
468
487
|
*/
|
|
469
488
|
usage: BetaMessageDeltaUsage;
|
|
470
489
|
}
|
|
@@ -495,6 +514,24 @@ export type BetaRawMessageStreamEvent =
|
|
|
495
514
|
| BetaRawContentBlockDeltaEvent
|
|
496
515
|
| BetaRawContentBlockStopEvent;
|
|
497
516
|
|
|
517
|
+
export interface BetaRedactedThinkingBlock {
|
|
518
|
+
data: string;
|
|
519
|
+
|
|
520
|
+
type: 'redacted_thinking';
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export interface BetaRedactedThinkingBlockParam {
|
|
524
|
+
data: string;
|
|
525
|
+
|
|
526
|
+
type: 'redacted_thinking';
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export interface BetaSignatureDelta {
|
|
530
|
+
signature: string;
|
|
531
|
+
|
|
532
|
+
type: 'signature_delta';
|
|
533
|
+
}
|
|
534
|
+
|
|
498
535
|
export interface BetaTextBlock {
|
|
499
536
|
/**
|
|
500
537
|
* Citations supporting the text block.
|
|
@@ -536,9 +573,65 @@ export interface BetaTextDelta {
|
|
|
536
573
|
type: 'text_delta';
|
|
537
574
|
}
|
|
538
575
|
|
|
576
|
+
export interface BetaThinkingBlock {
|
|
577
|
+
signature: string;
|
|
578
|
+
|
|
579
|
+
thinking: string;
|
|
580
|
+
|
|
581
|
+
type: 'thinking';
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export interface BetaThinkingBlockParam {
|
|
585
|
+
signature: string;
|
|
586
|
+
|
|
587
|
+
thinking: string;
|
|
588
|
+
|
|
589
|
+
type: 'thinking';
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export interface BetaThinkingConfigDisabled {
|
|
593
|
+
type: 'disabled';
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export interface BetaThinkingConfigEnabled {
|
|
597
|
+
/**
|
|
598
|
+
* Determines how many tokens Claude can use for its internal reasoning process.
|
|
599
|
+
* Larger budgets can enable more thorough analysis for complex problems, improving
|
|
600
|
+
* response quality.
|
|
601
|
+
*
|
|
602
|
+
* Must be ≥1024 and less than `max_tokens`.
|
|
603
|
+
*
|
|
604
|
+
* See
|
|
605
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
606
|
+
* for details.
|
|
607
|
+
*/
|
|
608
|
+
budget_tokens: number;
|
|
609
|
+
|
|
610
|
+
type: 'enabled';
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Configuration for enabling Claude's extended thinking.
|
|
615
|
+
*
|
|
616
|
+
* When enabled, responses include `thinking` content blocks showing Claude's
|
|
617
|
+
* thinking process before the final answer. Requires a minimum budget of 1,024
|
|
618
|
+
* tokens and counts towards your `max_tokens` limit.
|
|
619
|
+
*
|
|
620
|
+
* See
|
|
621
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
622
|
+
* for details.
|
|
623
|
+
*/
|
|
624
|
+
export type BetaThinkingConfigParam = BetaThinkingConfigEnabled | BetaThinkingConfigDisabled;
|
|
625
|
+
|
|
626
|
+
export interface BetaThinkingDelta {
|
|
627
|
+
thinking: string;
|
|
628
|
+
|
|
629
|
+
type: 'thinking_delta';
|
|
630
|
+
}
|
|
631
|
+
|
|
539
632
|
export interface BetaTool {
|
|
540
633
|
/**
|
|
541
|
-
* [JSON schema](https://json-schema.org/) for this tool's input.
|
|
634
|
+
* [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
|
|
542
635
|
*
|
|
543
636
|
* This defines the shape of the `input` that your tool accepts and that the model
|
|
544
637
|
* will produce.
|
|
@@ -569,7 +662,7 @@ export interface BetaTool {
|
|
|
569
662
|
|
|
570
663
|
export namespace BetaTool {
|
|
571
664
|
/**
|
|
572
|
-
* [JSON schema](https://json-schema.org/) for this tool's input.
|
|
665
|
+
* [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
|
|
573
666
|
*
|
|
574
667
|
* This defines the shape of the `input` that your tool accepts and that the model
|
|
575
668
|
* will produce.
|
|
@@ -595,6 +688,19 @@ export interface BetaToolBash20241022 {
|
|
|
595
688
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
596
689
|
}
|
|
597
690
|
|
|
691
|
+
export interface BetaToolBash20250124 {
|
|
692
|
+
/**
|
|
693
|
+
* Name of the tool.
|
|
694
|
+
*
|
|
695
|
+
* This is how the tool will be called by the model and in tool_use blocks.
|
|
696
|
+
*/
|
|
697
|
+
name: 'bash';
|
|
698
|
+
|
|
699
|
+
type: 'bash_20250124';
|
|
700
|
+
|
|
701
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
702
|
+
}
|
|
703
|
+
|
|
598
704
|
/**
|
|
599
705
|
* How the model should use the provided tools. The model can use a specific tool,
|
|
600
706
|
* any available tool, or decide by itself.
|
|
@@ -679,6 +785,34 @@ export interface BetaToolComputerUse20241022 {
|
|
|
679
785
|
display_number?: number | null;
|
|
680
786
|
}
|
|
681
787
|
|
|
788
|
+
export interface BetaToolComputerUse20250124 {
|
|
789
|
+
/**
|
|
790
|
+
* The height of the display in pixels.
|
|
791
|
+
*/
|
|
792
|
+
display_height_px: number;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* The width of the display in pixels.
|
|
796
|
+
*/
|
|
797
|
+
display_width_px: number;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Name of the tool.
|
|
801
|
+
*
|
|
802
|
+
* This is how the tool will be called by the model and in tool_use blocks.
|
|
803
|
+
*/
|
|
804
|
+
name: 'computer';
|
|
805
|
+
|
|
806
|
+
type: 'computer_20250124';
|
|
807
|
+
|
|
808
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* The X11 display number (e.g. 0, 1) for the display.
|
|
812
|
+
*/
|
|
813
|
+
display_number?: number | null;
|
|
814
|
+
}
|
|
815
|
+
|
|
682
816
|
export interface BetaToolResultBlockParam {
|
|
683
817
|
tool_use_id: string;
|
|
684
818
|
|
|
@@ -704,11 +838,27 @@ export interface BetaToolTextEditor20241022 {
|
|
|
704
838
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
705
839
|
}
|
|
706
840
|
|
|
841
|
+
export interface BetaToolTextEditor20250124 {
|
|
842
|
+
/**
|
|
843
|
+
* Name of the tool.
|
|
844
|
+
*
|
|
845
|
+
* This is how the tool will be called by the model and in tool_use blocks.
|
|
846
|
+
*/
|
|
847
|
+
name: 'str_replace_editor';
|
|
848
|
+
|
|
849
|
+
type: 'text_editor_20250124';
|
|
850
|
+
|
|
851
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
852
|
+
}
|
|
853
|
+
|
|
707
854
|
export type BetaToolUnion =
|
|
708
|
-
| BetaTool
|
|
709
855
|
| BetaToolComputerUse20241022
|
|
710
856
|
| BetaToolBash20241022
|
|
711
|
-
| BetaToolTextEditor20241022
|
|
857
|
+
| BetaToolTextEditor20241022
|
|
858
|
+
| BetaToolComputerUse20250124
|
|
859
|
+
| BetaToolBash20250124
|
|
860
|
+
| BetaToolTextEditor20250124
|
|
861
|
+
| BetaTool;
|
|
712
862
|
|
|
713
863
|
export interface BetaToolUseBlock {
|
|
714
864
|
id: string;
|
|
@@ -913,6 +1063,19 @@ export interface MessageCreateParamsBase {
|
|
|
913
1063
|
*/
|
|
914
1064
|
temperature?: number;
|
|
915
1065
|
|
|
1066
|
+
/**
|
|
1067
|
+
* Body param: Configuration for enabling Claude's extended thinking.
|
|
1068
|
+
*
|
|
1069
|
+
* When enabled, responses include `thinking` content blocks showing Claude's
|
|
1070
|
+
* thinking process before the final answer. Requires a minimum budget of 1,024
|
|
1071
|
+
* tokens and counts towards your `max_tokens` limit.
|
|
1072
|
+
*
|
|
1073
|
+
* See
|
|
1074
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
1075
|
+
* for details.
|
|
1076
|
+
*/
|
|
1077
|
+
thinking?: BetaThinkingConfigParam;
|
|
1078
|
+
|
|
916
1079
|
/**
|
|
917
1080
|
* Body param: How the model should use the provided tools. The model can use a
|
|
918
1081
|
* specific tool, any available tool, or decide by itself.
|
|
@@ -931,8 +1094,9 @@ export interface MessageCreateParamsBase {
|
|
|
931
1094
|
*
|
|
932
1095
|
* - `name`: Name of the tool.
|
|
933
1096
|
* - `description`: Optional, but strongly-recommended description of the tool.
|
|
934
|
-
* - `input_schema`: [JSON schema](https://json-schema.org/) for the
|
|
935
|
-
* shape that the model will produce in `tool_use` output content
|
|
1097
|
+
* - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
|
|
1098
|
+
* tool `input` shape that the model will produce in `tool_use` output content
|
|
1099
|
+
* blocks.
|
|
936
1100
|
*
|
|
937
1101
|
* For example, if you defined `tools` as:
|
|
938
1102
|
*
|
|
@@ -1155,6 +1319,19 @@ export interface MessageCountTokensParams {
|
|
|
1155
1319
|
*/
|
|
1156
1320
|
system?: string | Array<BetaTextBlockParam>;
|
|
1157
1321
|
|
|
1322
|
+
/**
|
|
1323
|
+
* Body param: Configuration for enabling Claude's extended thinking.
|
|
1324
|
+
*
|
|
1325
|
+
* When enabled, responses include `thinking` content blocks showing Claude's
|
|
1326
|
+
* thinking process before the final answer. Requires a minimum budget of 1,024
|
|
1327
|
+
* tokens and counts towards your `max_tokens` limit.
|
|
1328
|
+
*
|
|
1329
|
+
* See
|
|
1330
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
1331
|
+
* for details.
|
|
1332
|
+
*/
|
|
1333
|
+
thinking?: BetaThinkingConfigParam;
|
|
1334
|
+
|
|
1158
1335
|
/**
|
|
1159
1336
|
* Body param: How the model should use the provided tools. The model can use a
|
|
1160
1337
|
* specific tool, any available tool, or decide by itself.
|
|
@@ -1173,8 +1350,9 @@ export interface MessageCountTokensParams {
|
|
|
1173
1350
|
*
|
|
1174
1351
|
* - `name`: Name of the tool.
|
|
1175
1352
|
* - `description`: Optional, but strongly-recommended description of the tool.
|
|
1176
|
-
* - `input_schema`: [JSON schema](https://json-schema.org/) for the
|
|
1177
|
-
* shape that the model will produce in `tool_use` output content
|
|
1353
|
+
* - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
|
|
1354
|
+
* tool `input` shape that the model will produce in `tool_use` output content
|
|
1355
|
+
* blocks.
|
|
1178
1356
|
*
|
|
1179
1357
|
* For example, if you defined `tools` as:
|
|
1180
1358
|
*
|
|
@@ -1231,7 +1409,15 @@ export interface MessageCountTokensParams {
|
|
|
1231
1409
|
*
|
|
1232
1410
|
* See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
|
|
1233
1411
|
*/
|
|
1234
|
-
tools?: Array<
|
|
1412
|
+
tools?: Array<
|
|
1413
|
+
| BetaToolComputerUse20241022
|
|
1414
|
+
| BetaToolBash20241022
|
|
1415
|
+
| BetaToolTextEditor20241022
|
|
1416
|
+
| BetaToolComputerUse20250124
|
|
1417
|
+
| BetaToolBash20250124
|
|
1418
|
+
| BetaToolTextEditor20250124
|
|
1419
|
+
| BetaTool
|
|
1420
|
+
>;
|
|
1235
1421
|
|
|
1236
1422
|
/**
|
|
1237
1423
|
* Header param: Optional header to specify the beta version(s) you want to use.
|
|
@@ -1274,20 +1460,32 @@ export declare namespace Messages {
|
|
|
1274
1460
|
type BetaRawMessageStartEvent as BetaRawMessageStartEvent,
|
|
1275
1461
|
type BetaRawMessageStopEvent as BetaRawMessageStopEvent,
|
|
1276
1462
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
1463
|
+
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
1464
|
+
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
1465
|
+
type BetaSignatureDelta as BetaSignatureDelta,
|
|
1277
1466
|
type BetaTextBlock as BetaTextBlock,
|
|
1278
1467
|
type BetaTextBlockParam as BetaTextBlockParam,
|
|
1279
1468
|
type BetaTextCitation as BetaTextCitation,
|
|
1280
1469
|
type BetaTextCitationParam as BetaTextCitationParam,
|
|
1281
1470
|
type BetaTextDelta as BetaTextDelta,
|
|
1471
|
+
type BetaThinkingBlock as BetaThinkingBlock,
|
|
1472
|
+
type BetaThinkingBlockParam as BetaThinkingBlockParam,
|
|
1473
|
+
type BetaThinkingConfigDisabled as BetaThinkingConfigDisabled,
|
|
1474
|
+
type BetaThinkingConfigEnabled as BetaThinkingConfigEnabled,
|
|
1475
|
+
type BetaThinkingConfigParam as BetaThinkingConfigParam,
|
|
1476
|
+
type BetaThinkingDelta as BetaThinkingDelta,
|
|
1282
1477
|
type BetaTool as BetaTool,
|
|
1283
1478
|
type BetaToolBash20241022 as BetaToolBash20241022,
|
|
1479
|
+
type BetaToolBash20250124 as BetaToolBash20250124,
|
|
1284
1480
|
type BetaToolChoice as BetaToolChoice,
|
|
1285
1481
|
type BetaToolChoiceAny as BetaToolChoiceAny,
|
|
1286
1482
|
type BetaToolChoiceAuto as BetaToolChoiceAuto,
|
|
1287
1483
|
type BetaToolChoiceTool as BetaToolChoiceTool,
|
|
1288
1484
|
type BetaToolComputerUse20241022 as BetaToolComputerUse20241022,
|
|
1485
|
+
type BetaToolComputerUse20250124 as BetaToolComputerUse20250124,
|
|
1289
1486
|
type BetaToolResultBlockParam as BetaToolResultBlockParam,
|
|
1290
1487
|
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
|
|
1488
|
+
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
|
|
1291
1489
|
type BetaToolUnion as BetaToolUnion,
|
|
1292
1490
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
1293
1491
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
package/src/resources/index.ts
CHANGED
|
@@ -47,6 +47,7 @@ export {
|
|
|
47
47
|
type InputJsonDelta,
|
|
48
48
|
type InputJSONDelta,
|
|
49
49
|
type Message,
|
|
50
|
+
type MessageCountTokensTool,
|
|
50
51
|
type MessageDeltaEvent,
|
|
51
52
|
type MessageDeltaUsage,
|
|
52
53
|
type MessageParam,
|
|
@@ -65,17 +66,29 @@ export {
|
|
|
65
66
|
type RawMessageStartEvent,
|
|
66
67
|
type RawMessageStopEvent,
|
|
67
68
|
type RawMessageStreamEvent,
|
|
69
|
+
type RedactedThinkingBlock,
|
|
70
|
+
type RedactedThinkingBlockParam,
|
|
71
|
+
type SignatureDelta,
|
|
68
72
|
type TextBlock,
|
|
69
73
|
type TextBlockParam,
|
|
70
74
|
type TextCitation,
|
|
71
75
|
type TextCitationParam,
|
|
72
76
|
type TextDelta,
|
|
77
|
+
type ThinkingBlock,
|
|
78
|
+
type ThinkingBlockParam,
|
|
79
|
+
type ThinkingConfigDisabled,
|
|
80
|
+
type ThinkingConfigEnabled,
|
|
81
|
+
type ThinkingConfigParam,
|
|
82
|
+
type ThinkingDelta,
|
|
73
83
|
type Tool,
|
|
84
|
+
type ToolBash20250124,
|
|
74
85
|
type ToolChoice,
|
|
75
86
|
type ToolChoiceAny,
|
|
76
87
|
type ToolChoiceAuto,
|
|
77
88
|
type ToolChoiceTool,
|
|
78
89
|
type ToolResultBlockParam,
|
|
90
|
+
type ToolTextEditor20250124,
|
|
91
|
+
type ToolUnion,
|
|
79
92
|
type ToolUseBlock,
|
|
80
93
|
type ToolUseBlockParam,
|
|
81
94
|
type Usage,
|
|
@@ -16,6 +16,9 @@ export class Batches extends APIResource {
|
|
|
16
16
|
* The Message Batches API can be used to process multiple Messages API requests at
|
|
17
17
|
* once. Once a Message Batch is created, it begins processing immediately. Batches
|
|
18
18
|
* can take up to 24 hours to complete.
|
|
19
|
+
*
|
|
20
|
+
* Learn more about the Message Batches API in our
|
|
21
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
19
22
|
*/
|
|
20
23
|
create(body: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<MessageBatch> {
|
|
21
24
|
return this._client.post('/v1/messages/batches', { body, ...options });
|
|
@@ -25,6 +28,9 @@ export class Batches extends APIResource {
|
|
|
25
28
|
* This endpoint is idempotent and can be used to poll for Message Batch
|
|
26
29
|
* completion. To access the results of a Message Batch, make a request to the
|
|
27
30
|
* `results_url` field in the response.
|
|
31
|
+
*
|
|
32
|
+
* Learn more about the Message Batches API in our
|
|
33
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
28
34
|
*/
|
|
29
35
|
retrieve(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<MessageBatch> {
|
|
30
36
|
return this._client.get(`/v1/messages/batches/${messageBatchId}`, options);
|
|
@@ -33,6 +39,9 @@ export class Batches extends APIResource {
|
|
|
33
39
|
/**
|
|
34
40
|
* List all Message Batches within a Workspace. Most recently created batches are
|
|
35
41
|
* returned first.
|
|
42
|
+
*
|
|
43
|
+
* Learn more about the Message Batches API in our
|
|
44
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
36
45
|
*/
|
|
37
46
|
list(
|
|
38
47
|
query?: BatchListParams,
|
|
@@ -54,6 +63,9 @@ export class Batches extends APIResource {
|
|
|
54
63
|
*
|
|
55
64
|
* Message Batches can only be deleted once they've finished processing. If you'd
|
|
56
65
|
* like to delete an in-progress batch, you must first cancel it.
|
|
66
|
+
*
|
|
67
|
+
* Learn more about the Message Batches API in our
|
|
68
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
57
69
|
*/
|
|
58
70
|
delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<DeletedMessageBatch> {
|
|
59
71
|
return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
|
|
@@ -69,6 +81,9 @@ export class Batches extends APIResource {
|
|
|
69
81
|
* which requests were canceled, check the individual results within the batch.
|
|
70
82
|
* Note that cancellation may not result in any canceled requests if they were
|
|
71
83
|
* non-interruptible.
|
|
84
|
+
*
|
|
85
|
+
* Learn more about the Message Batches API in our
|
|
86
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
72
87
|
*/
|
|
73
88
|
cancel(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<MessageBatch> {
|
|
74
89
|
return this._client.post(`/v1/messages/batches/${messageBatchId}/cancel`, options);
|
|
@@ -80,6 +95,9 @@ export class Batches extends APIResource {
|
|
|
80
95
|
* Each line in the file is a JSON object containing the result of a single request
|
|
81
96
|
* in the Message Batch. Results are not guaranteed to be in the same order as
|
|
82
97
|
* requests. Use the `custom_id` field to match results to requests.
|
|
98
|
+
*
|
|
99
|
+
* Learn more about the Message Batches API in our
|
|
100
|
+
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
83
101
|
*/
|
|
84
102
|
async results(
|
|
85
103
|
messageBatchId: string,
|
|
@@ -38,6 +38,7 @@ export {
|
|
|
38
38
|
type ImageBlockParam,
|
|
39
39
|
type InputJSONDelta,
|
|
40
40
|
type Message,
|
|
41
|
+
type MessageCountTokensTool,
|
|
41
42
|
type MessageDeltaEvent,
|
|
42
43
|
type MessageDeltaUsage,
|
|
43
44
|
type MessageParam,
|
|
@@ -55,17 +56,29 @@ export {
|
|
|
55
56
|
type RawMessageStartEvent,
|
|
56
57
|
type RawMessageStopEvent,
|
|
57
58
|
type RawMessageStreamEvent,
|
|
59
|
+
type RedactedThinkingBlock,
|
|
60
|
+
type RedactedThinkingBlockParam,
|
|
61
|
+
type SignatureDelta,
|
|
58
62
|
type TextBlock,
|
|
59
63
|
type TextBlockParam,
|
|
60
64
|
type TextCitation,
|
|
61
65
|
type TextCitationParam,
|
|
62
66
|
type TextDelta,
|
|
67
|
+
type ThinkingBlock,
|
|
68
|
+
type ThinkingBlockParam,
|
|
69
|
+
type ThinkingConfigDisabled,
|
|
70
|
+
type ThinkingConfigEnabled,
|
|
71
|
+
type ThinkingConfigParam,
|
|
72
|
+
type ThinkingDelta,
|
|
63
73
|
type Tool,
|
|
74
|
+
type ToolBash20250124,
|
|
64
75
|
type ToolChoice,
|
|
65
76
|
type ToolChoiceAny,
|
|
66
77
|
type ToolChoiceAuto,
|
|
67
78
|
type ToolChoiceTool,
|
|
68
79
|
type ToolResultBlockParam,
|
|
80
|
+
type ToolTextEditor20250124,
|
|
81
|
+
type ToolUnion,
|
|
69
82
|
type ToolUseBlock,
|
|
70
83
|
type ToolUseBlockParam,
|
|
71
84
|
type Usage,
|