@anthropic-ai/sdk 0.50.4 → 0.52.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 +32 -0
- package/README.md +48 -2
- package/client.d.mts +1 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -0
- package/client.d.ts.map +1 -1
- package/client.js +9 -0
- package/client.js.map +1 -1
- package/client.mjs +9 -0
- package/client.mjs.map +1 -1
- package/internal/constants.d.mts +5 -0
- package/internal/constants.d.mts.map +1 -0
- package/internal/constants.d.ts +5 -0
- package/internal/constants.d.ts.map +1 -0
- package/internal/constants.js +15 -0
- package/internal/constants.js.map +1 -0
- package/internal/constants.mjs +12 -0
- package/internal/constants.mjs.map +1 -0
- package/internal/to-file.d.mts.map +1 -1
- package/internal/to-file.d.ts.map +1 -1
- package/internal/to-file.js +9 -4
- package/internal/to-file.js.map +1 -1
- package/internal/to-file.mjs +9 -4
- package/internal/to-file.mjs.map +1 -1
- package/internal/uploads.js +7 -2
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +7 -2
- package/internal/uploads.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +3 -2
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +3 -2
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/package.json +1 -4
- package/resources/beta/beta.d.mts +7 -3
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +7 -3
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +4 -0
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +4 -0
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/files.d.mts +151 -0
- package/resources/beta/files.d.mts.map +1 -0
- package/resources/beta/files.d.ts +151 -0
- package/resources/beta/files.d.ts.map +1 -0
- package/resources/beta/files.js +122 -0
- package/resources/beta/files.js.map +1 -0
- package/resources/beta/files.mjs +118 -0
- package/resources/beta/files.mjs.map +1 -0
- package/resources/beta/index.d.mts +2 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -1
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js +3 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs +1 -0
- package/resources/beta/index.mjs.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 +249 -12
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +249 -12
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +7 -2
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +7 -2
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/messages/messages.d.mts +21 -7
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +21 -7
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +9 -6
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +8 -4
- package/resources/messages/messages.mjs.map +1 -1
- package/src/client.ts +14 -0
- package/src/internal/constants.ts +12 -0
- package/src/internal/to-file.ts +10 -5
- package/src/internal/uploads.ts +9 -3
- package/src/lib/BetaMessageStream.ts +3 -2
- package/src/resources/beta/beta.ts +85 -1
- package/src/resources/beta/files.ts +258 -0
- package/src/resources/beta/index.ts +37 -0
- package/src/resources/beta/messages/index.ts +26 -0
- package/src/resources/beta/messages/messages.ts +398 -23
- package/src/resources/messages/messages.ts +37 -11
- 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
|
@@ -43,6 +43,7 @@ const DEPRECATED_MODELS: {
|
|
|
43
43
|
'claude-2.1': 'July 21st, 2025',
|
|
44
44
|
'claude-2.0': 'July 21st, 2025',
|
|
45
45
|
};
|
|
46
|
+
import { MODEL_NONSTREAMING_TOKENS } from '../../../internal/constants';
|
|
46
47
|
|
|
47
48
|
export class Messages extends APIResource {
|
|
48
49
|
batches: BatchesAPI.Batches = new BatchesAPI.Batches(this._client);
|
|
@@ -88,11 +89,14 @@ export class Messages extends APIResource {
|
|
|
88
89
|
);
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
let timeout = (this._client as any)._options.timeout as number | null;
|
|
93
|
+
if (!body.stream && timeout == null) {
|
|
94
|
+
const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
|
|
95
|
+
timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
|
|
96
|
+
}
|
|
91
97
|
return this._client.post('/v1/messages?beta=true', {
|
|
92
98
|
body,
|
|
93
|
-
timeout:
|
|
94
|
-
(this._client as any)._options.timeout ??
|
|
95
|
-
(body.stream ? 600000 : this._client._calculateNonstreamingTimeout(body.max_tokens)),
|
|
99
|
+
timeout: timeout ?? 600000,
|
|
96
100
|
...options,
|
|
97
101
|
headers: buildHeaders([
|
|
98
102
|
{ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
|
|
@@ -154,7 +158,12 @@ export interface BetaBase64ImageSource {
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
export interface BetaBase64PDFBlock {
|
|
157
|
-
source:
|
|
161
|
+
source:
|
|
162
|
+
| BetaBase64PDFSource
|
|
163
|
+
| BetaPlainTextSource
|
|
164
|
+
| BetaContentBlockSource
|
|
165
|
+
| BetaURLPDFSource
|
|
166
|
+
| BetaFileDocumentSource;
|
|
158
167
|
|
|
159
168
|
type: 'document';
|
|
160
169
|
|
|
@@ -180,6 +189,30 @@ export interface BetaBase64PDFSource {
|
|
|
180
189
|
|
|
181
190
|
export interface BetaCacheControlEphemeral {
|
|
182
191
|
type: 'ephemeral';
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The time-to-live for the cache control breakpoint.
|
|
195
|
+
*
|
|
196
|
+
* This may be one the following values:
|
|
197
|
+
*
|
|
198
|
+
* - `5m`: 5 minutes
|
|
199
|
+
* - `1h`: 1 hour
|
|
200
|
+
*
|
|
201
|
+
* Defaults to `5m`.
|
|
202
|
+
*/
|
|
203
|
+
ttl?: '5m' | '1h';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface BetaCacheCreation {
|
|
207
|
+
/**
|
|
208
|
+
* The number of input tokens used to create the 1 hour cache entry.
|
|
209
|
+
*/
|
|
210
|
+
ephemeral_1h_input_tokens: number;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The number of input tokens used to create the 5 minute cache entry.
|
|
214
|
+
*/
|
|
215
|
+
ephemeral_5m_input_tokens: number;
|
|
183
216
|
}
|
|
184
217
|
|
|
185
218
|
export interface BetaCitationCharLocation {
|
|
@@ -304,24 +337,177 @@ export interface BetaCitationsWebSearchResultLocation {
|
|
|
304
337
|
url: string;
|
|
305
338
|
}
|
|
306
339
|
|
|
340
|
+
export interface BetaCodeExecutionOutputBlock {
|
|
341
|
+
file_id: string;
|
|
342
|
+
|
|
343
|
+
type: 'code_execution_output';
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface BetaCodeExecutionOutputBlockParam {
|
|
347
|
+
file_id: string;
|
|
348
|
+
|
|
349
|
+
type: 'code_execution_output';
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface BetaCodeExecutionResultBlock {
|
|
353
|
+
content: Array<BetaCodeExecutionOutputBlock>;
|
|
354
|
+
|
|
355
|
+
return_code: number;
|
|
356
|
+
|
|
357
|
+
stderr: string;
|
|
358
|
+
|
|
359
|
+
stdout: string;
|
|
360
|
+
|
|
361
|
+
type: 'code_execution_result';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface BetaCodeExecutionResultBlockParam {
|
|
365
|
+
content: Array<BetaCodeExecutionOutputBlockParam>;
|
|
366
|
+
|
|
367
|
+
return_code: number;
|
|
368
|
+
|
|
369
|
+
stderr: string;
|
|
370
|
+
|
|
371
|
+
stdout: string;
|
|
372
|
+
|
|
373
|
+
type: 'code_execution_result';
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface BetaCodeExecutionTool20250522 {
|
|
377
|
+
/**
|
|
378
|
+
* Name of the tool.
|
|
379
|
+
*
|
|
380
|
+
* This is how the tool will be called by the model and in `tool_use` blocks.
|
|
381
|
+
*/
|
|
382
|
+
name: 'code_execution';
|
|
383
|
+
|
|
384
|
+
type: 'code_execution_20250522';
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Create a cache control breakpoint at this content block.
|
|
388
|
+
*/
|
|
389
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface BetaCodeExecutionToolResultBlock {
|
|
393
|
+
content: BetaCodeExecutionToolResultBlockContent;
|
|
394
|
+
|
|
395
|
+
tool_use_id: string;
|
|
396
|
+
|
|
397
|
+
type: 'code_execution_tool_result';
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export type BetaCodeExecutionToolResultBlockContent =
|
|
401
|
+
| BetaCodeExecutionToolResultError
|
|
402
|
+
| BetaCodeExecutionResultBlock;
|
|
403
|
+
|
|
404
|
+
export interface BetaCodeExecutionToolResultBlockParam {
|
|
405
|
+
content: BetaCodeExecutionToolResultBlockParamContent;
|
|
406
|
+
|
|
407
|
+
tool_use_id: string;
|
|
408
|
+
|
|
409
|
+
type: 'code_execution_tool_result';
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Create a cache control breakpoint at this content block.
|
|
413
|
+
*/
|
|
414
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export type BetaCodeExecutionToolResultBlockParamContent =
|
|
418
|
+
| BetaCodeExecutionToolResultErrorParam
|
|
419
|
+
| BetaCodeExecutionResultBlockParam;
|
|
420
|
+
|
|
421
|
+
export interface BetaCodeExecutionToolResultError {
|
|
422
|
+
error_code: BetaCodeExecutionToolResultErrorCode;
|
|
423
|
+
|
|
424
|
+
type: 'code_execution_tool_result_error';
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export type BetaCodeExecutionToolResultErrorCode =
|
|
428
|
+
| 'invalid_tool_input'
|
|
429
|
+
| 'unavailable'
|
|
430
|
+
| 'too_many_requests'
|
|
431
|
+
| 'execution_time_exceeded';
|
|
432
|
+
|
|
433
|
+
export interface BetaCodeExecutionToolResultErrorParam {
|
|
434
|
+
error_code: BetaCodeExecutionToolResultErrorCode;
|
|
435
|
+
|
|
436
|
+
type: 'code_execution_tool_result_error';
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Information about the container used in the request (for the code execution
|
|
441
|
+
* tool)
|
|
442
|
+
*/
|
|
443
|
+
export interface BetaContainer {
|
|
444
|
+
/**
|
|
445
|
+
* Identifier for the container used in this request
|
|
446
|
+
*/
|
|
447
|
+
id: string;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* The time at which the container will expire.
|
|
451
|
+
*/
|
|
452
|
+
expires_at: string;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Response model for a file uploaded to the container.
|
|
457
|
+
*/
|
|
458
|
+
export interface BetaContainerUploadBlock {
|
|
459
|
+
file_id: string;
|
|
460
|
+
|
|
461
|
+
type: 'container_upload';
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* A content block that represents a file to be uploaded to the container Files
|
|
466
|
+
* uploaded via this block will be available in the container's input directory.
|
|
467
|
+
*/
|
|
468
|
+
export interface BetaContainerUploadBlockParam {
|
|
469
|
+
file_id: string;
|
|
470
|
+
|
|
471
|
+
type: 'container_upload';
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Create a cache control breakpoint at this content block.
|
|
475
|
+
*/
|
|
476
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Response model for a file uploaded to the container.
|
|
481
|
+
*/
|
|
307
482
|
export type BetaContentBlock =
|
|
308
483
|
| BetaTextBlock
|
|
309
484
|
| BetaToolUseBlock
|
|
310
485
|
| BetaServerToolUseBlock
|
|
311
486
|
| BetaWebSearchToolResultBlock
|
|
487
|
+
| BetaCodeExecutionToolResultBlock
|
|
488
|
+
| BetaMCPToolUseBlock
|
|
489
|
+
| BetaMCPToolResultBlock
|
|
490
|
+
| BetaContainerUploadBlock
|
|
312
491
|
| BetaThinkingBlock
|
|
313
492
|
| BetaRedactedThinkingBlock;
|
|
314
493
|
|
|
494
|
+
/**
|
|
495
|
+
* Regular text content.
|
|
496
|
+
*/
|
|
315
497
|
export type BetaContentBlockParam =
|
|
498
|
+
| BetaServerToolUseBlockParam
|
|
499
|
+
| BetaWebSearchToolResultBlockParam
|
|
500
|
+
| BetaCodeExecutionToolResultBlockParam
|
|
501
|
+
| BetaMCPToolUseBlockParam
|
|
502
|
+
| BetaRequestMCPToolResultBlockParam
|
|
316
503
|
| BetaTextBlockParam
|
|
317
504
|
| BetaImageBlockParam
|
|
318
505
|
| BetaToolUseBlockParam
|
|
319
|
-
| BetaServerToolUseBlockParam
|
|
320
|
-
| BetaWebSearchToolResultBlockParam
|
|
321
506
|
| BetaToolResultBlockParam
|
|
322
507
|
| BetaBase64PDFBlock
|
|
323
508
|
| BetaThinkingBlockParam
|
|
324
|
-
| BetaRedactedThinkingBlockParam
|
|
509
|
+
| BetaRedactedThinkingBlockParam
|
|
510
|
+
| BetaContainerUploadBlockParam;
|
|
325
511
|
|
|
326
512
|
export interface BetaContentBlockSource {
|
|
327
513
|
content: string | Array<BetaContentBlockSourceContent>;
|
|
@@ -331,8 +517,20 @@ export interface BetaContentBlockSource {
|
|
|
331
517
|
|
|
332
518
|
export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
|
|
333
519
|
|
|
520
|
+
export interface BetaFileDocumentSource {
|
|
521
|
+
file_id: string;
|
|
522
|
+
|
|
523
|
+
type: 'file';
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export interface BetaFileImageSource {
|
|
527
|
+
file_id: string;
|
|
528
|
+
|
|
529
|
+
type: 'file';
|
|
530
|
+
}
|
|
531
|
+
|
|
334
532
|
export interface BetaImageBlockParam {
|
|
335
|
-
source: BetaBase64ImageSource | BetaURLImageSource;
|
|
533
|
+
source: BetaBase64ImageSource | BetaURLImageSource | BetaFileImageSource;
|
|
336
534
|
|
|
337
535
|
type: 'image';
|
|
338
536
|
|
|
@@ -348,6 +546,54 @@ export interface BetaInputJSONDelta {
|
|
|
348
546
|
type: 'input_json_delta';
|
|
349
547
|
}
|
|
350
548
|
|
|
549
|
+
export interface BetaMCPToolResultBlock {
|
|
550
|
+
content: string | Array<BetaTextBlock>;
|
|
551
|
+
|
|
552
|
+
is_error: boolean;
|
|
553
|
+
|
|
554
|
+
tool_use_id: string;
|
|
555
|
+
|
|
556
|
+
type: 'mcp_tool_result';
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export interface BetaMCPToolUseBlock {
|
|
560
|
+
id: string;
|
|
561
|
+
|
|
562
|
+
input: unknown;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* The name of the MCP tool
|
|
566
|
+
*/
|
|
567
|
+
name: string;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* The name of the MCP server
|
|
571
|
+
*/
|
|
572
|
+
server_name: string;
|
|
573
|
+
|
|
574
|
+
type: 'mcp_tool_use';
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export interface BetaMCPToolUseBlockParam {
|
|
578
|
+
id: string;
|
|
579
|
+
|
|
580
|
+
input: unknown;
|
|
581
|
+
|
|
582
|
+
name: string;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* The name of the MCP server
|
|
586
|
+
*/
|
|
587
|
+
server_name: string;
|
|
588
|
+
|
|
589
|
+
type: 'mcp_tool_use';
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Create a cache control breakpoint at this content block.
|
|
593
|
+
*/
|
|
594
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
595
|
+
}
|
|
596
|
+
|
|
351
597
|
export interface BetaMessage {
|
|
352
598
|
/**
|
|
353
599
|
* Unique object identifier.
|
|
@@ -356,6 +602,12 @@ export interface BetaMessage {
|
|
|
356
602
|
*/
|
|
357
603
|
id: string;
|
|
358
604
|
|
|
605
|
+
/**
|
|
606
|
+
* Information about the container used in the request (for the code execution
|
|
607
|
+
* tool)
|
|
608
|
+
*/
|
|
609
|
+
container: BetaContainer | null;
|
|
610
|
+
|
|
359
611
|
/**
|
|
360
612
|
* Content generated by the model.
|
|
361
613
|
*
|
|
@@ -532,11 +784,18 @@ export interface BetaRawContentBlockDeltaEvent {
|
|
|
532
784
|
}
|
|
533
785
|
|
|
534
786
|
export interface BetaRawContentBlockStartEvent {
|
|
787
|
+
/**
|
|
788
|
+
* Response model for a file uploaded to the container.
|
|
789
|
+
*/
|
|
535
790
|
content_block:
|
|
536
791
|
| BetaTextBlock
|
|
537
792
|
| BetaToolUseBlock
|
|
538
793
|
| BetaServerToolUseBlock
|
|
539
794
|
| BetaWebSearchToolResultBlock
|
|
795
|
+
| BetaCodeExecutionToolResultBlock
|
|
796
|
+
| BetaMCPToolUseBlock
|
|
797
|
+
| BetaMCPToolResultBlock
|
|
798
|
+
| BetaContainerUploadBlock
|
|
540
799
|
| BetaThinkingBlock
|
|
541
800
|
| BetaRedactedThinkingBlock;
|
|
542
801
|
|
|
@@ -578,6 +837,12 @@ export interface BetaRawMessageDeltaEvent {
|
|
|
578
837
|
|
|
579
838
|
export namespace BetaRawMessageDeltaEvent {
|
|
580
839
|
export interface Delta {
|
|
840
|
+
/**
|
|
841
|
+
* Information about the container used in the request (for the code execution
|
|
842
|
+
* tool)
|
|
843
|
+
*/
|
|
844
|
+
container: MessagesMessagesAPI.BetaContainer | null;
|
|
845
|
+
|
|
581
846
|
stop_reason: MessagesMessagesAPI.BetaStopReason | null;
|
|
582
847
|
|
|
583
848
|
stop_sequence: string | null;
|
|
@@ -614,6 +879,39 @@ export interface BetaRedactedThinkingBlockParam {
|
|
|
614
879
|
type: 'redacted_thinking';
|
|
615
880
|
}
|
|
616
881
|
|
|
882
|
+
export interface BetaRequestMCPServerToolConfiguration {
|
|
883
|
+
allowed_tools?: Array<string> | null;
|
|
884
|
+
|
|
885
|
+
enabled?: boolean | null;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
export interface BetaRequestMCPServerURLDefinition {
|
|
889
|
+
name: string;
|
|
890
|
+
|
|
891
|
+
type: 'url';
|
|
892
|
+
|
|
893
|
+
url: string;
|
|
894
|
+
|
|
895
|
+
authorization_token?: string | null;
|
|
896
|
+
|
|
897
|
+
tool_configuration?: BetaRequestMCPServerToolConfiguration | null;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export interface BetaRequestMCPToolResultBlockParam {
|
|
901
|
+
tool_use_id: string;
|
|
902
|
+
|
|
903
|
+
type: 'mcp_tool_result';
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Create a cache control breakpoint at this content block.
|
|
907
|
+
*/
|
|
908
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
909
|
+
|
|
910
|
+
content?: string | Array<BetaTextBlockParam>;
|
|
911
|
+
|
|
912
|
+
is_error?: boolean;
|
|
913
|
+
}
|
|
914
|
+
|
|
617
915
|
export interface BetaServerToolUsage {
|
|
618
916
|
/**
|
|
619
917
|
* The number of web search tool requests.
|
|
@@ -626,7 +924,7 @@ export interface BetaServerToolUseBlock {
|
|
|
626
924
|
|
|
627
925
|
input: unknown;
|
|
628
926
|
|
|
629
|
-
name: 'web_search';
|
|
927
|
+
name: 'web_search' | 'code_execution';
|
|
630
928
|
|
|
631
929
|
type: 'server_tool_use';
|
|
632
930
|
}
|
|
@@ -636,7 +934,7 @@ export interface BetaServerToolUseBlockParam {
|
|
|
636
934
|
|
|
637
935
|
input: unknown;
|
|
638
936
|
|
|
639
|
-
name: 'web_search';
|
|
937
|
+
name: 'web_search' | 'code_execution';
|
|
640
938
|
|
|
641
939
|
type: 'server_tool_use';
|
|
642
940
|
|
|
@@ -1016,6 +1314,22 @@ export interface BetaToolTextEditor20250124 {
|
|
|
1016
1314
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
1017
1315
|
}
|
|
1018
1316
|
|
|
1317
|
+
export interface BetaToolTextEditor20250429 {
|
|
1318
|
+
/**
|
|
1319
|
+
* Name of the tool.
|
|
1320
|
+
*
|
|
1321
|
+
* This is how the tool will be called by the model and in `tool_use` blocks.
|
|
1322
|
+
*/
|
|
1323
|
+
name: 'str_replace_based_edit_tool';
|
|
1324
|
+
|
|
1325
|
+
type: 'text_editor_20250429';
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Create a cache control breakpoint at this content block.
|
|
1329
|
+
*/
|
|
1330
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1019
1333
|
export type BetaToolUnion =
|
|
1020
1334
|
| BetaTool
|
|
1021
1335
|
| BetaToolComputerUse20241022
|
|
@@ -1024,7 +1338,9 @@ export type BetaToolUnion =
|
|
|
1024
1338
|
| BetaToolComputerUse20250124
|
|
1025
1339
|
| BetaToolBash20250124
|
|
1026
1340
|
| BetaToolTextEditor20250124
|
|
1027
|
-
|
|
|
1341
|
+
| BetaToolTextEditor20250429
|
|
1342
|
+
| BetaWebSearchTool20250305
|
|
1343
|
+
| BetaCodeExecutionTool20250522;
|
|
1028
1344
|
|
|
1029
1345
|
export interface BetaToolUseBlock {
|
|
1030
1346
|
id: string;
|
|
@@ -1064,6 +1380,11 @@ export interface BetaURLPDFSource {
|
|
|
1064
1380
|
}
|
|
1065
1381
|
|
|
1066
1382
|
export interface BetaUsage {
|
|
1383
|
+
/**
|
|
1384
|
+
* Breakdown of cached tokens by TTL
|
|
1385
|
+
*/
|
|
1386
|
+
cache_creation: BetaCacheCreation | null;
|
|
1387
|
+
|
|
1067
1388
|
/**
|
|
1068
1389
|
* The number of input tokens used to create the cache entry.
|
|
1069
1390
|
*/
|
|
@@ -1088,6 +1409,11 @@ export interface BetaUsage {
|
|
|
1088
1409
|
* The number of server tool requests.
|
|
1089
1410
|
*/
|
|
1090
1411
|
server_tool_use: BetaServerToolUsage | null;
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* If the request used the priority, standard, or batch tier.
|
|
1415
|
+
*/
|
|
1416
|
+
service_tier: 'standard' | 'priority' | 'batch' | null;
|
|
1091
1417
|
}
|
|
1092
1418
|
|
|
1093
1419
|
export interface BetaWebSearchResultBlock {
|
|
@@ -1186,12 +1512,7 @@ export namespace BetaWebSearchTool20250305 {
|
|
|
1186
1512
|
}
|
|
1187
1513
|
|
|
1188
1514
|
export interface BetaWebSearchToolRequestError {
|
|
1189
|
-
error_code:
|
|
1190
|
-
| 'invalid_tool_input'
|
|
1191
|
-
| 'unavailable'
|
|
1192
|
-
| 'max_uses_exceeded'
|
|
1193
|
-
| 'too_many_requests'
|
|
1194
|
-
| 'query_too_long';
|
|
1515
|
+
error_code: BetaWebSearchToolResultErrorCode;
|
|
1195
1516
|
|
|
1196
1517
|
type: 'web_search_tool_result_error';
|
|
1197
1518
|
}
|
|
@@ -1226,16 +1547,18 @@ export type BetaWebSearchToolResultBlockParamContent =
|
|
|
1226
1547
|
| BetaWebSearchToolRequestError;
|
|
1227
1548
|
|
|
1228
1549
|
export interface BetaWebSearchToolResultError {
|
|
1229
|
-
error_code:
|
|
1230
|
-
| 'invalid_tool_input'
|
|
1231
|
-
| 'unavailable'
|
|
1232
|
-
| 'max_uses_exceeded'
|
|
1233
|
-
| 'too_many_requests'
|
|
1234
|
-
| 'query_too_long';
|
|
1550
|
+
error_code: BetaWebSearchToolResultErrorCode;
|
|
1235
1551
|
|
|
1236
1552
|
type: 'web_search_tool_result_error';
|
|
1237
1553
|
}
|
|
1238
1554
|
|
|
1555
|
+
export type BetaWebSearchToolResultErrorCode =
|
|
1556
|
+
| 'invalid_tool_input'
|
|
1557
|
+
| 'unavailable'
|
|
1558
|
+
| 'max_uses_exceeded'
|
|
1559
|
+
| 'too_many_requests'
|
|
1560
|
+
| 'query_too_long';
|
|
1561
|
+
|
|
1239
1562
|
export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
|
|
1240
1563
|
|
|
1241
1564
|
export interface MessageCreateParamsBase {
|
|
@@ -1349,11 +1672,30 @@ export interface MessageCreateParamsBase {
|
|
|
1349
1672
|
*/
|
|
1350
1673
|
model: MessagesAPI.Model;
|
|
1351
1674
|
|
|
1675
|
+
/**
|
|
1676
|
+
* Body param: Container identifier for reuse across requests.
|
|
1677
|
+
*/
|
|
1678
|
+
container?: string | null;
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Body param: MCP servers to be utilized in this request
|
|
1682
|
+
*/
|
|
1683
|
+
mcp_servers?: Array<BetaRequestMCPServerURLDefinition>;
|
|
1684
|
+
|
|
1352
1685
|
/**
|
|
1353
1686
|
* Body param: An object describing metadata about the request.
|
|
1354
1687
|
*/
|
|
1355
1688
|
metadata?: BetaMetadata;
|
|
1356
1689
|
|
|
1690
|
+
/**
|
|
1691
|
+
* Body param: Determines whether to use priority capacity (if available) or
|
|
1692
|
+
* standard capacity for this request.
|
|
1693
|
+
*
|
|
1694
|
+
* Anthropic offers different levels of service for your API requests. See
|
|
1695
|
+
* [service-tiers](https://docs.anthropic.com/en/api/service-tiers) for details.
|
|
1696
|
+
*/
|
|
1697
|
+
service_tier?: 'auto' | 'standard_only';
|
|
1698
|
+
|
|
1357
1699
|
/**
|
|
1358
1700
|
* Body param: Custom text sequences that will cause the model to stop generating.
|
|
1359
1701
|
*
|
|
@@ -1646,6 +1988,11 @@ export interface MessageCountTokensParams {
|
|
|
1646
1988
|
*/
|
|
1647
1989
|
model: MessagesAPI.Model;
|
|
1648
1990
|
|
|
1991
|
+
/**
|
|
1992
|
+
* Body param: MCP servers to be utilized in this request
|
|
1993
|
+
*/
|
|
1994
|
+
mcp_servers?: Array<BetaRequestMCPServerURLDefinition>;
|
|
1995
|
+
|
|
1649
1996
|
/**
|
|
1650
1997
|
* Body param: System prompt.
|
|
1651
1998
|
*
|
|
@@ -1753,7 +2100,9 @@ export interface MessageCountTokensParams {
|
|
|
1753
2100
|
| BetaToolComputerUse20250124
|
|
1754
2101
|
| BetaToolBash20250124
|
|
1755
2102
|
| BetaToolTextEditor20250124
|
|
2103
|
+
| BetaToolTextEditor20250429
|
|
1756
2104
|
| BetaWebSearchTool20250305
|
|
2105
|
+
| BetaCodeExecutionTool20250522
|
|
1757
2106
|
>;
|
|
1758
2107
|
|
|
1759
2108
|
/**
|
|
@@ -1770,6 +2119,7 @@ export declare namespace Messages {
|
|
|
1770
2119
|
type BetaBase64PDFBlock as BetaBase64PDFBlock,
|
|
1771
2120
|
type BetaBase64PDFSource as BetaBase64PDFSource,
|
|
1772
2121
|
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
|
|
2122
|
+
type BetaCacheCreation as BetaCacheCreation,
|
|
1773
2123
|
type BetaCitationCharLocation as BetaCitationCharLocation,
|
|
1774
2124
|
type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
|
|
1775
2125
|
type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
|
|
@@ -1780,12 +2130,32 @@ export declare namespace Messages {
|
|
|
1780
2130
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
1781
2131
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
1782
2132
|
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
|
|
2133
|
+
type BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock,
|
|
2134
|
+
type BetaCodeExecutionOutputBlockParam as BetaCodeExecutionOutputBlockParam,
|
|
2135
|
+
type BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock,
|
|
2136
|
+
type BetaCodeExecutionResultBlockParam as BetaCodeExecutionResultBlockParam,
|
|
2137
|
+
type BetaCodeExecutionTool20250522 as BetaCodeExecutionTool20250522,
|
|
2138
|
+
type BetaCodeExecutionToolResultBlock as BetaCodeExecutionToolResultBlock,
|
|
2139
|
+
type BetaCodeExecutionToolResultBlockContent as BetaCodeExecutionToolResultBlockContent,
|
|
2140
|
+
type BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
|
|
2141
|
+
type BetaCodeExecutionToolResultBlockParamContent as BetaCodeExecutionToolResultBlockParamContent,
|
|
2142
|
+
type BetaCodeExecutionToolResultError as BetaCodeExecutionToolResultError,
|
|
2143
|
+
type BetaCodeExecutionToolResultErrorCode as BetaCodeExecutionToolResultErrorCode,
|
|
2144
|
+
type BetaCodeExecutionToolResultErrorParam as BetaCodeExecutionToolResultErrorParam,
|
|
2145
|
+
type BetaContainer as BetaContainer,
|
|
2146
|
+
type BetaContainerUploadBlock as BetaContainerUploadBlock,
|
|
2147
|
+
type BetaContainerUploadBlockParam as BetaContainerUploadBlockParam,
|
|
1783
2148
|
type BetaContentBlock as BetaContentBlock,
|
|
1784
2149
|
type BetaContentBlockParam as BetaContentBlockParam,
|
|
1785
2150
|
type BetaContentBlockSource as BetaContentBlockSource,
|
|
1786
2151
|
type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
|
|
2152
|
+
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
2153
|
+
type BetaFileImageSource as BetaFileImageSource,
|
|
1787
2154
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
1788
2155
|
type BetaInputJSONDelta as BetaInputJSONDelta,
|
|
2156
|
+
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
|
|
2157
|
+
type BetaMCPToolUseBlock as BetaMCPToolUseBlock,
|
|
2158
|
+
type BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam,
|
|
1789
2159
|
type BetaMessage as BetaMessage,
|
|
1790
2160
|
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
|
|
1791
2161
|
type BetaMessageParam as BetaMessageParam,
|
|
@@ -1802,6 +2172,9 @@ export declare namespace Messages {
|
|
|
1802
2172
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
1803
2173
|
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
1804
2174
|
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
2175
|
+
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
|
|
2176
|
+
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
|
|
2177
|
+
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
|
|
1805
2178
|
type BetaServerToolUsage as BetaServerToolUsage,
|
|
1806
2179
|
type BetaServerToolUseBlock as BetaServerToolUseBlock,
|
|
1807
2180
|
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
|
|
@@ -1831,6 +2204,7 @@ export declare namespace Messages {
|
|
|
1831
2204
|
type BetaToolResultBlockParam as BetaToolResultBlockParam,
|
|
1832
2205
|
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
|
|
1833
2206
|
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
|
|
2207
|
+
type BetaToolTextEditor20250429 as BetaToolTextEditor20250429,
|
|
1834
2208
|
type BetaToolUnion as BetaToolUnion,
|
|
1835
2209
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
1836
2210
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
@@ -1846,6 +2220,7 @@ export declare namespace Messages {
|
|
|
1846
2220
|
type BetaWebSearchToolResultBlockParam as BetaWebSearchToolResultBlockParam,
|
|
1847
2221
|
type BetaWebSearchToolResultBlockParamContent as BetaWebSearchToolResultBlockParamContent,
|
|
1848
2222
|
type BetaWebSearchToolResultError as BetaWebSearchToolResultError,
|
|
2223
|
+
type BetaWebSearchToolResultErrorCode as BetaWebSearchToolResultErrorCode,
|
|
1849
2224
|
type MessageCreateParams as MessageCreateParams,
|
|
1850
2225
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
1851
2226
|
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
|