@anthropic-ai/sdk 0.51.0 → 0.53.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 +48 -0
- package/README.md +79 -45
- 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 +10 -1
- package/client.js.map +1 -1
- package/client.mjs +10 -1
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +1 -1
- package/core/pagination.d.mts.map +1 -1
- package/core/pagination.d.ts +1 -1
- package/core/pagination.d.ts.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/detect-platform.js +3 -3
- package/internal/detect-platform.js.map +1 -1
- package/internal/detect-platform.mjs +3 -3
- package/internal/detect-platform.mjs.map +1 -1
- package/internal/shim-types.d.mts +11 -22
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +11 -22
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +2 -2
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +2 -2
- package/internal/shims.d.ts.map +1 -1
- 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 +2 -2
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts +2 -2
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +6 -2
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +6 -2
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.mts +2 -2
- package/lib/MessageStream.d.mts.map +1 -1
- package/lib/MessageStream.d.ts +2 -2
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +5 -2
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +5 -2
- package/lib/MessageStream.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 +250 -12
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +250 -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 +54 -9
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +54 -9
- 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 +15 -1
- package/src/core/pagination.ts +1 -1
- package/src/internal/constants.ts +12 -0
- package/src/internal/detect-platform.ts +3 -3
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +2 -2
- package/src/internal/to-file.ts +10 -5
- package/src/internal/uploads.ts +9 -3
- package/src/lib/BetaMessageStream.ts +12 -3
- package/src/lib/MessageStream.ts +10 -3
- 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 +400 -23
- package/src/resources/messages/messages.ts +87 -13
- 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
- package/src/internal/shim-types.d.ts +0 -28
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
type BetaBase64PDFBlock,
|
|
26
26
|
type BetaBase64PDFSource,
|
|
27
27
|
type BetaCacheControlEphemeral,
|
|
28
|
+
type BetaCacheCreation,
|
|
28
29
|
type BetaCitationCharLocation,
|
|
29
30
|
type BetaCitationCharLocationParam,
|
|
30
31
|
type BetaCitationContentBlockLocation,
|
|
@@ -35,12 +36,32 @@ export {
|
|
|
35
36
|
type BetaCitationsConfigParam,
|
|
36
37
|
type BetaCitationsDelta,
|
|
37
38
|
type BetaCitationsWebSearchResultLocation,
|
|
39
|
+
type BetaCodeExecutionOutputBlock,
|
|
40
|
+
type BetaCodeExecutionOutputBlockParam,
|
|
41
|
+
type BetaCodeExecutionResultBlock,
|
|
42
|
+
type BetaCodeExecutionResultBlockParam,
|
|
43
|
+
type BetaCodeExecutionTool20250522,
|
|
44
|
+
type BetaCodeExecutionToolResultBlock,
|
|
45
|
+
type BetaCodeExecutionToolResultBlockContent,
|
|
46
|
+
type BetaCodeExecutionToolResultBlockParam,
|
|
47
|
+
type BetaCodeExecutionToolResultBlockParamContent,
|
|
48
|
+
type BetaCodeExecutionToolResultError,
|
|
49
|
+
type BetaCodeExecutionToolResultErrorCode,
|
|
50
|
+
type BetaCodeExecutionToolResultErrorParam,
|
|
51
|
+
type BetaContainer,
|
|
52
|
+
type BetaContainerUploadBlock,
|
|
53
|
+
type BetaContainerUploadBlockParam,
|
|
38
54
|
type BetaContentBlock,
|
|
39
55
|
type BetaContentBlockParam,
|
|
40
56
|
type BetaContentBlockSource,
|
|
41
57
|
type BetaContentBlockSourceContent,
|
|
58
|
+
type BetaFileDocumentSource,
|
|
59
|
+
type BetaFileImageSource,
|
|
42
60
|
type BetaImageBlockParam,
|
|
43
61
|
type BetaInputJSONDelta,
|
|
62
|
+
type BetaMCPToolResultBlock,
|
|
63
|
+
type BetaMCPToolUseBlock,
|
|
64
|
+
type BetaMCPToolUseBlockParam,
|
|
44
65
|
type BetaMessage,
|
|
45
66
|
type BetaMessageDeltaUsage,
|
|
46
67
|
type BetaMessageParam,
|
|
@@ -57,6 +78,9 @@ export {
|
|
|
57
78
|
type BetaRawMessageStreamEvent,
|
|
58
79
|
type BetaRedactedThinkingBlock,
|
|
59
80
|
type BetaRedactedThinkingBlockParam,
|
|
81
|
+
type BetaRequestMCPServerToolConfiguration,
|
|
82
|
+
type BetaRequestMCPServerURLDefinition,
|
|
83
|
+
type BetaRequestMCPToolResultBlockParam,
|
|
60
84
|
type BetaServerToolUsage,
|
|
61
85
|
type BetaServerToolUseBlock,
|
|
62
86
|
type BetaServerToolUseBlockParam,
|
|
@@ -86,6 +110,7 @@ export {
|
|
|
86
110
|
type BetaToolResultBlockParam,
|
|
87
111
|
type BetaToolTextEditor20241022,
|
|
88
112
|
type BetaToolTextEditor20250124,
|
|
113
|
+
type BetaToolTextEditor20250429,
|
|
89
114
|
type BetaToolUnion,
|
|
90
115
|
type BetaToolUseBlock,
|
|
91
116
|
type BetaToolUseBlockParam,
|
|
@@ -101,6 +126,7 @@ export {
|
|
|
101
126
|
type BetaWebSearchToolResultBlockParam,
|
|
102
127
|
type BetaWebSearchToolResultBlockParamContent,
|
|
103
128
|
type BetaWebSearchToolResultError,
|
|
129
|
+
type BetaWebSearchToolResultErrorCode,
|
|
104
130
|
type MessageCreateParams,
|
|
105
131
|
type MessageCreateParamsNonStreaming,
|
|
106
132
|
type MessageCreateParamsStreaming,
|
|
@@ -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
|
|
|
@@ -808,6 +1106,8 @@ export namespace BetaTool {
|
|
|
808
1106
|
|
|
809
1107
|
properties?: unknown | null;
|
|
810
1108
|
|
|
1109
|
+
required?: Array<string> | null;
|
|
1110
|
+
|
|
811
1111
|
[k: string]: unknown;
|
|
812
1112
|
}
|
|
813
1113
|
}
|
|
@@ -1016,6 +1316,22 @@ export interface BetaToolTextEditor20250124 {
|
|
|
1016
1316
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
1017
1317
|
}
|
|
1018
1318
|
|
|
1319
|
+
export interface BetaToolTextEditor20250429 {
|
|
1320
|
+
/**
|
|
1321
|
+
* Name of the tool.
|
|
1322
|
+
*
|
|
1323
|
+
* This is how the tool will be called by the model and in `tool_use` blocks.
|
|
1324
|
+
*/
|
|
1325
|
+
name: 'str_replace_based_edit_tool';
|
|
1326
|
+
|
|
1327
|
+
type: 'text_editor_20250429';
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Create a cache control breakpoint at this content block.
|
|
1331
|
+
*/
|
|
1332
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1019
1335
|
export type BetaToolUnion =
|
|
1020
1336
|
| BetaTool
|
|
1021
1337
|
| BetaToolComputerUse20241022
|
|
@@ -1024,7 +1340,9 @@ export type BetaToolUnion =
|
|
|
1024
1340
|
| BetaToolComputerUse20250124
|
|
1025
1341
|
| BetaToolBash20250124
|
|
1026
1342
|
| BetaToolTextEditor20250124
|
|
1027
|
-
|
|
|
1343
|
+
| BetaToolTextEditor20250429
|
|
1344
|
+
| BetaWebSearchTool20250305
|
|
1345
|
+
| BetaCodeExecutionTool20250522;
|
|
1028
1346
|
|
|
1029
1347
|
export interface BetaToolUseBlock {
|
|
1030
1348
|
id: string;
|
|
@@ -1064,6 +1382,11 @@ export interface BetaURLPDFSource {
|
|
|
1064
1382
|
}
|
|
1065
1383
|
|
|
1066
1384
|
export interface BetaUsage {
|
|
1385
|
+
/**
|
|
1386
|
+
* Breakdown of cached tokens by TTL
|
|
1387
|
+
*/
|
|
1388
|
+
cache_creation: BetaCacheCreation | null;
|
|
1389
|
+
|
|
1067
1390
|
/**
|
|
1068
1391
|
* The number of input tokens used to create the cache entry.
|
|
1069
1392
|
*/
|
|
@@ -1088,6 +1411,11 @@ export interface BetaUsage {
|
|
|
1088
1411
|
* The number of server tool requests.
|
|
1089
1412
|
*/
|
|
1090
1413
|
server_tool_use: BetaServerToolUsage | null;
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* If the request used the priority, standard, or batch tier.
|
|
1417
|
+
*/
|
|
1418
|
+
service_tier: 'standard' | 'priority' | 'batch' | null;
|
|
1091
1419
|
}
|
|
1092
1420
|
|
|
1093
1421
|
export interface BetaWebSearchResultBlock {
|
|
@@ -1186,12 +1514,7 @@ export namespace BetaWebSearchTool20250305 {
|
|
|
1186
1514
|
}
|
|
1187
1515
|
|
|
1188
1516
|
export interface BetaWebSearchToolRequestError {
|
|
1189
|
-
error_code:
|
|
1190
|
-
| 'invalid_tool_input'
|
|
1191
|
-
| 'unavailable'
|
|
1192
|
-
| 'max_uses_exceeded'
|
|
1193
|
-
| 'too_many_requests'
|
|
1194
|
-
| 'query_too_long';
|
|
1517
|
+
error_code: BetaWebSearchToolResultErrorCode;
|
|
1195
1518
|
|
|
1196
1519
|
type: 'web_search_tool_result_error';
|
|
1197
1520
|
}
|
|
@@ -1226,16 +1549,18 @@ export type BetaWebSearchToolResultBlockParamContent =
|
|
|
1226
1549
|
| BetaWebSearchToolRequestError;
|
|
1227
1550
|
|
|
1228
1551
|
export interface BetaWebSearchToolResultError {
|
|
1229
|
-
error_code:
|
|
1230
|
-
| 'invalid_tool_input'
|
|
1231
|
-
| 'unavailable'
|
|
1232
|
-
| 'max_uses_exceeded'
|
|
1233
|
-
| 'too_many_requests'
|
|
1234
|
-
| 'query_too_long';
|
|
1552
|
+
error_code: BetaWebSearchToolResultErrorCode;
|
|
1235
1553
|
|
|
1236
1554
|
type: 'web_search_tool_result_error';
|
|
1237
1555
|
}
|
|
1238
1556
|
|
|
1557
|
+
export type BetaWebSearchToolResultErrorCode =
|
|
1558
|
+
| 'invalid_tool_input'
|
|
1559
|
+
| 'unavailable'
|
|
1560
|
+
| 'max_uses_exceeded'
|
|
1561
|
+
| 'too_many_requests'
|
|
1562
|
+
| 'query_too_long';
|
|
1563
|
+
|
|
1239
1564
|
export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
|
|
1240
1565
|
|
|
1241
1566
|
export interface MessageCreateParamsBase {
|
|
@@ -1349,11 +1674,30 @@ export interface MessageCreateParamsBase {
|
|
|
1349
1674
|
*/
|
|
1350
1675
|
model: MessagesAPI.Model;
|
|
1351
1676
|
|
|
1677
|
+
/**
|
|
1678
|
+
* Body param: Container identifier for reuse across requests.
|
|
1679
|
+
*/
|
|
1680
|
+
container?: string | null;
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Body param: MCP servers to be utilized in this request
|
|
1684
|
+
*/
|
|
1685
|
+
mcp_servers?: Array<BetaRequestMCPServerURLDefinition>;
|
|
1686
|
+
|
|
1352
1687
|
/**
|
|
1353
1688
|
* Body param: An object describing metadata about the request.
|
|
1354
1689
|
*/
|
|
1355
1690
|
metadata?: BetaMetadata;
|
|
1356
1691
|
|
|
1692
|
+
/**
|
|
1693
|
+
* Body param: Determines whether to use priority capacity (if available) or
|
|
1694
|
+
* standard capacity for this request.
|
|
1695
|
+
*
|
|
1696
|
+
* Anthropic offers different levels of service for your API requests. See
|
|
1697
|
+
* [service-tiers](https://docs.anthropic.com/en/api/service-tiers) for details.
|
|
1698
|
+
*/
|
|
1699
|
+
service_tier?: 'auto' | 'standard_only';
|
|
1700
|
+
|
|
1357
1701
|
/**
|
|
1358
1702
|
* Body param: Custom text sequences that will cause the model to stop generating.
|
|
1359
1703
|
*
|
|
@@ -1646,6 +1990,11 @@ export interface MessageCountTokensParams {
|
|
|
1646
1990
|
*/
|
|
1647
1991
|
model: MessagesAPI.Model;
|
|
1648
1992
|
|
|
1993
|
+
/**
|
|
1994
|
+
* Body param: MCP servers to be utilized in this request
|
|
1995
|
+
*/
|
|
1996
|
+
mcp_servers?: Array<BetaRequestMCPServerURLDefinition>;
|
|
1997
|
+
|
|
1649
1998
|
/**
|
|
1650
1999
|
* Body param: System prompt.
|
|
1651
2000
|
*
|
|
@@ -1753,7 +2102,9 @@ export interface MessageCountTokensParams {
|
|
|
1753
2102
|
| BetaToolComputerUse20250124
|
|
1754
2103
|
| BetaToolBash20250124
|
|
1755
2104
|
| BetaToolTextEditor20250124
|
|
2105
|
+
| BetaToolTextEditor20250429
|
|
1756
2106
|
| BetaWebSearchTool20250305
|
|
2107
|
+
| BetaCodeExecutionTool20250522
|
|
1757
2108
|
>;
|
|
1758
2109
|
|
|
1759
2110
|
/**
|
|
@@ -1770,6 +2121,7 @@ export declare namespace Messages {
|
|
|
1770
2121
|
type BetaBase64PDFBlock as BetaBase64PDFBlock,
|
|
1771
2122
|
type BetaBase64PDFSource as BetaBase64PDFSource,
|
|
1772
2123
|
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
|
|
2124
|
+
type BetaCacheCreation as BetaCacheCreation,
|
|
1773
2125
|
type BetaCitationCharLocation as BetaCitationCharLocation,
|
|
1774
2126
|
type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
|
|
1775
2127
|
type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
|
|
@@ -1780,12 +2132,32 @@ export declare namespace Messages {
|
|
|
1780
2132
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
1781
2133
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
1782
2134
|
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
|
|
2135
|
+
type BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock,
|
|
2136
|
+
type BetaCodeExecutionOutputBlockParam as BetaCodeExecutionOutputBlockParam,
|
|
2137
|
+
type BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock,
|
|
2138
|
+
type BetaCodeExecutionResultBlockParam as BetaCodeExecutionResultBlockParam,
|
|
2139
|
+
type BetaCodeExecutionTool20250522 as BetaCodeExecutionTool20250522,
|
|
2140
|
+
type BetaCodeExecutionToolResultBlock as BetaCodeExecutionToolResultBlock,
|
|
2141
|
+
type BetaCodeExecutionToolResultBlockContent as BetaCodeExecutionToolResultBlockContent,
|
|
2142
|
+
type BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
|
|
2143
|
+
type BetaCodeExecutionToolResultBlockParamContent as BetaCodeExecutionToolResultBlockParamContent,
|
|
2144
|
+
type BetaCodeExecutionToolResultError as BetaCodeExecutionToolResultError,
|
|
2145
|
+
type BetaCodeExecutionToolResultErrorCode as BetaCodeExecutionToolResultErrorCode,
|
|
2146
|
+
type BetaCodeExecutionToolResultErrorParam as BetaCodeExecutionToolResultErrorParam,
|
|
2147
|
+
type BetaContainer as BetaContainer,
|
|
2148
|
+
type BetaContainerUploadBlock as BetaContainerUploadBlock,
|
|
2149
|
+
type BetaContainerUploadBlockParam as BetaContainerUploadBlockParam,
|
|
1783
2150
|
type BetaContentBlock as BetaContentBlock,
|
|
1784
2151
|
type BetaContentBlockParam as BetaContentBlockParam,
|
|
1785
2152
|
type BetaContentBlockSource as BetaContentBlockSource,
|
|
1786
2153
|
type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
|
|
2154
|
+
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
2155
|
+
type BetaFileImageSource as BetaFileImageSource,
|
|
1787
2156
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
1788
2157
|
type BetaInputJSONDelta as BetaInputJSONDelta,
|
|
2158
|
+
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
|
|
2159
|
+
type BetaMCPToolUseBlock as BetaMCPToolUseBlock,
|
|
2160
|
+
type BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam,
|
|
1789
2161
|
type BetaMessage as BetaMessage,
|
|
1790
2162
|
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
|
|
1791
2163
|
type BetaMessageParam as BetaMessageParam,
|
|
@@ -1802,6 +2174,9 @@ export declare namespace Messages {
|
|
|
1802
2174
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
1803
2175
|
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
1804
2176
|
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
2177
|
+
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
|
|
2178
|
+
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
|
|
2179
|
+
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
|
|
1805
2180
|
type BetaServerToolUsage as BetaServerToolUsage,
|
|
1806
2181
|
type BetaServerToolUseBlock as BetaServerToolUseBlock,
|
|
1807
2182
|
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
|
|
@@ -1831,6 +2206,7 @@ export declare namespace Messages {
|
|
|
1831
2206
|
type BetaToolResultBlockParam as BetaToolResultBlockParam,
|
|
1832
2207
|
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
|
|
1833
2208
|
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
|
|
2209
|
+
type BetaToolTextEditor20250429 as BetaToolTextEditor20250429,
|
|
1834
2210
|
type BetaToolUnion as BetaToolUnion,
|
|
1835
2211
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
1836
2212
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
@@ -1846,6 +2222,7 @@ export declare namespace Messages {
|
|
|
1846
2222
|
type BetaWebSearchToolResultBlockParam as BetaWebSearchToolResultBlockParam,
|
|
1847
2223
|
type BetaWebSearchToolResultBlockParamContent as BetaWebSearchToolResultBlockParamContent,
|
|
1848
2224
|
type BetaWebSearchToolResultError as BetaWebSearchToolResultError,
|
|
2225
|
+
type BetaWebSearchToolResultErrorCode as BetaWebSearchToolResultErrorCode,
|
|
1849
2226
|
type MessageCreateParams as MessageCreateParams,
|
|
1850
2227
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
1851
2228
|
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
|