@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
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as FilesAPI from './files';
|
|
5
|
+
import {
|
|
6
|
+
DeletedFile,
|
|
7
|
+
FileDeleteParams,
|
|
8
|
+
FileDownloadParams,
|
|
9
|
+
FileListParams,
|
|
10
|
+
FileMetadata,
|
|
11
|
+
FileMetadataPage,
|
|
12
|
+
FileRetrieveMetadataParams,
|
|
13
|
+
FileUploadParams,
|
|
14
|
+
Files,
|
|
15
|
+
} from './files';
|
|
4
16
|
import * as ModelsAPI from './models';
|
|
5
17
|
import { BetaModelInfo, BetaModelInfosPage, ModelListParams, ModelRetrieveParams, Models } from './models';
|
|
6
18
|
import * as MessagesAPI from './messages/messages';
|
|
@@ -9,6 +21,7 @@ import {
|
|
|
9
21
|
BetaBase64PDFBlock,
|
|
10
22
|
BetaBase64PDFSource,
|
|
11
23
|
BetaCacheControlEphemeral,
|
|
24
|
+
BetaCacheCreation,
|
|
12
25
|
BetaCitationCharLocation,
|
|
13
26
|
BetaCitationCharLocationParam,
|
|
14
27
|
BetaCitationContentBlockLocation,
|
|
@@ -19,12 +32,32 @@ import {
|
|
|
19
32
|
BetaCitationsConfigParam,
|
|
20
33
|
BetaCitationsDelta,
|
|
21
34
|
BetaCitationsWebSearchResultLocation,
|
|
35
|
+
BetaCodeExecutionOutputBlock,
|
|
36
|
+
BetaCodeExecutionOutputBlockParam,
|
|
37
|
+
BetaCodeExecutionResultBlock,
|
|
38
|
+
BetaCodeExecutionResultBlockParam,
|
|
39
|
+
BetaCodeExecutionTool20250522,
|
|
40
|
+
BetaCodeExecutionToolResultBlock,
|
|
41
|
+
BetaCodeExecutionToolResultBlockContent,
|
|
42
|
+
BetaCodeExecutionToolResultBlockParam,
|
|
43
|
+
BetaCodeExecutionToolResultBlockParamContent,
|
|
44
|
+
BetaCodeExecutionToolResultError,
|
|
45
|
+
BetaCodeExecutionToolResultErrorCode,
|
|
46
|
+
BetaCodeExecutionToolResultErrorParam,
|
|
47
|
+
BetaContainer,
|
|
48
|
+
BetaContainerUploadBlock,
|
|
49
|
+
BetaContainerUploadBlockParam,
|
|
22
50
|
BetaContentBlock,
|
|
23
51
|
BetaContentBlockParam,
|
|
24
52
|
BetaContentBlockSource,
|
|
25
53
|
BetaContentBlockSourceContent,
|
|
54
|
+
BetaFileDocumentSource,
|
|
55
|
+
BetaFileImageSource,
|
|
26
56
|
BetaImageBlockParam,
|
|
27
57
|
BetaInputJSONDelta,
|
|
58
|
+
BetaMCPToolResultBlock,
|
|
59
|
+
BetaMCPToolUseBlock,
|
|
60
|
+
BetaMCPToolUseBlockParam,
|
|
28
61
|
BetaMessage,
|
|
29
62
|
BetaMessageDeltaUsage,
|
|
30
63
|
BetaMessageParam,
|
|
@@ -41,6 +74,9 @@ import {
|
|
|
41
74
|
BetaRawMessageStreamEvent,
|
|
42
75
|
BetaRedactedThinkingBlock,
|
|
43
76
|
BetaRedactedThinkingBlockParam,
|
|
77
|
+
BetaRequestMCPServerToolConfiguration,
|
|
78
|
+
BetaRequestMCPServerURLDefinition,
|
|
79
|
+
BetaRequestMCPToolResultBlockParam,
|
|
44
80
|
BetaServerToolUsage,
|
|
45
81
|
BetaServerToolUseBlock,
|
|
46
82
|
BetaServerToolUseBlockParam,
|
|
@@ -70,6 +106,7 @@ import {
|
|
|
70
106
|
BetaToolResultBlockParam,
|
|
71
107
|
BetaToolTextEditor20241022,
|
|
72
108
|
BetaToolTextEditor20250124,
|
|
109
|
+
BetaToolTextEditor20250429,
|
|
73
110
|
BetaToolUnion,
|
|
74
111
|
BetaToolUseBlock,
|
|
75
112
|
BetaToolUseBlockParam,
|
|
@@ -85,6 +122,7 @@ import {
|
|
|
85
122
|
BetaWebSearchToolResultBlockParam,
|
|
86
123
|
BetaWebSearchToolResultBlockParamContent,
|
|
87
124
|
BetaWebSearchToolResultError,
|
|
125
|
+
BetaWebSearchToolResultErrorCode,
|
|
88
126
|
MessageCountTokensParams,
|
|
89
127
|
MessageCreateParams,
|
|
90
128
|
MessageCreateParamsNonStreaming,
|
|
@@ -95,6 +133,7 @@ import {
|
|
|
95
133
|
export class Beta extends APIResource {
|
|
96
134
|
models: ModelsAPI.Models = new ModelsAPI.Models(this._client);
|
|
97
135
|
messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
|
|
136
|
+
files: FilesAPI.Files = new FilesAPI.Files(this._client);
|
|
98
137
|
}
|
|
99
138
|
|
|
100
139
|
export type AnthropicBeta =
|
|
@@ -106,7 +145,13 @@ export type AnthropicBeta =
|
|
|
106
145
|
| 'pdfs-2024-09-25'
|
|
107
146
|
| 'token-counting-2024-11-01'
|
|
108
147
|
| 'token-efficient-tools-2025-02-19'
|
|
109
|
-
| 'output-128k-2025-02-19'
|
|
148
|
+
| 'output-128k-2025-02-19'
|
|
149
|
+
| 'files-api-2025-04-14'
|
|
150
|
+
| 'mcp-client-2025-04-04'
|
|
151
|
+
| 'dev-full-thinking-2025-05-14'
|
|
152
|
+
| 'interleaved-thinking-2025-05-14'
|
|
153
|
+
| 'code-execution-2025-05-22'
|
|
154
|
+
| 'extended-cache-ttl-2025-04-11';
|
|
110
155
|
|
|
111
156
|
export interface BetaAPIError {
|
|
112
157
|
message: string;
|
|
@@ -181,6 +226,7 @@ export interface BetaRateLimitError {
|
|
|
181
226
|
|
|
182
227
|
Beta.Models = Models;
|
|
183
228
|
Beta.Messages = Messages;
|
|
229
|
+
Beta.Files = Files;
|
|
184
230
|
|
|
185
231
|
export declare namespace Beta {
|
|
186
232
|
export {
|
|
@@ -212,6 +258,7 @@ export declare namespace Beta {
|
|
|
212
258
|
type BetaBase64PDFBlock as BetaBase64PDFBlock,
|
|
213
259
|
type BetaBase64PDFSource as BetaBase64PDFSource,
|
|
214
260
|
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
|
|
261
|
+
type BetaCacheCreation as BetaCacheCreation,
|
|
215
262
|
type BetaCitationCharLocation as BetaCitationCharLocation,
|
|
216
263
|
type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
|
|
217
264
|
type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
|
|
@@ -222,12 +269,32 @@ export declare namespace Beta {
|
|
|
222
269
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
223
270
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
224
271
|
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
|
|
272
|
+
type BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock,
|
|
273
|
+
type BetaCodeExecutionOutputBlockParam as BetaCodeExecutionOutputBlockParam,
|
|
274
|
+
type BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock,
|
|
275
|
+
type BetaCodeExecutionResultBlockParam as BetaCodeExecutionResultBlockParam,
|
|
276
|
+
type BetaCodeExecutionTool20250522 as BetaCodeExecutionTool20250522,
|
|
277
|
+
type BetaCodeExecutionToolResultBlock as BetaCodeExecutionToolResultBlock,
|
|
278
|
+
type BetaCodeExecutionToolResultBlockContent as BetaCodeExecutionToolResultBlockContent,
|
|
279
|
+
type BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
|
|
280
|
+
type BetaCodeExecutionToolResultBlockParamContent as BetaCodeExecutionToolResultBlockParamContent,
|
|
281
|
+
type BetaCodeExecutionToolResultError as BetaCodeExecutionToolResultError,
|
|
282
|
+
type BetaCodeExecutionToolResultErrorCode as BetaCodeExecutionToolResultErrorCode,
|
|
283
|
+
type BetaCodeExecutionToolResultErrorParam as BetaCodeExecutionToolResultErrorParam,
|
|
284
|
+
type BetaContainer as BetaContainer,
|
|
285
|
+
type BetaContainerUploadBlock as BetaContainerUploadBlock,
|
|
286
|
+
type BetaContainerUploadBlockParam as BetaContainerUploadBlockParam,
|
|
225
287
|
type BetaContentBlock as BetaContentBlock,
|
|
226
288
|
type BetaContentBlockParam as BetaContentBlockParam,
|
|
227
289
|
type BetaContentBlockSource as BetaContentBlockSource,
|
|
228
290
|
type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
|
|
291
|
+
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
292
|
+
type BetaFileImageSource as BetaFileImageSource,
|
|
229
293
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
230
294
|
type BetaInputJSONDelta as BetaInputJSONDelta,
|
|
295
|
+
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
|
|
296
|
+
type BetaMCPToolUseBlock as BetaMCPToolUseBlock,
|
|
297
|
+
type BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam,
|
|
231
298
|
type BetaMessage as BetaMessage,
|
|
232
299
|
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
|
|
233
300
|
type BetaMessageParam as BetaMessageParam,
|
|
@@ -244,6 +311,9 @@ export declare namespace Beta {
|
|
|
244
311
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
245
312
|
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
246
313
|
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
314
|
+
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
|
|
315
|
+
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
|
|
316
|
+
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
|
|
247
317
|
type BetaServerToolUsage as BetaServerToolUsage,
|
|
248
318
|
type BetaServerToolUseBlock as BetaServerToolUseBlock,
|
|
249
319
|
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
|
|
@@ -273,6 +343,7 @@ export declare namespace Beta {
|
|
|
273
343
|
type BetaToolResultBlockParam as BetaToolResultBlockParam,
|
|
274
344
|
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
|
|
275
345
|
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
|
|
346
|
+
type BetaToolTextEditor20250429 as BetaToolTextEditor20250429,
|
|
276
347
|
type BetaToolUnion as BetaToolUnion,
|
|
277
348
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
278
349
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
@@ -288,9 +359,22 @@ export declare namespace Beta {
|
|
|
288
359
|
type BetaWebSearchToolResultBlockParam as BetaWebSearchToolResultBlockParam,
|
|
289
360
|
type BetaWebSearchToolResultBlockParamContent as BetaWebSearchToolResultBlockParamContent,
|
|
290
361
|
type BetaWebSearchToolResultError as BetaWebSearchToolResultError,
|
|
362
|
+
type BetaWebSearchToolResultErrorCode as BetaWebSearchToolResultErrorCode,
|
|
291
363
|
type MessageCreateParams as MessageCreateParams,
|
|
292
364
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
293
365
|
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
|
|
294
366
|
type MessageCountTokensParams as MessageCountTokensParams,
|
|
295
367
|
};
|
|
368
|
+
|
|
369
|
+
export {
|
|
370
|
+
Files as Files,
|
|
371
|
+
type DeletedFile as DeletedFile,
|
|
372
|
+
type FileMetadata as FileMetadata,
|
|
373
|
+
type FileMetadataPage as FileMetadataPage,
|
|
374
|
+
type FileListParams as FileListParams,
|
|
375
|
+
type FileDeleteParams as FileDeleteParams,
|
|
376
|
+
type FileDownloadParams as FileDownloadParams,
|
|
377
|
+
type FileRetrieveMetadataParams as FileRetrieveMetadataParams,
|
|
378
|
+
type FileUploadParams as FileUploadParams,
|
|
379
|
+
};
|
|
296
380
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as BetaAPI from './beta';
|
|
5
|
+
import { APIPromise } from '../../core/api-promise';
|
|
6
|
+
import { Page, type PageParams, PagePromise } from '../../core/pagination';
|
|
7
|
+
import { type Uploadable } from '../../core/uploads';
|
|
8
|
+
import { buildHeaders } from '../../internal/headers';
|
|
9
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
10
|
+
import { multipartFormRequestOptions } from '../../internal/uploads';
|
|
11
|
+
import { path } from '../../internal/utils/path';
|
|
12
|
+
|
|
13
|
+
export class Files extends APIResource {
|
|
14
|
+
/**
|
|
15
|
+
* List Files
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Automatically fetches more pages as needed.
|
|
20
|
+
* for await (const fileMetadata of client.beta.files.list()) {
|
|
21
|
+
* // ...
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
list(
|
|
26
|
+
params: FileListParams | null | undefined = {},
|
|
27
|
+
options?: RequestOptions,
|
|
28
|
+
): PagePromise<FileMetadataPage, FileMetadata> {
|
|
29
|
+
const { betas, ...query } = params ?? {};
|
|
30
|
+
return this._client.getAPIList('/v1/files', Page<FileMetadata>, {
|
|
31
|
+
query,
|
|
32
|
+
...options,
|
|
33
|
+
headers: buildHeaders([
|
|
34
|
+
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
|
|
35
|
+
options?.headers,
|
|
36
|
+
]),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Delete File
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const deletedFile = await client.beta.files.delete(
|
|
46
|
+
* 'file_id',
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
delete(
|
|
51
|
+
fileID: string,
|
|
52
|
+
params: FileDeleteParams | null | undefined = {},
|
|
53
|
+
options?: RequestOptions,
|
|
54
|
+
): APIPromise<DeletedFile> {
|
|
55
|
+
const { betas } = params ?? {};
|
|
56
|
+
return this._client.delete(path`/v1/files/${fileID}`, {
|
|
57
|
+
...options,
|
|
58
|
+
headers: buildHeaders([
|
|
59
|
+
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
|
|
60
|
+
options?.headers,
|
|
61
|
+
]),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Download File
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const response = await client.beta.files.download(
|
|
71
|
+
* 'file_id',
|
|
72
|
+
* );
|
|
73
|
+
*
|
|
74
|
+
* const content = await response.blob();
|
|
75
|
+
* console.log(content);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
download(
|
|
79
|
+
fileID: string,
|
|
80
|
+
params: FileDownloadParams | null | undefined = {},
|
|
81
|
+
options?: RequestOptions,
|
|
82
|
+
): APIPromise<Response> {
|
|
83
|
+
const { betas } = params ?? {};
|
|
84
|
+
return this._client.get(path`/v1/files/${fileID}/content`, {
|
|
85
|
+
...options,
|
|
86
|
+
headers: buildHeaders([
|
|
87
|
+
{
|
|
88
|
+
'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString(),
|
|
89
|
+
Accept: 'application/binary',
|
|
90
|
+
},
|
|
91
|
+
options?.headers,
|
|
92
|
+
]),
|
|
93
|
+
__binaryResponse: true,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get File Metadata
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const fileMetadata =
|
|
103
|
+
* await client.beta.files.retrieveMetadata('file_id');
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
retrieveMetadata(
|
|
107
|
+
fileID: string,
|
|
108
|
+
params: FileRetrieveMetadataParams | null | undefined = {},
|
|
109
|
+
options?: RequestOptions,
|
|
110
|
+
): APIPromise<FileMetadata> {
|
|
111
|
+
const { betas } = params ?? {};
|
|
112
|
+
return this._client.get(path`/v1/files/${fileID}`, {
|
|
113
|
+
...options,
|
|
114
|
+
headers: buildHeaders([
|
|
115
|
+
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
|
|
116
|
+
options?.headers,
|
|
117
|
+
]),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Upload File
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const fileMetadata = await client.beta.files.upload({
|
|
127
|
+
* file: fs.createReadStream('path/to/file'),
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
upload(params: FileUploadParams, options?: RequestOptions): APIPromise<FileMetadata> {
|
|
132
|
+
const { betas, ...body } = params;
|
|
133
|
+
return this._client.post(
|
|
134
|
+
'/v1/files',
|
|
135
|
+
multipartFormRequestOptions(
|
|
136
|
+
{
|
|
137
|
+
body,
|
|
138
|
+
...options,
|
|
139
|
+
headers: buildHeaders([
|
|
140
|
+
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
|
|
141
|
+
options?.headers,
|
|
142
|
+
]),
|
|
143
|
+
},
|
|
144
|
+
this._client,
|
|
145
|
+
),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type FileMetadataPage = Page<FileMetadata>;
|
|
151
|
+
|
|
152
|
+
export interface DeletedFile {
|
|
153
|
+
/**
|
|
154
|
+
* ID of the deleted file.
|
|
155
|
+
*/
|
|
156
|
+
id: string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Deleted object type.
|
|
160
|
+
*
|
|
161
|
+
* For file deletion, this is always `"file_deleted"`.
|
|
162
|
+
*/
|
|
163
|
+
type?: 'file_deleted';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface FileMetadata {
|
|
167
|
+
/**
|
|
168
|
+
* Unique object identifier.
|
|
169
|
+
*
|
|
170
|
+
* The format and length of IDs may change over time.
|
|
171
|
+
*/
|
|
172
|
+
id: string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* RFC 3339 datetime string representing when the file was created.
|
|
176
|
+
*/
|
|
177
|
+
created_at: string;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Original filename of the uploaded file.
|
|
181
|
+
*/
|
|
182
|
+
filename: string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* MIME type of the file.
|
|
186
|
+
*/
|
|
187
|
+
mime_type: string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Size of the file in bytes.
|
|
191
|
+
*/
|
|
192
|
+
size_bytes: number;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Object type.
|
|
196
|
+
*
|
|
197
|
+
* For files, this is always `"file"`.
|
|
198
|
+
*/
|
|
199
|
+
type: 'file';
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Whether the file can be downloaded.
|
|
203
|
+
*/
|
|
204
|
+
downloadable?: boolean;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface FileListParams extends PageParams {
|
|
208
|
+
/**
|
|
209
|
+
* Header param: Optional header to specify the beta version(s) you want to use.
|
|
210
|
+
*/
|
|
211
|
+
betas?: Array<BetaAPI.AnthropicBeta>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface FileDeleteParams {
|
|
215
|
+
/**
|
|
216
|
+
* Optional header to specify the beta version(s) you want to use.
|
|
217
|
+
*/
|
|
218
|
+
betas?: Array<BetaAPI.AnthropicBeta>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface FileDownloadParams {
|
|
222
|
+
/**
|
|
223
|
+
* Optional header to specify the beta version(s) you want to use.
|
|
224
|
+
*/
|
|
225
|
+
betas?: Array<BetaAPI.AnthropicBeta>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface FileRetrieveMetadataParams {
|
|
229
|
+
/**
|
|
230
|
+
* Optional header to specify the beta version(s) you want to use.
|
|
231
|
+
*/
|
|
232
|
+
betas?: Array<BetaAPI.AnthropicBeta>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface FileUploadParams {
|
|
236
|
+
/**
|
|
237
|
+
* Body param: The file to upload
|
|
238
|
+
*/
|
|
239
|
+
file: Uploadable;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Header param: Optional header to specify the beta version(s) you want to use.
|
|
243
|
+
*/
|
|
244
|
+
betas?: Array<BetaAPI.AnthropicBeta>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export declare namespace Files {
|
|
248
|
+
export {
|
|
249
|
+
type DeletedFile as DeletedFile,
|
|
250
|
+
type FileMetadata as FileMetadata,
|
|
251
|
+
type FileMetadataPage as FileMetadataPage,
|
|
252
|
+
type FileListParams as FileListParams,
|
|
253
|
+
type FileDeleteParams as FileDeleteParams,
|
|
254
|
+
type FileDownloadParams as FileDownloadParams,
|
|
255
|
+
type FileRetrieveMetadataParams as FileRetrieveMetadataParams,
|
|
256
|
+
type FileUploadParams as FileUploadParams,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -15,12 +15,24 @@ export {
|
|
|
15
15
|
type BetaPermissionError,
|
|
16
16
|
type BetaRateLimitError,
|
|
17
17
|
} from './beta';
|
|
18
|
+
export {
|
|
19
|
+
Files,
|
|
20
|
+
type DeletedFile,
|
|
21
|
+
type FileMetadata,
|
|
22
|
+
type FileListParams,
|
|
23
|
+
type FileDeleteParams,
|
|
24
|
+
type FileDownloadParams,
|
|
25
|
+
type FileRetrieveMetadataParams,
|
|
26
|
+
type FileUploadParams,
|
|
27
|
+
type FileMetadataPage,
|
|
28
|
+
} from './files';
|
|
18
29
|
export {
|
|
19
30
|
Messages,
|
|
20
31
|
type BetaBase64ImageSource,
|
|
21
32
|
type BetaBase64PDFBlock,
|
|
22
33
|
type BetaBase64PDFSource,
|
|
23
34
|
type BetaCacheControlEphemeral,
|
|
35
|
+
type BetaCacheCreation,
|
|
24
36
|
type BetaCitationCharLocation,
|
|
25
37
|
type BetaCitationCharLocationParam,
|
|
26
38
|
type BetaCitationContentBlockLocation,
|
|
@@ -31,12 +43,32 @@ export {
|
|
|
31
43
|
type BetaCitationsConfigParam,
|
|
32
44
|
type BetaCitationsDelta,
|
|
33
45
|
type BetaCitationsWebSearchResultLocation,
|
|
46
|
+
type BetaCodeExecutionOutputBlock,
|
|
47
|
+
type BetaCodeExecutionOutputBlockParam,
|
|
48
|
+
type BetaCodeExecutionResultBlock,
|
|
49
|
+
type BetaCodeExecutionResultBlockParam,
|
|
50
|
+
type BetaCodeExecutionTool20250522,
|
|
51
|
+
type BetaCodeExecutionToolResultBlock,
|
|
52
|
+
type BetaCodeExecutionToolResultBlockContent,
|
|
53
|
+
type BetaCodeExecutionToolResultBlockParam,
|
|
54
|
+
type BetaCodeExecutionToolResultBlockParamContent,
|
|
55
|
+
type BetaCodeExecutionToolResultError,
|
|
56
|
+
type BetaCodeExecutionToolResultErrorCode,
|
|
57
|
+
type BetaCodeExecutionToolResultErrorParam,
|
|
58
|
+
type BetaContainer,
|
|
59
|
+
type BetaContainerUploadBlock,
|
|
60
|
+
type BetaContainerUploadBlockParam,
|
|
34
61
|
type BetaContentBlock,
|
|
35
62
|
type BetaContentBlockParam,
|
|
36
63
|
type BetaContentBlockSource,
|
|
37
64
|
type BetaContentBlockSourceContent,
|
|
65
|
+
type BetaFileDocumentSource,
|
|
66
|
+
type BetaFileImageSource,
|
|
38
67
|
type BetaImageBlockParam,
|
|
39
68
|
type BetaInputJSONDelta,
|
|
69
|
+
type BetaMCPToolResultBlock,
|
|
70
|
+
type BetaMCPToolUseBlock,
|
|
71
|
+
type BetaMCPToolUseBlockParam,
|
|
40
72
|
type BetaMessage,
|
|
41
73
|
type BetaMessageDeltaUsage,
|
|
42
74
|
type BetaMessageParam,
|
|
@@ -53,6 +85,9 @@ export {
|
|
|
53
85
|
type BetaRawMessageStreamEvent,
|
|
54
86
|
type BetaRedactedThinkingBlock,
|
|
55
87
|
type BetaRedactedThinkingBlockParam,
|
|
88
|
+
type BetaRequestMCPServerToolConfiguration,
|
|
89
|
+
type BetaRequestMCPServerURLDefinition,
|
|
90
|
+
type BetaRequestMCPToolResultBlockParam,
|
|
56
91
|
type BetaServerToolUsage,
|
|
57
92
|
type BetaServerToolUseBlock,
|
|
58
93
|
type BetaServerToolUseBlockParam,
|
|
@@ -82,6 +117,7 @@ export {
|
|
|
82
117
|
type BetaToolResultBlockParam,
|
|
83
118
|
type BetaToolTextEditor20241022,
|
|
84
119
|
type BetaToolTextEditor20250124,
|
|
120
|
+
type BetaToolTextEditor20250429,
|
|
85
121
|
type BetaToolUnion,
|
|
86
122
|
type BetaToolUseBlock,
|
|
87
123
|
type BetaToolUseBlockParam,
|
|
@@ -97,6 +133,7 @@ export {
|
|
|
97
133
|
type BetaWebSearchToolResultBlockParam,
|
|
98
134
|
type BetaWebSearchToolResultBlockParamContent,
|
|
99
135
|
type BetaWebSearchToolResultError,
|
|
136
|
+
type BetaWebSearchToolResultErrorCode,
|
|
100
137
|
type MessageCreateParams,
|
|
101
138
|
type MessageCreateParamsNonStreaming,
|
|
102
139
|
type MessageCreateParamsStreaming,
|
|
@@ -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,
|