@anthropic-ai/sdk 0.40.0 → 0.41.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 +27 -0
- package/README.md +3 -3
- package/index.d.mts +4 -4
- package/index.d.ts +4 -4
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +7 -0
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +7 -0
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +7 -0
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +7 -0
- package/lib/MessageStream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/beta.d.ts +4 -4
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/messages/batches.d.ts +59 -0
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/batches.js +19 -0
- package/resources/beta/messages/batches.js.map +1 -1
- package/resources/beta/messages/batches.mjs +19 -0
- package/resources/beta/messages/batches.mjs.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.ts +228 -17
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +9 -0
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +9 -0
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/models.d.ts +29 -2
- package/resources/beta/models.d.ts.map +1 -1
- package/resources/beta/models.js +24 -12
- package/resources/beta/models.js.map +1 -1
- package/resources/beta/models.mjs +24 -12
- package/resources/beta/models.mjs.map +1 -1
- package/resources/completions.d.ts +31 -14
- package/resources/completions.d.ts.map +1 -1
- package/resources/completions.js +7 -2
- package/resources/completions.js.map +1 -1
- package/resources/completions.mjs +7 -2
- package/resources/completions.mjs.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/batches.d.ts +52 -0
- package/resources/messages/batches.d.ts.map +1 -1
- package/resources/messages/batches.js +44 -0
- package/resources/messages/batches.js.map +1 -1
- package/resources/messages/batches.mjs +44 -0
- package/resources/messages/batches.mjs.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.ts +213 -13
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +9 -0
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +9 -0
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/models.d.ts +14 -2
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +24 -12
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +24 -12
- package/resources/models.mjs.map +1 -1
- package/src/index.ts +30 -1
- package/src/lib/BetaMessageStream.ts +9 -0
- package/src/lib/MessageStream.ts +9 -0
- package/src/resources/beta/beta.ts +30 -1
- package/src/resources/beta/index.ts +21 -1
- package/src/resources/beta/messages/batches.ts +59 -0
- package/src/resources/beta/messages/index.ts +14 -0
- package/src/resources/beta/messages/messages.ts +336 -13
- package/src/resources/beta/models.ts +65 -8
- package/src/resources/completions.ts +39 -16
- package/src/resources/index.ts +21 -1
- package/src/resources/messages/batches.ts +52 -0
- package/src/resources/messages/index.ts +14 -0
- package/src/resources/messages/messages.ts +321 -11
- package/src/resources/models.ts +50 -8
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/models.js
CHANGED
|
@@ -6,20 +6,32 @@ const resource_1 = require("../resource.js");
|
|
|
6
6
|
const core_1 = require("../core.js");
|
|
7
7
|
const pagination_1 = require("../pagination.js");
|
|
8
8
|
class Models extends resource_1.APIResource {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
retrieve(modelId, params = {}, options) {
|
|
10
|
+
if ((0, core_1.isRequestOptions)(params)) {
|
|
11
|
+
return this.retrieve(modelId, {}, params);
|
|
12
|
+
}
|
|
13
|
+
const { betas } = params;
|
|
14
|
+
return this._client.get(`/v1/models/${modelId}`, {
|
|
15
|
+
...options,
|
|
16
|
+
headers: {
|
|
17
|
+
...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
|
|
18
|
+
...options?.headers,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
17
21
|
}
|
|
18
|
-
list(
|
|
19
|
-
if ((0, core_1.isRequestOptions)(
|
|
20
|
-
return this.list({},
|
|
22
|
+
list(params = {}, options) {
|
|
23
|
+
if ((0, core_1.isRequestOptions)(params)) {
|
|
24
|
+
return this.list({}, params);
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
const { betas, ...query } = params;
|
|
27
|
+
return this._client.getAPIList('/v1/models', ModelInfosPage, {
|
|
28
|
+
query,
|
|
29
|
+
...options,
|
|
30
|
+
headers: {
|
|
31
|
+
...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
|
|
32
|
+
...options?.headers,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
exports.Models = Models;
|
package/resources/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/resources/models.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAC1C,qCAA2C;
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/resources/models.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAC1C,qCAA2C;AAG3C,iDAAsD;AAEtD,MAAa,MAAO,SAAQ,sBAAW;IAarC,QAAQ,CACN,OAAe,EACf,SAAoD,EAAE,EACtD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;SAC3C;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,EAAE,EAAE;YAC/C,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpF,GAAG,OAAO,EAAE,OAAO;aACpB;SACF,CAAC,CAAC;IACL,CAAC;IAUD,IAAI,CACF,SAAgD,EAAE,EAClD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;SAC9B;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE;YAC3D,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpF,GAAG,OAAO,EAAE,OAAO;aACpB;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAxDD,wBAwDC;AAED,MAAa,cAAe,SAAQ,iBAAe;CAAG;AAAtD,wCAAsD;AAyCtD,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC"}
|
package/resources/models.mjs
CHANGED
|
@@ -3,20 +3,32 @@ import { APIResource } from "../resource.mjs";
|
|
|
3
3
|
import { isRequestOptions } from "../core.mjs";
|
|
4
4
|
import { Page } from "../pagination.mjs";
|
|
5
5
|
export class Models extends APIResource {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
retrieve(modelId, params = {}, options) {
|
|
7
|
+
if (isRequestOptions(params)) {
|
|
8
|
+
return this.retrieve(modelId, {}, params);
|
|
9
|
+
}
|
|
10
|
+
const { betas } = params;
|
|
11
|
+
return this._client.get(`/v1/models/${modelId}`, {
|
|
12
|
+
...options,
|
|
13
|
+
headers: {
|
|
14
|
+
...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
|
|
15
|
+
...options?.headers,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
14
18
|
}
|
|
15
|
-
list(
|
|
16
|
-
if (isRequestOptions(
|
|
17
|
-
return this.list({},
|
|
19
|
+
list(params = {}, options) {
|
|
20
|
+
if (isRequestOptions(params)) {
|
|
21
|
+
return this.list({}, params);
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
const { betas, ...query } = params;
|
|
24
|
+
return this._client.getAPIList('/v1/models', ModelInfosPage, {
|
|
25
|
+
query,
|
|
26
|
+
...options,
|
|
27
|
+
headers: {
|
|
28
|
+
...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
|
|
29
|
+
...options?.headers,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
20
32
|
}
|
|
21
33
|
}
|
|
22
34
|
export class ModelInfosPage extends Page {
|
package/resources/models.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.mjs","sourceRoot":"","sources":["../src/resources/models.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;
|
|
1
|
+
{"version":3,"file":"models.mjs","sourceRoot":"","sources":["../src/resources/models.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;OAGpB,EAAE,IAAI,EAAmB;AAEhC,MAAM,OAAO,MAAO,SAAQ,WAAW;IAarC,QAAQ,CACN,OAAe,EACf,SAAoD,EAAE,EACtD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;SAC3C;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,EAAE,EAAE;YAC/C,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpF,GAAG,OAAO,EAAE,OAAO;aACpB;SACF,CAAC,CAAC;IACL,CAAC;IAUD,IAAI,CACF,SAAgD,EAAE,EAClD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;SAC9B;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE;YAC3D,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpF,GAAG,OAAO,EAAE,OAAO;aACpB;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,IAAe;CAAG;AAyCtD,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC"}
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
CompletionCreateParamsStreaming,
|
|
15
15
|
Completions,
|
|
16
16
|
} from "./resources/completions.js";
|
|
17
|
-
import { ModelInfo, ModelInfosPage, ModelListParams, Models } from "./resources/models.js";
|
|
17
|
+
import { ModelInfo, ModelInfosPage, ModelListParams, ModelRetrieveParams, Models } from "./resources/models.js";
|
|
18
18
|
import {
|
|
19
19
|
AnthropicBeta,
|
|
20
20
|
Beta,
|
|
@@ -40,8 +40,10 @@ import {
|
|
|
40
40
|
CitationContentBlockLocationParam,
|
|
41
41
|
CitationPageLocation,
|
|
42
42
|
CitationPageLocationParam,
|
|
43
|
+
CitationWebSearchResultLocationParam,
|
|
43
44
|
CitationsConfigParam,
|
|
44
45
|
CitationsDelta,
|
|
46
|
+
CitationsWebSearchResultLocation,
|
|
45
47
|
ContentBlock,
|
|
46
48
|
ContentBlockDeltaEvent,
|
|
47
49
|
ContentBlockParam,
|
|
@@ -80,6 +82,9 @@ import {
|
|
|
80
82
|
RawMessageStreamEvent,
|
|
81
83
|
RedactedThinkingBlock,
|
|
82
84
|
RedactedThinkingBlockParam,
|
|
85
|
+
ServerToolUsage,
|
|
86
|
+
ServerToolUseBlock,
|
|
87
|
+
ServerToolUseBlockParam,
|
|
83
88
|
SignatureDelta,
|
|
84
89
|
StopReason,
|
|
85
90
|
TextBlock,
|
|
@@ -108,6 +113,15 @@ import {
|
|
|
108
113
|
URLImageSource,
|
|
109
114
|
URLPDFSource,
|
|
110
115
|
Usage,
|
|
116
|
+
WebSearchResultBlock,
|
|
117
|
+
WebSearchResultBlockParam,
|
|
118
|
+
WebSearchTool20250305,
|
|
119
|
+
WebSearchToolRequestError,
|
|
120
|
+
WebSearchToolResultBlock,
|
|
121
|
+
WebSearchToolResultBlockContent,
|
|
122
|
+
WebSearchToolResultBlockParam,
|
|
123
|
+
WebSearchToolResultBlockParamContent,
|
|
124
|
+
WebSearchToolResultError,
|
|
111
125
|
} from "./resources/messages/messages.js";
|
|
112
126
|
|
|
113
127
|
export interface ClientOptions {
|
|
@@ -354,8 +368,10 @@ export declare namespace Anthropic {
|
|
|
354
368
|
type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
|
|
355
369
|
type CitationPageLocation as CitationPageLocation,
|
|
356
370
|
type CitationPageLocationParam as CitationPageLocationParam,
|
|
371
|
+
type CitationWebSearchResultLocationParam as CitationWebSearchResultLocationParam,
|
|
357
372
|
type CitationsConfigParam as CitationsConfigParam,
|
|
358
373
|
type CitationsDelta as CitationsDelta,
|
|
374
|
+
type CitationsWebSearchResultLocation as CitationsWebSearchResultLocation,
|
|
359
375
|
type ContentBlock as ContentBlock,
|
|
360
376
|
type ContentBlockParam as ContentBlockParam,
|
|
361
377
|
type ContentBlockSource as ContentBlockSource,
|
|
@@ -381,6 +397,9 @@ export declare namespace Anthropic {
|
|
|
381
397
|
type RawMessageStreamEvent as RawMessageStreamEvent,
|
|
382
398
|
type RedactedThinkingBlock as RedactedThinkingBlock,
|
|
383
399
|
type RedactedThinkingBlockParam as RedactedThinkingBlockParam,
|
|
400
|
+
type ServerToolUsage as ServerToolUsage,
|
|
401
|
+
type ServerToolUseBlock as ServerToolUseBlock,
|
|
402
|
+
type ServerToolUseBlockParam as ServerToolUseBlockParam,
|
|
384
403
|
type SignatureDelta as SignatureDelta,
|
|
385
404
|
type StopReason as StopReason,
|
|
386
405
|
type TextBlock as TextBlock,
|
|
@@ -409,6 +428,15 @@ export declare namespace Anthropic {
|
|
|
409
428
|
type URLImageSource as URLImageSource,
|
|
410
429
|
type URLPDFSource as URLPDFSource,
|
|
411
430
|
type Usage as Usage,
|
|
431
|
+
type WebSearchResultBlock as WebSearchResultBlock,
|
|
432
|
+
type WebSearchResultBlockParam as WebSearchResultBlockParam,
|
|
433
|
+
type WebSearchTool20250305 as WebSearchTool20250305,
|
|
434
|
+
type WebSearchToolRequestError as WebSearchToolRequestError,
|
|
435
|
+
type WebSearchToolResultBlock as WebSearchToolResultBlock,
|
|
436
|
+
type WebSearchToolResultBlockContent as WebSearchToolResultBlockContent,
|
|
437
|
+
type WebSearchToolResultBlockParam as WebSearchToolResultBlockParam,
|
|
438
|
+
type WebSearchToolResultBlockParamContent as WebSearchToolResultBlockParamContent,
|
|
439
|
+
type WebSearchToolResultError as WebSearchToolResultError,
|
|
412
440
|
type MessageStreamEvent as MessageStreamEvent,
|
|
413
441
|
type MessageStartEvent as MessageStartEvent,
|
|
414
442
|
type MessageDeltaEvent as MessageDeltaEvent,
|
|
@@ -427,6 +455,7 @@ export declare namespace Anthropic {
|
|
|
427
455
|
Models as Models,
|
|
428
456
|
type ModelInfo as ModelInfo,
|
|
429
457
|
ModelInfosPage as ModelInfosPage,
|
|
458
|
+
type ModelRetrieveParams as ModelRetrieveParams,
|
|
430
459
|
type ModelListParams as ModelListParams,
|
|
431
460
|
};
|
|
432
461
|
|
|
@@ -530,6 +530,15 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
530
530
|
snapshot.stop_reason = event.delta.stop_reason;
|
|
531
531
|
snapshot.stop_sequence = event.delta.stop_sequence;
|
|
532
532
|
snapshot.usage.output_tokens = event.usage.output_tokens;
|
|
533
|
+
|
|
534
|
+
// Update other usage fields if they exist in the event
|
|
535
|
+
if (event.usage.input_tokens) {
|
|
536
|
+
snapshot.usage.input_tokens = event.usage.input_tokens;
|
|
537
|
+
}
|
|
538
|
+
snapshot.usage.cache_creation_input_tokens = event.usage.cache_creation_input_tokens;
|
|
539
|
+
snapshot.usage.cache_read_input_tokens = event.usage.cache_read_input_tokens;
|
|
540
|
+
snapshot.usage.server_tool_use = event.usage.server_tool_use;
|
|
541
|
+
|
|
533
542
|
return snapshot;
|
|
534
543
|
case 'content_block_start':
|
|
535
544
|
snapshot.content.push(event.content_block);
|
package/src/lib/MessageStream.ts
CHANGED
|
@@ -530,6 +530,15 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
|
|
|
530
530
|
snapshot.stop_reason = event.delta.stop_reason;
|
|
531
531
|
snapshot.stop_sequence = event.delta.stop_sequence;
|
|
532
532
|
snapshot.usage.output_tokens = event.usage.output_tokens;
|
|
533
|
+
|
|
534
|
+
// Update other usage fields if they exist in the event
|
|
535
|
+
if (event.usage.input_tokens) {
|
|
536
|
+
snapshot.usage.input_tokens = event.usage.input_tokens;
|
|
537
|
+
}
|
|
538
|
+
snapshot.usage.cache_creation_input_tokens = event.usage.cache_creation_input_tokens;
|
|
539
|
+
snapshot.usage.cache_read_input_tokens = event.usage.cache_read_input_tokens;
|
|
540
|
+
snapshot.usage.server_tool_use = event.usage.server_tool_use;
|
|
541
|
+
|
|
533
542
|
return snapshot;
|
|
534
543
|
case 'content_block_start':
|
|
535
544
|
snapshot.content.push(event.content_block);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from "../../resource.js";
|
|
4
4
|
import * as ModelsAPI from "./models.js";
|
|
5
|
-
import { BetaModelInfo, BetaModelInfosPage, ModelListParams, Models } from "./models.js";
|
|
5
|
+
import { BetaModelInfo, BetaModelInfosPage, ModelListParams, ModelRetrieveParams, Models } from "./models.js";
|
|
6
6
|
import * as MessagesAPI from "./messages/messages.js";
|
|
7
7
|
import {
|
|
8
8
|
BetaBase64ImageSource,
|
|
@@ -15,8 +15,10 @@ import {
|
|
|
15
15
|
BetaCitationContentBlockLocationParam,
|
|
16
16
|
BetaCitationPageLocation,
|
|
17
17
|
BetaCitationPageLocationParam,
|
|
18
|
+
BetaCitationWebSearchResultLocationParam,
|
|
18
19
|
BetaCitationsConfigParam,
|
|
19
20
|
BetaCitationsDelta,
|
|
21
|
+
BetaCitationsWebSearchResultLocation,
|
|
20
22
|
BetaContentBlock,
|
|
21
23
|
BetaContentBlockParam,
|
|
22
24
|
BetaContentBlockSource,
|
|
@@ -39,6 +41,9 @@ import {
|
|
|
39
41
|
BetaRawMessageStreamEvent,
|
|
40
42
|
BetaRedactedThinkingBlock,
|
|
41
43
|
BetaRedactedThinkingBlockParam,
|
|
44
|
+
BetaServerToolUsage,
|
|
45
|
+
BetaServerToolUseBlock,
|
|
46
|
+
BetaServerToolUseBlockParam,
|
|
42
47
|
BetaSignatureDelta,
|
|
43
48
|
BetaStopReason,
|
|
44
49
|
BetaTextBlock,
|
|
@@ -71,6 +76,15 @@ import {
|
|
|
71
76
|
BetaURLImageSource,
|
|
72
77
|
BetaURLPDFSource,
|
|
73
78
|
BetaUsage,
|
|
79
|
+
BetaWebSearchResultBlock,
|
|
80
|
+
BetaWebSearchResultBlockParam,
|
|
81
|
+
BetaWebSearchTool20250305,
|
|
82
|
+
BetaWebSearchToolRequestError,
|
|
83
|
+
BetaWebSearchToolResultBlock,
|
|
84
|
+
BetaWebSearchToolResultBlockContent,
|
|
85
|
+
BetaWebSearchToolResultBlockParam,
|
|
86
|
+
BetaWebSearchToolResultBlockParamContent,
|
|
87
|
+
BetaWebSearchToolResultError,
|
|
74
88
|
MessageCountTokensParams,
|
|
75
89
|
MessageCreateParams,
|
|
76
90
|
MessageCreateParamsNonStreaming,
|
|
@@ -189,6 +203,7 @@ export declare namespace Beta {
|
|
|
189
203
|
Models as Models,
|
|
190
204
|
type BetaModelInfo as BetaModelInfo,
|
|
191
205
|
BetaModelInfosPage as BetaModelInfosPage,
|
|
206
|
+
type ModelRetrieveParams as ModelRetrieveParams,
|
|
192
207
|
type ModelListParams as ModelListParams,
|
|
193
208
|
};
|
|
194
209
|
|
|
@@ -204,8 +219,10 @@ export declare namespace Beta {
|
|
|
204
219
|
type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
|
|
205
220
|
type BetaCitationPageLocation as BetaCitationPageLocation,
|
|
206
221
|
type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
|
|
222
|
+
type BetaCitationWebSearchResultLocationParam as BetaCitationWebSearchResultLocationParam,
|
|
207
223
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
208
224
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
225
|
+
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
|
|
209
226
|
type BetaContentBlock as BetaContentBlock,
|
|
210
227
|
type BetaContentBlockParam as BetaContentBlockParam,
|
|
211
228
|
type BetaContentBlockSource as BetaContentBlockSource,
|
|
@@ -228,6 +245,9 @@ export declare namespace Beta {
|
|
|
228
245
|
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
|
|
229
246
|
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
|
|
230
247
|
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
|
|
248
|
+
type BetaServerToolUsage as BetaServerToolUsage,
|
|
249
|
+
type BetaServerToolUseBlock as BetaServerToolUseBlock,
|
|
250
|
+
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
|
|
231
251
|
type BetaSignatureDelta as BetaSignatureDelta,
|
|
232
252
|
type BetaStopReason as BetaStopReason,
|
|
233
253
|
type BetaTextBlock as BetaTextBlock,
|
|
@@ -260,6 +280,15 @@ export declare namespace Beta {
|
|
|
260
280
|
type BetaURLImageSource as BetaURLImageSource,
|
|
261
281
|
type BetaURLPDFSource as BetaURLPDFSource,
|
|
262
282
|
type BetaUsage as BetaUsage,
|
|
283
|
+
type BetaWebSearchResultBlock as BetaWebSearchResultBlock,
|
|
284
|
+
type BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam,
|
|
285
|
+
type BetaWebSearchTool20250305 as BetaWebSearchTool20250305,
|
|
286
|
+
type BetaWebSearchToolRequestError as BetaWebSearchToolRequestError,
|
|
287
|
+
type BetaWebSearchToolResultBlock as BetaWebSearchToolResultBlock,
|
|
288
|
+
type BetaWebSearchToolResultBlockContent as BetaWebSearchToolResultBlockContent,
|
|
289
|
+
type BetaWebSearchToolResultBlockParam as BetaWebSearchToolResultBlockParam,
|
|
290
|
+
type BetaWebSearchToolResultBlockParamContent as BetaWebSearchToolResultBlockParamContent,
|
|
291
|
+
type BetaWebSearchToolResultError as BetaWebSearchToolResultError,
|
|
263
292
|
type MessageCreateParams as MessageCreateParams,
|
|
264
293
|
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
|
|
265
294
|
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
|
|
@@ -15,7 +15,13 @@ export {
|
|
|
15
15
|
type BetaPermissionError,
|
|
16
16
|
type BetaRateLimitError,
|
|
17
17
|
} from "./beta.js";
|
|
18
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
BetaModelInfosPage,
|
|
20
|
+
Models,
|
|
21
|
+
type BetaModelInfo,
|
|
22
|
+
type ModelRetrieveParams,
|
|
23
|
+
type ModelListParams,
|
|
24
|
+
} from "./models.js";
|
|
19
25
|
export {
|
|
20
26
|
Messages,
|
|
21
27
|
type BetaBase64ImageSource,
|
|
@@ -28,8 +34,10 @@ export {
|
|
|
28
34
|
type BetaCitationContentBlockLocationParam,
|
|
29
35
|
type BetaCitationPageLocation,
|
|
30
36
|
type BetaCitationPageLocationParam,
|
|
37
|
+
type BetaCitationWebSearchResultLocationParam,
|
|
31
38
|
type BetaCitationsConfigParam,
|
|
32
39
|
type BetaCitationsDelta,
|
|
40
|
+
type BetaCitationsWebSearchResultLocation,
|
|
33
41
|
type BetaContentBlock,
|
|
34
42
|
type BetaContentBlockParam,
|
|
35
43
|
type BetaContentBlockSource,
|
|
@@ -52,6 +60,9 @@ export {
|
|
|
52
60
|
type BetaRawMessageStreamEvent,
|
|
53
61
|
type BetaRedactedThinkingBlock,
|
|
54
62
|
type BetaRedactedThinkingBlockParam,
|
|
63
|
+
type BetaServerToolUsage,
|
|
64
|
+
type BetaServerToolUseBlock,
|
|
65
|
+
type BetaServerToolUseBlockParam,
|
|
55
66
|
type BetaSignatureDelta,
|
|
56
67
|
type BetaStopReason,
|
|
57
68
|
type BetaTextBlock,
|
|
@@ -84,6 +95,15 @@ export {
|
|
|
84
95
|
type BetaURLImageSource,
|
|
85
96
|
type BetaURLPDFSource,
|
|
86
97
|
type BetaUsage,
|
|
98
|
+
type BetaWebSearchResultBlock,
|
|
99
|
+
type BetaWebSearchResultBlockParam,
|
|
100
|
+
type BetaWebSearchTool20250305,
|
|
101
|
+
type BetaWebSearchToolRequestError,
|
|
102
|
+
type BetaWebSearchToolResultBlock,
|
|
103
|
+
type BetaWebSearchToolResultBlockContent,
|
|
104
|
+
type BetaWebSearchToolResultBlockParam,
|
|
105
|
+
type BetaWebSearchToolResultBlockParamContent,
|
|
106
|
+
type BetaWebSearchToolResultError,
|
|
87
107
|
type MessageCreateParams,
|
|
88
108
|
type MessageCreateParamsNonStreaming,
|
|
89
109
|
type MessageCreateParamsStreaming,
|
|
@@ -20,6 +20,25 @@ export class Batches extends APIResource {
|
|
|
20
20
|
*
|
|
21
21
|
* Learn more about the Message Batches API in our
|
|
22
22
|
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const betaMessageBatch =
|
|
27
|
+
* await client.beta.messages.batches.create({
|
|
28
|
+
* requests: [
|
|
29
|
+
* {
|
|
30
|
+
* custom_id: 'my-custom-id-1',
|
|
31
|
+
* params: {
|
|
32
|
+
* max_tokens: 1024,
|
|
33
|
+
* messages: [
|
|
34
|
+
* { content: 'Hello, world', role: 'user' },
|
|
35
|
+
* ],
|
|
36
|
+
* model: 'claude-3-7-sonnet-20250219',
|
|
37
|
+
* },
|
|
38
|
+
* },
|
|
39
|
+
* ],
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
23
42
|
*/
|
|
24
43
|
create(params: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<BetaMessageBatch> {
|
|
25
44
|
const { betas, ...body } = params;
|
|
@@ -40,6 +59,14 @@ export class Batches extends APIResource {
|
|
|
40
59
|
*
|
|
41
60
|
* Learn more about the Message Batches API in our
|
|
42
61
|
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const betaMessageBatch =
|
|
66
|
+
* await client.beta.messages.batches.retrieve(
|
|
67
|
+
* 'message_batch_id',
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
43
70
|
*/
|
|
44
71
|
retrieve(
|
|
45
72
|
messageBatchId: string,
|
|
@@ -71,6 +98,14 @@ export class Batches extends APIResource {
|
|
|
71
98
|
*
|
|
72
99
|
* Learn more about the Message Batches API in our
|
|
73
100
|
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* // Automatically fetches more pages as needed.
|
|
105
|
+
* for await (const betaMessageBatch of client.beta.messages.batches.list()) {
|
|
106
|
+
* // ...
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
74
109
|
*/
|
|
75
110
|
list(
|
|
76
111
|
params?: BatchListParams,
|
|
@@ -103,6 +138,14 @@ export class Batches extends APIResource {
|
|
|
103
138
|
*
|
|
104
139
|
* Learn more about the Message Batches API in our
|
|
105
140
|
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const betaDeletedMessageBatch =
|
|
145
|
+
* await client.beta.messages.batches.delete(
|
|
146
|
+
* 'message_batch_id',
|
|
147
|
+
* );
|
|
148
|
+
* ```
|
|
106
149
|
*/
|
|
107
150
|
delete(
|
|
108
151
|
messageBatchId: string,
|
|
@@ -141,6 +184,14 @@ export class Batches extends APIResource {
|
|
|
141
184
|
*
|
|
142
185
|
* Learn more about the Message Batches API in our
|
|
143
186
|
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* const betaMessageBatch =
|
|
191
|
+
* await client.beta.messages.batches.cancel(
|
|
192
|
+
* 'message_batch_id',
|
|
193
|
+
* );
|
|
194
|
+
* ```
|
|
144
195
|
*/
|
|
145
196
|
cancel(
|
|
146
197
|
messageBatchId: string,
|
|
@@ -175,6 +226,14 @@ export class Batches extends APIResource {
|
|
|
175
226
|
*
|
|
176
227
|
* Learn more about the Message Batches API in our
|
|
177
228
|
* [user guide](/en/docs/build-with-claude/batch-processing)
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const betaMessageBatchIndividualResponse =
|
|
233
|
+
* await client.beta.messages.batches.results(
|
|
234
|
+
* 'message_batch_id',
|
|
235
|
+
* );
|
|
236
|
+
* ```
|
|
178
237
|
*/
|
|
179
238
|
async results(
|
|
180
239
|
messageBatchId: string,
|
|
@@ -31,8 +31,10 @@ export {
|
|
|
31
31
|
type BetaCitationContentBlockLocationParam,
|
|
32
32
|
type BetaCitationPageLocation,
|
|
33
33
|
type BetaCitationPageLocationParam,
|
|
34
|
+
type BetaCitationWebSearchResultLocationParam,
|
|
34
35
|
type BetaCitationsConfigParam,
|
|
35
36
|
type BetaCitationsDelta,
|
|
37
|
+
type BetaCitationsWebSearchResultLocation,
|
|
36
38
|
type BetaContentBlock,
|
|
37
39
|
type BetaContentBlockParam,
|
|
38
40
|
type BetaContentBlockSource,
|
|
@@ -55,6 +57,9 @@ export {
|
|
|
55
57
|
type BetaRawMessageStreamEvent,
|
|
56
58
|
type BetaRedactedThinkingBlock,
|
|
57
59
|
type BetaRedactedThinkingBlockParam,
|
|
60
|
+
type BetaServerToolUsage,
|
|
61
|
+
type BetaServerToolUseBlock,
|
|
62
|
+
type BetaServerToolUseBlockParam,
|
|
58
63
|
type BetaSignatureDelta,
|
|
59
64
|
type BetaStopReason,
|
|
60
65
|
type BetaTextBlock,
|
|
@@ -87,6 +92,15 @@ export {
|
|
|
87
92
|
type BetaURLImageSource,
|
|
88
93
|
type BetaURLPDFSource,
|
|
89
94
|
type BetaUsage,
|
|
95
|
+
type BetaWebSearchResultBlock,
|
|
96
|
+
type BetaWebSearchResultBlockParam,
|
|
97
|
+
type BetaWebSearchTool20250305,
|
|
98
|
+
type BetaWebSearchToolRequestError,
|
|
99
|
+
type BetaWebSearchToolResultBlock,
|
|
100
|
+
type BetaWebSearchToolResultBlockContent,
|
|
101
|
+
type BetaWebSearchToolResultBlockParam,
|
|
102
|
+
type BetaWebSearchToolResultBlockParamContent,
|
|
103
|
+
type BetaWebSearchToolResultError,
|
|
90
104
|
type MessageCreateParams,
|
|
91
105
|
type MessageCreateParamsNonStreaming,
|
|
92
106
|
type MessageCreateParamsStreaming,
|