@anthropic-ai/sdk 0.36.3 → 0.38.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 +44 -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 +163 -22
- 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 +144 -23
- 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 +32 -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 +34 -1
- package/src/resources/beta/index.ts +15 -0
- package/src/resources/beta/messages/batches.ts +18 -0
- package/src/resources/beta/messages/index.ts +15 -0
- package/src/resources/beta/messages/messages.ts +236 -25
- package/src/resources/index.ts +16 -0
- package/src/resources/messages/batches.ts +18 -0
- package/src/resources/messages/index.ts +16 -0
- package/src/resources/messages/messages.ts +202 -27
- 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
|
@@ -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,
|
|
@@ -119,8 +126,16 @@ export class Messages extends APIResource {
|
|
|
119
126
|
|
|
120
127
|
export type BetaMessageStreamParams = MessageCreateParamsBase;
|
|
121
128
|
|
|
129
|
+
export interface BetaBase64ImageSource {
|
|
130
|
+
data: string;
|
|
131
|
+
|
|
132
|
+
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
133
|
+
|
|
134
|
+
type: 'base64';
|
|
135
|
+
}
|
|
136
|
+
|
|
122
137
|
export interface BetaBase64PDFBlock {
|
|
123
|
-
source: BetaBase64PDFSource | BetaPlainTextSource | BetaContentBlockSource;
|
|
138
|
+
source: BetaBase64PDFSource | BetaPlainTextSource | BetaContentBlockSource | BetaURLPDFSource;
|
|
124
139
|
|
|
125
140
|
type: 'document';
|
|
126
141
|
|
|
@@ -239,14 +254,20 @@ export interface BetaCitationsDelta {
|
|
|
239
254
|
type: 'citations_delta';
|
|
240
255
|
}
|
|
241
256
|
|
|
242
|
-
export type BetaContentBlock =
|
|
257
|
+
export type BetaContentBlock =
|
|
258
|
+
| BetaTextBlock
|
|
259
|
+
| BetaToolUseBlock
|
|
260
|
+
| BetaThinkingBlock
|
|
261
|
+
| BetaRedactedThinkingBlock;
|
|
243
262
|
|
|
244
263
|
export type BetaContentBlockParam =
|
|
245
264
|
| BetaTextBlockParam
|
|
246
265
|
| BetaImageBlockParam
|
|
247
266
|
| BetaToolUseBlockParam
|
|
248
267
|
| BetaToolResultBlockParam
|
|
249
|
-
| BetaBase64PDFBlock
|
|
268
|
+
| BetaBase64PDFBlock
|
|
269
|
+
| BetaThinkingBlockParam
|
|
270
|
+
| BetaRedactedThinkingBlockParam;
|
|
250
271
|
|
|
251
272
|
export interface BetaContentBlockSource {
|
|
252
273
|
content: string | Array<BetaContentBlockSourceContent>;
|
|
@@ -257,23 +278,13 @@ export interface BetaContentBlockSource {
|
|
|
257
278
|
export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
|
|
258
279
|
|
|
259
280
|
export interface BetaImageBlockParam {
|
|
260
|
-
source:
|
|
281
|
+
source: BetaBase64ImageSource | BetaURLImageSource;
|
|
261
282
|
|
|
262
283
|
type: 'image';
|
|
263
284
|
|
|
264
285
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
265
286
|
}
|
|
266
287
|
|
|
267
|
-
export namespace BetaImageBlockParam {
|
|
268
|
-
export interface Source {
|
|
269
|
-
data: string;
|
|
270
|
-
|
|
271
|
-
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
272
|
-
|
|
273
|
-
type: 'base64';
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
288
|
export interface BetaInputJSONDelta {
|
|
278
289
|
partial_json: string;
|
|
279
290
|
|
|
@@ -381,6 +392,9 @@ export interface BetaMessage {
|
|
|
381
392
|
*
|
|
382
393
|
* For example, `output_tokens` will be non-zero, even for an empty string response
|
|
383
394
|
* from Claude.
|
|
395
|
+
*
|
|
396
|
+
* Total input tokens in a request is the summation of `input_tokens`,
|
|
397
|
+
* `cache_creation_input_tokens`, and `cache_read_input_tokens`.
|
|
384
398
|
*/
|
|
385
399
|
usage: BetaUsage;
|
|
386
400
|
}
|
|
@@ -426,7 +440,7 @@ export interface BetaPlainTextSource {
|
|
|
426
440
|
}
|
|
427
441
|
|
|
428
442
|
export interface BetaRawContentBlockDeltaEvent {
|
|
429
|
-
delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta;
|
|
443
|
+
delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta | BetaThinkingDelta | BetaSignatureDelta;
|
|
430
444
|
|
|
431
445
|
index: number;
|
|
432
446
|
|
|
@@ -434,7 +448,7 @@ export interface BetaRawContentBlockDeltaEvent {
|
|
|
434
448
|
}
|
|
435
449
|
|
|
436
450
|
export interface BetaRawContentBlockStartEvent {
|
|
437
|
-
content_block: BetaTextBlock | BetaToolUseBlock;
|
|
451
|
+
content_block: BetaTextBlock | BetaToolUseBlock | BetaThinkingBlock | BetaRedactedThinkingBlock;
|
|
438
452
|
|
|
439
453
|
index: number;
|
|
440
454
|
|
|
@@ -465,6 +479,9 @@ export interface BetaRawMessageDeltaEvent {
|
|
|
465
479
|
*
|
|
466
480
|
* For example, `output_tokens` will be non-zero, even for an empty string response
|
|
467
481
|
* from Claude.
|
|
482
|
+
*
|
|
483
|
+
* Total input tokens in a request is the summation of `input_tokens`,
|
|
484
|
+
* `cache_creation_input_tokens`, and `cache_read_input_tokens`.
|
|
468
485
|
*/
|
|
469
486
|
usage: BetaMessageDeltaUsage;
|
|
470
487
|
}
|
|
@@ -495,6 +512,24 @@ export type BetaRawMessageStreamEvent =
|
|
|
495
512
|
| BetaRawContentBlockDeltaEvent
|
|
496
513
|
| BetaRawContentBlockStopEvent;
|
|
497
514
|
|
|
515
|
+
export interface BetaRedactedThinkingBlock {
|
|
516
|
+
data: string;
|
|
517
|
+
|
|
518
|
+
type: 'redacted_thinking';
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export interface BetaRedactedThinkingBlockParam {
|
|
522
|
+
data: string;
|
|
523
|
+
|
|
524
|
+
type: 'redacted_thinking';
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export interface BetaSignatureDelta {
|
|
528
|
+
signature: string;
|
|
529
|
+
|
|
530
|
+
type: 'signature_delta';
|
|
531
|
+
}
|
|
532
|
+
|
|
498
533
|
export interface BetaTextBlock {
|
|
499
534
|
/**
|
|
500
535
|
* Citations supporting the text block.
|
|
@@ -536,9 +571,65 @@ export interface BetaTextDelta {
|
|
|
536
571
|
type: 'text_delta';
|
|
537
572
|
}
|
|
538
573
|
|
|
574
|
+
export interface BetaThinkingBlock {
|
|
575
|
+
signature: string;
|
|
576
|
+
|
|
577
|
+
thinking: string;
|
|
578
|
+
|
|
579
|
+
type: 'thinking';
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
export interface BetaThinkingBlockParam {
|
|
583
|
+
signature: string;
|
|
584
|
+
|
|
585
|
+
thinking: string;
|
|
586
|
+
|
|
587
|
+
type: 'thinking';
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
export interface BetaThinkingConfigDisabled {
|
|
591
|
+
type: 'disabled';
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export interface BetaThinkingConfigEnabled {
|
|
595
|
+
/**
|
|
596
|
+
* Determines how many tokens Claude can use for its internal reasoning process.
|
|
597
|
+
* Larger budgets can enable more thorough analysis for complex problems, improving
|
|
598
|
+
* response quality.
|
|
599
|
+
*
|
|
600
|
+
* Must be ≥1024 and less than `max_tokens`.
|
|
601
|
+
*
|
|
602
|
+
* See
|
|
603
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
604
|
+
* for details.
|
|
605
|
+
*/
|
|
606
|
+
budget_tokens: number;
|
|
607
|
+
|
|
608
|
+
type: 'enabled';
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Configuration for enabling Claude's extended thinking.
|
|
613
|
+
*
|
|
614
|
+
* When enabled, responses include `thinking` content blocks showing Claude's
|
|
615
|
+
* thinking process before the final answer. Requires a minimum budget of 1,024
|
|
616
|
+
* tokens and counts towards your `max_tokens` limit.
|
|
617
|
+
*
|
|
618
|
+
* See
|
|
619
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
620
|
+
* for details.
|
|
621
|
+
*/
|
|
622
|
+
export type BetaThinkingConfigParam = BetaThinkingConfigEnabled | BetaThinkingConfigDisabled;
|
|
623
|
+
|
|
624
|
+
export interface BetaThinkingDelta {
|
|
625
|
+
thinking: string;
|
|
626
|
+
|
|
627
|
+
type: 'thinking_delta';
|
|
628
|
+
}
|
|
629
|
+
|
|
539
630
|
export interface BetaTool {
|
|
540
631
|
/**
|
|
541
|
-
* [JSON schema](https://json-schema.org/) for this tool's input.
|
|
632
|
+
* [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
|
|
542
633
|
*
|
|
543
634
|
* This defines the shape of the `input` that your tool accepts and that the model
|
|
544
635
|
* will produce.
|
|
@@ -569,7 +660,7 @@ export interface BetaTool {
|
|
|
569
660
|
|
|
570
661
|
export namespace BetaTool {
|
|
571
662
|
/**
|
|
572
|
-
* [JSON schema](https://json-schema.org/) for this tool's input.
|
|
663
|
+
* [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
|
|
573
664
|
*
|
|
574
665
|
* This defines the shape of the `input` that your tool accepts and that the model
|
|
575
666
|
* will produce.
|
|
@@ -595,6 +686,19 @@ export interface BetaToolBash20241022 {
|
|
|
595
686
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
596
687
|
}
|
|
597
688
|
|
|
689
|
+
export interface BetaToolBash20250124 {
|
|
690
|
+
/**
|
|
691
|
+
* Name of the tool.
|
|
692
|
+
*
|
|
693
|
+
* This is how the tool will be called by the model and in tool_use blocks.
|
|
694
|
+
*/
|
|
695
|
+
name: 'bash';
|
|
696
|
+
|
|
697
|
+
type: 'bash_20250124';
|
|
698
|
+
|
|
699
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
700
|
+
}
|
|
701
|
+
|
|
598
702
|
/**
|
|
599
703
|
* How the model should use the provided tools. The model can use a specific tool,
|
|
600
704
|
* any available tool, or decide by itself.
|
|
@@ -679,6 +783,34 @@ export interface BetaToolComputerUse20241022 {
|
|
|
679
783
|
display_number?: number | null;
|
|
680
784
|
}
|
|
681
785
|
|
|
786
|
+
export interface BetaToolComputerUse20250124 {
|
|
787
|
+
/**
|
|
788
|
+
* The height of the display in pixels.
|
|
789
|
+
*/
|
|
790
|
+
display_height_px: number;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* The width of the display in pixels.
|
|
794
|
+
*/
|
|
795
|
+
display_width_px: number;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Name of the tool.
|
|
799
|
+
*
|
|
800
|
+
* This is how the tool will be called by the model and in tool_use blocks.
|
|
801
|
+
*/
|
|
802
|
+
name: 'computer';
|
|
803
|
+
|
|
804
|
+
type: 'computer_20250124';
|
|
805
|
+
|
|
806
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* The X11 display number (e.g. 0, 1) for the display.
|
|
810
|
+
*/
|
|
811
|
+
display_number?: number | null;
|
|
812
|
+
}
|
|
813
|
+
|
|
682
814
|
export interface BetaToolResultBlockParam {
|
|
683
815
|
tool_use_id: string;
|
|
684
816
|
|
|
@@ -704,11 +836,27 @@ export interface BetaToolTextEditor20241022 {
|
|
|
704
836
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
705
837
|
}
|
|
706
838
|
|
|
839
|
+
export interface BetaToolTextEditor20250124 {
|
|
840
|
+
/**
|
|
841
|
+
* Name of the tool.
|
|
842
|
+
*
|
|
843
|
+
* This is how the tool will be called by the model and in tool_use blocks.
|
|
844
|
+
*/
|
|
845
|
+
name: 'str_replace_editor';
|
|
846
|
+
|
|
847
|
+
type: 'text_editor_20250124';
|
|
848
|
+
|
|
849
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
850
|
+
}
|
|
851
|
+
|
|
707
852
|
export type BetaToolUnion =
|
|
708
853
|
| BetaTool
|
|
709
854
|
| BetaToolComputerUse20241022
|
|
710
855
|
| BetaToolBash20241022
|
|
711
|
-
| BetaToolTextEditor20241022
|
|
856
|
+
| BetaToolTextEditor20241022
|
|
857
|
+
| BetaToolComputerUse20250124
|
|
858
|
+
| BetaToolBash20250124
|
|
859
|
+
| BetaToolTextEditor20250124;
|
|
712
860
|
|
|
713
861
|
export interface BetaToolUseBlock {
|
|
714
862
|
id: string;
|
|
@@ -732,6 +880,18 @@ export interface BetaToolUseBlockParam {
|
|
|
732
880
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
733
881
|
}
|
|
734
882
|
|
|
883
|
+
export interface BetaURLImageSource {
|
|
884
|
+
type: 'url';
|
|
885
|
+
|
|
886
|
+
url: string;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
export interface BetaURLPDFSource {
|
|
890
|
+
type: 'url';
|
|
891
|
+
|
|
892
|
+
url: string;
|
|
893
|
+
}
|
|
894
|
+
|
|
735
895
|
export interface BetaUsage {
|
|
736
896
|
/**
|
|
737
897
|
* The number of input tokens used to create the cache entry.
|
|
@@ -913,6 +1073,19 @@ export interface MessageCreateParamsBase {
|
|
|
913
1073
|
*/
|
|
914
1074
|
temperature?: number;
|
|
915
1075
|
|
|
1076
|
+
/**
|
|
1077
|
+
* Body param: Configuration for enabling Claude's extended thinking.
|
|
1078
|
+
*
|
|
1079
|
+
* When enabled, responses include `thinking` content blocks showing Claude's
|
|
1080
|
+
* thinking process before the final answer. Requires a minimum budget of 1,024
|
|
1081
|
+
* tokens and counts towards your `max_tokens` limit.
|
|
1082
|
+
*
|
|
1083
|
+
* See
|
|
1084
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
1085
|
+
* for details.
|
|
1086
|
+
*/
|
|
1087
|
+
thinking?: BetaThinkingConfigParam;
|
|
1088
|
+
|
|
916
1089
|
/**
|
|
917
1090
|
* Body param: How the model should use the provided tools. The model can use a
|
|
918
1091
|
* specific tool, any available tool, or decide by itself.
|
|
@@ -931,8 +1104,9 @@ export interface MessageCreateParamsBase {
|
|
|
931
1104
|
*
|
|
932
1105
|
* - `name`: Name of the tool.
|
|
933
1106
|
* - `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
|
|
1107
|
+
* - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
|
|
1108
|
+
* tool `input` shape that the model will produce in `tool_use` output content
|
|
1109
|
+
* blocks.
|
|
936
1110
|
*
|
|
937
1111
|
* For example, if you defined `tools` as:
|
|
938
1112
|
*
|
|
@@ -1155,6 +1329,19 @@ export interface MessageCountTokensParams {
|
|
|
1155
1329
|
*/
|
|
1156
1330
|
system?: string | Array<BetaTextBlockParam>;
|
|
1157
1331
|
|
|
1332
|
+
/**
|
|
1333
|
+
* Body param: Configuration for enabling Claude's extended thinking.
|
|
1334
|
+
*
|
|
1335
|
+
* When enabled, responses include `thinking` content blocks showing Claude's
|
|
1336
|
+
* thinking process before the final answer. Requires a minimum budget of 1,024
|
|
1337
|
+
* tokens and counts towards your `max_tokens` limit.
|
|
1338
|
+
*
|
|
1339
|
+
* See
|
|
1340
|
+
* [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
|
1341
|
+
* for details.
|
|
1342
|
+
*/
|
|
1343
|
+
thinking?: BetaThinkingConfigParam;
|
|
1344
|
+
|
|
1158
1345
|
/**
|
|
1159
1346
|
* Body param: How the model should use the provided tools. The model can use a
|
|
1160
1347
|
* specific tool, any available tool, or decide by itself.
|
|
@@ -1173,8 +1360,9 @@ export interface MessageCountTokensParams {
|
|
|
1173
1360
|
*
|
|
1174
1361
|
* - `name`: Name of the tool.
|
|
1175
1362
|
* - `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
|
|
1363
|
+
* - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
|
|
1364
|
+
* tool `input` shape that the model will produce in `tool_use` output content
|
|
1365
|
+
* blocks.
|
|
1178
1366
|
*
|
|
1179
1367
|
* For example, if you defined `tools` as:
|
|
1180
1368
|
*
|
|
@@ -1231,7 +1419,15 @@ export interface MessageCountTokensParams {
|
|
|
1231
1419
|
*
|
|
1232
1420
|
* See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
|
|
1233
1421
|
*/
|
|
1234
|
-
tools?: Array<
|
|
1422
|
+
tools?: Array<
|
|
1423
|
+
| BetaTool
|
|
1424
|
+
| BetaToolComputerUse20241022
|
|
1425
|
+
| BetaToolBash20241022
|
|
1426
|
+
| BetaToolTextEditor20241022
|
|
1427
|
+
| BetaToolComputerUse20250124
|
|
1428
|
+
| BetaToolBash20250124
|
|
1429
|
+
| BetaToolTextEditor20250124
|
|
1430
|
+
>;
|
|
1235
1431
|
|
|
1236
1432
|
/**
|
|
1237
1433
|
* Header param: Optional header to specify the beta version(s) you want to use.
|
|
@@ -1244,6 +1440,7 @@ Messages.BetaMessageBatchesPage = BetaMessageBatchesPage;
|
|
|
1244
1440
|
|
|
1245
1441
|
export declare namespace Messages {
|
|
1246
1442
|
export {
|
|
1443
|
+
type BetaBase64ImageSource as BetaBase64ImageSource,
|
|
1247
1444
|
type BetaBase64PDFBlock as BetaBase64PDFBlock,
|
|
1248
1445
|
type BetaBase64PDFSource as BetaBase64PDFSource,
|
|
1249
1446
|
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
|
|
@@ -1274,23 +1471,37 @@ export declare namespace Messages {
|
|
|
1274
1471
|
type BetaRawMessageStartEvent as BetaRawMessageStartEvent,
|
|
1275
1472
|
type BetaRawMessageStopEvent as BetaRawMessageStopEvent,
|
|
1276
1473
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
1474
|
+
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
1475
|
+
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
1476
|
+
type BetaSignatureDelta as BetaSignatureDelta,
|
|
1277
1477
|
type BetaTextBlock as BetaTextBlock,
|
|
1278
1478
|
type BetaTextBlockParam as BetaTextBlockParam,
|
|
1279
1479
|
type BetaTextCitation as BetaTextCitation,
|
|
1280
1480
|
type BetaTextCitationParam as BetaTextCitationParam,
|
|
1281
1481
|
type BetaTextDelta as BetaTextDelta,
|
|
1482
|
+
type BetaThinkingBlock as BetaThinkingBlock,
|
|
1483
|
+
type BetaThinkingBlockParam as BetaThinkingBlockParam,
|
|
1484
|
+
type BetaThinkingConfigDisabled as BetaThinkingConfigDisabled,
|
|
1485
|
+
type BetaThinkingConfigEnabled as BetaThinkingConfigEnabled,
|
|
1486
|
+
type BetaThinkingConfigParam as BetaThinkingConfigParam,
|
|
1487
|
+
type BetaThinkingDelta as BetaThinkingDelta,
|
|
1282
1488
|
type BetaTool as BetaTool,
|
|
1283
1489
|
type BetaToolBash20241022 as BetaToolBash20241022,
|
|
1490
|
+
type BetaToolBash20250124 as BetaToolBash20250124,
|
|
1284
1491
|
type BetaToolChoice as BetaToolChoice,
|
|
1285
1492
|
type BetaToolChoiceAny as BetaToolChoiceAny,
|
|
1286
1493
|
type BetaToolChoiceAuto as BetaToolChoiceAuto,
|
|
1287
1494
|
type BetaToolChoiceTool as BetaToolChoiceTool,
|
|
1288
1495
|
type BetaToolComputerUse20241022 as BetaToolComputerUse20241022,
|
|
1496
|
+
type BetaToolComputerUse20250124 as BetaToolComputerUse20250124,
|
|
1289
1497
|
type BetaToolResultBlockParam as BetaToolResultBlockParam,
|
|
1290
1498
|
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
|
|
1499
|
+
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
|
|
1291
1500
|
type BetaToolUnion as BetaToolUnion,
|
|
1292
1501
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
1293
1502
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
1503
|
+
type BetaURLImageSource as BetaURLImageSource,
|
|
1504
|
+
type BetaURLPDFSource as BetaURLPDFSource,
|
|
1294
1505
|
type BetaUsage as BetaUsage,
|
|
1295
1506
|
type MessageCreateParams as MessageCreateParams,
|
|
1296
1507
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
package/src/resources/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
} from "./completions.js";
|
|
26
26
|
export {
|
|
27
27
|
Messages,
|
|
28
|
+
type Base64ImageSource,
|
|
28
29
|
type Base64PDFSource,
|
|
29
30
|
type CacheControlEphemeral,
|
|
30
31
|
type CitationCharLocation,
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
type InputJsonDelta,
|
|
48
49
|
type InputJSONDelta,
|
|
49
50
|
type Message,
|
|
51
|
+
type MessageCountTokensTool,
|
|
50
52
|
type MessageDeltaEvent,
|
|
51
53
|
type MessageDeltaUsage,
|
|
52
54
|
type MessageParam,
|
|
@@ -65,19 +67,33 @@ export {
|
|
|
65
67
|
type RawMessageStartEvent,
|
|
66
68
|
type RawMessageStopEvent,
|
|
67
69
|
type RawMessageStreamEvent,
|
|
70
|
+
type RedactedThinkingBlock,
|
|
71
|
+
type RedactedThinkingBlockParam,
|
|
72
|
+
type SignatureDelta,
|
|
68
73
|
type TextBlock,
|
|
69
74
|
type TextBlockParam,
|
|
70
75
|
type TextCitation,
|
|
71
76
|
type TextCitationParam,
|
|
72
77
|
type TextDelta,
|
|
78
|
+
type ThinkingBlock,
|
|
79
|
+
type ThinkingBlockParam,
|
|
80
|
+
type ThinkingConfigDisabled,
|
|
81
|
+
type ThinkingConfigEnabled,
|
|
82
|
+
type ThinkingConfigParam,
|
|
83
|
+
type ThinkingDelta,
|
|
73
84
|
type Tool,
|
|
85
|
+
type ToolBash20250124,
|
|
74
86
|
type ToolChoice,
|
|
75
87
|
type ToolChoiceAny,
|
|
76
88
|
type ToolChoiceAuto,
|
|
77
89
|
type ToolChoiceTool,
|
|
78
90
|
type ToolResultBlockParam,
|
|
91
|
+
type ToolTextEditor20250124,
|
|
92
|
+
type ToolUnion,
|
|
79
93
|
type ToolUseBlock,
|
|
80
94
|
type ToolUseBlockParam,
|
|
95
|
+
type URLImageSource,
|
|
96
|
+
type URLPDFSource,
|
|
81
97
|
type Usage,
|
|
82
98
|
type MessageCreateParams,
|
|
83
99
|
type MessageCreateParamsNonStreaming,
|
|
@@ -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,
|
|
@@ -17,6 +17,7 @@ export {
|
|
|
17
17
|
} from "./batches.js";
|
|
18
18
|
export {
|
|
19
19
|
Messages,
|
|
20
|
+
type Base64ImageSource,
|
|
20
21
|
type Base64PDFSource,
|
|
21
22
|
type CacheControlEphemeral,
|
|
22
23
|
type CitationCharLocation,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
type ImageBlockParam,
|
|
39
40
|
type InputJSONDelta,
|
|
40
41
|
type Message,
|
|
42
|
+
type MessageCountTokensTool,
|
|
41
43
|
type MessageDeltaEvent,
|
|
42
44
|
type MessageDeltaUsage,
|
|
43
45
|
type MessageParam,
|
|
@@ -55,19 +57,33 @@ export {
|
|
|
55
57
|
type RawMessageStartEvent,
|
|
56
58
|
type RawMessageStopEvent,
|
|
57
59
|
type RawMessageStreamEvent,
|
|
60
|
+
type RedactedThinkingBlock,
|
|
61
|
+
type RedactedThinkingBlockParam,
|
|
62
|
+
type SignatureDelta,
|
|
58
63
|
type TextBlock,
|
|
59
64
|
type TextBlockParam,
|
|
60
65
|
type TextCitation,
|
|
61
66
|
type TextCitationParam,
|
|
62
67
|
type TextDelta,
|
|
68
|
+
type ThinkingBlock,
|
|
69
|
+
type ThinkingBlockParam,
|
|
70
|
+
type ThinkingConfigDisabled,
|
|
71
|
+
type ThinkingConfigEnabled,
|
|
72
|
+
type ThinkingConfigParam,
|
|
73
|
+
type ThinkingDelta,
|
|
63
74
|
type Tool,
|
|
75
|
+
type ToolBash20250124,
|
|
64
76
|
type ToolChoice,
|
|
65
77
|
type ToolChoiceAny,
|
|
66
78
|
type ToolChoiceAuto,
|
|
67
79
|
type ToolChoiceTool,
|
|
68
80
|
type ToolResultBlockParam,
|
|
81
|
+
type ToolTextEditor20250124,
|
|
82
|
+
type ToolUnion,
|
|
69
83
|
type ToolUseBlock,
|
|
70
84
|
type ToolUseBlockParam,
|
|
85
|
+
type URLImageSource,
|
|
86
|
+
type URLPDFSource,
|
|
71
87
|
type Usage,
|
|
72
88
|
type MessageCreateParams,
|
|
73
89
|
type MessageCreateParamsBase,
|