@anthropic-ai/sdk 0.55.0 → 0.56.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 +46 -0
- package/README.md +24 -24
- package/client.d.mts +2 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -0
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +5 -3
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +5 -3
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +18 -12
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +18 -12
- package/core/streaming.mjs.map +1 -1
- package/internal/parse.js +2 -2
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +2 -2
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +42 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +42 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/types.d.mts +8 -6
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +8 -6
- package/internal/types.d.ts.map +1 -1
- package/internal/uploads.js +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/log.js +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js +26 -5
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +26 -5
- package/internal/utils/path.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +20 -7
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +20 -7
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.mts.map +1 -1
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +21 -8
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +21 -8
- package/lib/MessageStream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/beta.d.mts +2 -2
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +2 -2
- 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.mts +1 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/messages/batches.d.mts +1 -1
- package/resources/beta/messages/batches.d.ts +1 -1
- package/resources/beta/messages/batches.js +1 -1
- package/resources/beta/messages/batches.mjs +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 +58 -13
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +58 -13
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +1 -0
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +1 -0
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/messages/batches.d.mts +1 -1
- package/resources/messages/batches.d.ts +1 -1
- package/resources/messages/batches.js +1 -1
- package/resources/messages/batches.mjs +1 -1
- package/resources/messages/messages.d.mts +22 -6
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +22 -6
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +1 -0
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +1 -0
- package/resources/messages/messages.mjs.map +1 -1
- package/src/client.ts +2 -0
- package/src/core/streaming.ts +24 -10
- package/src/internal/parse.ts +2 -2
- package/src/internal/request-options.ts +53 -0
- package/src/internal/types.ts +9 -6
- package/src/internal/uploads.ts +1 -1
- package/src/internal/utils/log.ts +1 -1
- package/src/internal/utils/path.ts +30 -7
- package/src/lib/BetaMessageStream.ts +20 -7
- package/src/lib/MessageStream.ts +21 -8
- package/src/resources/beta/beta.ts +6 -0
- package/src/resources/beta/index.ts +3 -0
- package/src/resources/beta/messages/batches.ts +1 -1
- package/src/resources/beta/messages/index.ts +3 -0
- package/src/resources/beta/messages/messages.ts +102 -29
- package/src/resources/messages/batches.ts +1 -1
- package/src/resources/messages/messages.ts +31 -14
- 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
|
@@ -12,25 +12,43 @@ export function encodeURIPath(str: string) {
|
|
|
12
12
|
return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
16
|
+
|
|
15
17
|
export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
16
18
|
function path(statics: readonly string[], ...params: readonly unknown[]): string {
|
|
17
19
|
// If there are no params, no processing is needed.
|
|
18
20
|
if (statics.length === 1) return statics[0]!;
|
|
19
21
|
|
|
20
22
|
let postPath = false;
|
|
23
|
+
const invalidSegments = [];
|
|
21
24
|
const path = statics.reduce((previousValue, currentValue, index) => {
|
|
22
25
|
if (/[?#]/.test(currentValue)) {
|
|
23
26
|
postPath = true;
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const value = params[index];
|
|
29
|
+
let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
|
|
30
|
+
if (
|
|
31
|
+
index !== params.length &&
|
|
32
|
+
(value == null ||
|
|
33
|
+
(typeof value === 'object' &&
|
|
34
|
+
// handle values from other realms
|
|
35
|
+
value.toString ===
|
|
36
|
+
Object.getPrototypeOf(Object.getPrototypeOf((value as any).hasOwnProperty ?? EMPTY) ?? EMPTY)
|
|
37
|
+
?.toString))
|
|
38
|
+
) {
|
|
39
|
+
encoded = value + '';
|
|
40
|
+
invalidSegments.push({
|
|
41
|
+
start: previousValue.length + currentValue.length,
|
|
42
|
+
length: encoded.length,
|
|
43
|
+
error: `Value of type ${Object.prototype.toString
|
|
44
|
+
.call(value)
|
|
45
|
+
.slice(8, -1)} is not a valid path parameter`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
30
49
|
}, '');
|
|
31
50
|
|
|
32
51
|
const pathOnly = path.split(/[?#]/, 1)[0]!;
|
|
33
|
-
const invalidSegments = [];
|
|
34
52
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
35
53
|
let match;
|
|
36
54
|
|
|
@@ -39,9 +57,12 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
39
57
|
invalidSegments.push({
|
|
40
58
|
start: match.index,
|
|
41
59
|
length: match[0].length,
|
|
60
|
+
error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
|
|
42
61
|
});
|
|
43
62
|
}
|
|
44
63
|
|
|
64
|
+
invalidSegments.sort((a, b) => a.start - b.start);
|
|
65
|
+
|
|
45
66
|
if (invalidSegments.length > 0) {
|
|
46
67
|
let lastEnd = 0;
|
|
47
68
|
const underline = invalidSegments.reduce((acc, segment) => {
|
|
@@ -52,7 +73,9 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
52
73
|
}, '');
|
|
53
74
|
|
|
54
75
|
throw new AnthropicError(
|
|
55
|
-
`Path parameters result in path with invalid segments:\n${
|
|
76
|
+
`Path parameters result in path with invalid segments:\n${invalidSegments
|
|
77
|
+
.map((e) => e.error)
|
|
78
|
+
.join('\n')}\n${path}\n${underline}`,
|
|
56
79
|
);
|
|
57
80
|
}
|
|
58
81
|
|
|
@@ -583,14 +583,19 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
583
583
|
switch (event.delta.type) {
|
|
584
584
|
case 'text_delta': {
|
|
585
585
|
if (snapshotContent?.type === 'text') {
|
|
586
|
-
|
|
586
|
+
snapshot.content[event.index] = {
|
|
587
|
+
...snapshotContent,
|
|
588
|
+
text: (snapshotContent.text || '') + event.delta.text,
|
|
589
|
+
};
|
|
587
590
|
}
|
|
588
591
|
break;
|
|
589
592
|
}
|
|
590
593
|
case 'citations_delta': {
|
|
591
594
|
if (snapshotContent?.type === 'text') {
|
|
592
|
-
|
|
593
|
-
|
|
595
|
+
snapshot.content[event.index] = {
|
|
596
|
+
...snapshotContent,
|
|
597
|
+
citations: [...(snapshotContent.citations ?? []), event.delta.citation],
|
|
598
|
+
};
|
|
594
599
|
}
|
|
595
600
|
break;
|
|
596
601
|
}
|
|
@@ -602,7 +607,8 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
602
607
|
let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
|
|
603
608
|
jsonBuf += event.delta.partial_json;
|
|
604
609
|
|
|
605
|
-
|
|
610
|
+
const newContent = { ...snapshotContent };
|
|
611
|
+
Object.defineProperty(newContent, JSON_BUF_PROPERTY, {
|
|
606
612
|
value: jsonBuf,
|
|
607
613
|
enumerable: false,
|
|
608
614
|
writable: true,
|
|
@@ -610,7 +616,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
610
616
|
|
|
611
617
|
if (jsonBuf) {
|
|
612
618
|
try {
|
|
613
|
-
|
|
619
|
+
newContent.input = partialParse(jsonBuf);
|
|
614
620
|
} catch (err) {
|
|
615
621
|
const error = new AnthropicError(
|
|
616
622
|
`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err}. JSON: ${jsonBuf}`,
|
|
@@ -618,18 +624,25 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
|
|
|
618
624
|
this.#handleError(error);
|
|
619
625
|
}
|
|
620
626
|
}
|
|
627
|
+
snapshot.content[event.index] = newContent;
|
|
621
628
|
}
|
|
622
629
|
break;
|
|
623
630
|
}
|
|
624
631
|
case 'thinking_delta': {
|
|
625
632
|
if (snapshotContent?.type === 'thinking') {
|
|
626
|
-
|
|
633
|
+
snapshot.content[event.index] = {
|
|
634
|
+
...snapshotContent,
|
|
635
|
+
thinking: snapshotContent.thinking + event.delta.thinking,
|
|
636
|
+
};
|
|
627
637
|
}
|
|
628
638
|
break;
|
|
629
639
|
}
|
|
630
640
|
case 'signature_delta': {
|
|
631
641
|
if (snapshotContent?.type === 'thinking') {
|
|
632
|
-
|
|
642
|
+
snapshot.content[event.index] = {
|
|
643
|
+
...snapshotContent,
|
|
644
|
+
signature: event.delta.signature,
|
|
645
|
+
};
|
|
633
646
|
}
|
|
634
647
|
break;
|
|
635
648
|
}
|
package/src/lib/MessageStream.ts
CHANGED
|
@@ -574,7 +574,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
|
|
|
574
574
|
|
|
575
575
|
return snapshot;
|
|
576
576
|
case 'content_block_start':
|
|
577
|
-
snapshot.content.push(event.content_block);
|
|
577
|
+
snapshot.content.push({ ...event.content_block });
|
|
578
578
|
return snapshot;
|
|
579
579
|
case 'content_block_delta': {
|
|
580
580
|
const snapshotContent = snapshot.content.at(event.index);
|
|
@@ -582,14 +582,19 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
|
|
|
582
582
|
switch (event.delta.type) {
|
|
583
583
|
case 'text_delta': {
|
|
584
584
|
if (snapshotContent?.type === 'text') {
|
|
585
|
-
|
|
585
|
+
snapshot.content[event.index] = {
|
|
586
|
+
...snapshotContent,
|
|
587
|
+
text: (snapshotContent.text || '') + event.delta.text,
|
|
588
|
+
};
|
|
586
589
|
}
|
|
587
590
|
break;
|
|
588
591
|
}
|
|
589
592
|
case 'citations_delta': {
|
|
590
593
|
if (snapshotContent?.type === 'text') {
|
|
591
|
-
|
|
592
|
-
|
|
594
|
+
snapshot.content[event.index] = {
|
|
595
|
+
...snapshotContent,
|
|
596
|
+
citations: [...(snapshotContent.citations ?? []), event.delta.citation],
|
|
597
|
+
};
|
|
593
598
|
}
|
|
594
599
|
break;
|
|
595
600
|
}
|
|
@@ -601,27 +606,35 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
|
|
|
601
606
|
let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
|
|
602
607
|
jsonBuf += event.delta.partial_json;
|
|
603
608
|
|
|
604
|
-
|
|
609
|
+
const newContent = { ...snapshotContent };
|
|
610
|
+
Object.defineProperty(newContent, JSON_BUF_PROPERTY, {
|
|
605
611
|
value: jsonBuf,
|
|
606
612
|
enumerable: false,
|
|
607
613
|
writable: true,
|
|
608
614
|
});
|
|
609
615
|
|
|
610
616
|
if (jsonBuf) {
|
|
611
|
-
|
|
617
|
+
newContent.input = partialParse(jsonBuf);
|
|
612
618
|
}
|
|
619
|
+
snapshot.content[event.index] = newContent;
|
|
613
620
|
}
|
|
614
621
|
break;
|
|
615
622
|
}
|
|
616
623
|
case 'thinking_delta': {
|
|
617
624
|
if (snapshotContent?.type === 'thinking') {
|
|
618
|
-
|
|
625
|
+
snapshot.content[event.index] = {
|
|
626
|
+
...snapshotContent,
|
|
627
|
+
thinking: snapshotContent.thinking + event.delta.thinking,
|
|
628
|
+
};
|
|
619
629
|
}
|
|
620
630
|
break;
|
|
621
631
|
}
|
|
622
632
|
case 'signature_delta': {
|
|
623
633
|
if (snapshotContent?.type === 'thinking') {
|
|
624
|
-
|
|
634
|
+
snapshot.content[event.index] = {
|
|
635
|
+
...snapshotContent,
|
|
636
|
+
signature: event.delta.signature,
|
|
637
|
+
};
|
|
625
638
|
}
|
|
626
639
|
break;
|
|
627
640
|
}
|
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
BetaCitationContentBlockLocationParam,
|
|
29
29
|
BetaCitationPageLocation,
|
|
30
30
|
BetaCitationPageLocationParam,
|
|
31
|
+
BetaCitationSearchResultLocation,
|
|
32
|
+
BetaCitationSearchResultLocationParam,
|
|
31
33
|
BetaCitationWebSearchResultLocationParam,
|
|
32
34
|
BetaCitationsConfigParam,
|
|
33
35
|
BetaCitationsDelta,
|
|
@@ -78,6 +80,7 @@ import {
|
|
|
78
80
|
BetaRequestMCPServerToolConfiguration,
|
|
79
81
|
BetaRequestMCPServerURLDefinition,
|
|
80
82
|
BetaRequestMCPToolResultBlockParam,
|
|
83
|
+
BetaSearchResultBlockParam,
|
|
81
84
|
BetaServerToolUsage,
|
|
82
85
|
BetaServerToolUseBlock,
|
|
83
86
|
BetaServerToolUseBlockParam,
|
|
@@ -265,6 +268,8 @@ export declare namespace Beta {
|
|
|
265
268
|
type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
|
|
266
269
|
type BetaCitationPageLocation as BetaCitationPageLocation,
|
|
267
270
|
type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
|
|
271
|
+
type BetaCitationSearchResultLocation as BetaCitationSearchResultLocation,
|
|
272
|
+
type BetaCitationSearchResultLocationParam as BetaCitationSearchResultLocationParam,
|
|
268
273
|
type BetaCitationWebSearchResultLocationParam as BetaCitationWebSearchResultLocationParam,
|
|
269
274
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
270
275
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
@@ -315,6 +320,7 @@ export declare namespace Beta {
|
|
|
315
320
|
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
|
|
316
321
|
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
|
|
317
322
|
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
|
|
323
|
+
type BetaSearchResultBlockParam as BetaSearchResultBlockParam,
|
|
318
324
|
type BetaServerToolUsage as BetaServerToolUsage,
|
|
319
325
|
type BetaServerToolUseBlock as BetaServerToolUseBlock,
|
|
320
326
|
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
|
|
@@ -38,6 +38,8 @@ export {
|
|
|
38
38
|
type BetaCitationContentBlockLocationParam,
|
|
39
39
|
type BetaCitationPageLocation,
|
|
40
40
|
type BetaCitationPageLocationParam,
|
|
41
|
+
type BetaCitationSearchResultLocation,
|
|
42
|
+
type BetaCitationSearchResultLocationParam,
|
|
41
43
|
type BetaCitationWebSearchResultLocationParam,
|
|
42
44
|
type BetaCitationsConfigParam,
|
|
43
45
|
type BetaCitationsDelta,
|
|
@@ -88,6 +90,7 @@ export {
|
|
|
88
90
|
type BetaRequestMCPServerToolConfiguration,
|
|
89
91
|
type BetaRequestMCPServerURLDefinition,
|
|
90
92
|
type BetaRequestMCPToolResultBlockParam,
|
|
93
|
+
type BetaSearchResultBlockParam,
|
|
91
94
|
type BetaServerToolUsage,
|
|
92
95
|
type BetaServerToolUseBlock,
|
|
93
96
|
type BetaServerToolUseBlockParam,
|
|
@@ -31,6 +31,8 @@ export {
|
|
|
31
31
|
type BetaCitationContentBlockLocationParam,
|
|
32
32
|
type BetaCitationPageLocation,
|
|
33
33
|
type BetaCitationPageLocationParam,
|
|
34
|
+
type BetaCitationSearchResultLocation,
|
|
35
|
+
type BetaCitationSearchResultLocationParam,
|
|
34
36
|
type BetaCitationWebSearchResultLocationParam,
|
|
35
37
|
type BetaCitationsConfigParam,
|
|
36
38
|
type BetaCitationsDelta,
|
|
@@ -81,6 +83,7 @@ export {
|
|
|
81
83
|
type BetaRequestMCPServerToolConfiguration,
|
|
82
84
|
type BetaRequestMCPServerURLDefinition,
|
|
83
85
|
type BetaRequestMCPToolResultBlockParam,
|
|
86
|
+
type BetaSearchResultBlockParam,
|
|
84
87
|
type BetaServerToolUsage,
|
|
85
88
|
type BetaServerToolUseBlock,
|
|
86
89
|
type BetaServerToolUseBlockParam,
|
|
@@ -40,6 +40,7 @@ const DEPRECATED_MODELS: {
|
|
|
40
40
|
'claude-instant-1.1-100k': 'November 6th, 2024',
|
|
41
41
|
'claude-instant-1.2': 'November 6th, 2024',
|
|
42
42
|
'claude-3-sonnet-20240229': 'July 21st, 2025',
|
|
43
|
+
'claude-3-opus-20240229': 'January 5th, 2026',
|
|
43
44
|
'claude-2.1': 'July 21st, 2025',
|
|
44
45
|
'claude-2.0': 'July 21st, 2025',
|
|
45
46
|
};
|
|
@@ -62,7 +63,7 @@ export class Messages extends APIResource {
|
|
|
62
63
|
* const betaMessage = await client.beta.messages.create({
|
|
63
64
|
* max_tokens: 1024,
|
|
64
65
|
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
65
|
-
* model: 'claude-
|
|
66
|
+
* model: 'claude-sonnet-4-20250514',
|
|
66
67
|
* });
|
|
67
68
|
* ```
|
|
68
69
|
*/
|
|
@@ -277,6 +278,38 @@ export interface BetaCitationPageLocationParam {
|
|
|
277
278
|
type: 'page_location';
|
|
278
279
|
}
|
|
279
280
|
|
|
281
|
+
export interface BetaCitationSearchResultLocation {
|
|
282
|
+
cited_text: string;
|
|
283
|
+
|
|
284
|
+
end_block_index: number;
|
|
285
|
+
|
|
286
|
+
search_result_index: number;
|
|
287
|
+
|
|
288
|
+
source: string;
|
|
289
|
+
|
|
290
|
+
start_block_index: number;
|
|
291
|
+
|
|
292
|
+
title: string | null;
|
|
293
|
+
|
|
294
|
+
type: 'search_result_location';
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface BetaCitationSearchResultLocationParam {
|
|
298
|
+
cited_text: string;
|
|
299
|
+
|
|
300
|
+
end_block_index: number;
|
|
301
|
+
|
|
302
|
+
search_result_index: number;
|
|
303
|
+
|
|
304
|
+
source: string;
|
|
305
|
+
|
|
306
|
+
start_block_index: number;
|
|
307
|
+
|
|
308
|
+
title: string | null;
|
|
309
|
+
|
|
310
|
+
type: 'search_result_location';
|
|
311
|
+
}
|
|
312
|
+
|
|
280
313
|
export interface BetaCitationWebSearchResultLocationParam {
|
|
281
314
|
cited_text: string;
|
|
282
315
|
|
|
@@ -298,7 +331,8 @@ export interface BetaCitationsDelta {
|
|
|
298
331
|
| BetaCitationCharLocation
|
|
299
332
|
| BetaCitationPageLocation
|
|
300
333
|
| BetaCitationContentBlockLocation
|
|
301
|
-
| BetaCitationsWebSearchResultLocation
|
|
334
|
+
| BetaCitationsWebSearchResultLocation
|
|
335
|
+
| BetaCitationSearchResultLocation;
|
|
302
336
|
|
|
303
337
|
type: 'citations_delta';
|
|
304
338
|
}
|
|
@@ -459,32 +493,33 @@ export interface BetaContainerUploadBlockParam {
|
|
|
459
493
|
*/
|
|
460
494
|
export type BetaContentBlock =
|
|
461
495
|
| BetaTextBlock
|
|
496
|
+
| BetaThinkingBlock
|
|
497
|
+
| BetaRedactedThinkingBlock
|
|
462
498
|
| BetaToolUseBlock
|
|
463
499
|
| BetaServerToolUseBlock
|
|
464
500
|
| BetaWebSearchToolResultBlock
|
|
465
501
|
| BetaCodeExecutionToolResultBlock
|
|
466
502
|
| BetaMCPToolUseBlock
|
|
467
503
|
| BetaMCPToolResultBlock
|
|
468
|
-
| BetaContainerUploadBlock
|
|
469
|
-
| BetaThinkingBlock
|
|
470
|
-
| BetaRedactedThinkingBlock;
|
|
504
|
+
| BetaContainerUploadBlock;
|
|
471
505
|
|
|
472
506
|
/**
|
|
473
507
|
* Regular text content.
|
|
474
508
|
*/
|
|
475
509
|
export type BetaContentBlockParam =
|
|
476
|
-
| BetaServerToolUseBlockParam
|
|
477
|
-
| BetaWebSearchToolResultBlockParam
|
|
478
|
-
| BetaCodeExecutionToolResultBlockParam
|
|
479
|
-
| BetaMCPToolUseBlockParam
|
|
480
|
-
| BetaRequestMCPToolResultBlockParam
|
|
481
510
|
| BetaTextBlockParam
|
|
482
511
|
| BetaImageBlockParam
|
|
483
|
-
| BetaToolUseBlockParam
|
|
484
|
-
| BetaToolResultBlockParam
|
|
485
512
|
| BetaRequestDocumentBlock
|
|
513
|
+
| BetaSearchResultBlockParam
|
|
486
514
|
| BetaThinkingBlockParam
|
|
487
515
|
| BetaRedactedThinkingBlockParam
|
|
516
|
+
| BetaToolUseBlockParam
|
|
517
|
+
| BetaToolResultBlockParam
|
|
518
|
+
| BetaServerToolUseBlockParam
|
|
519
|
+
| BetaWebSearchToolResultBlockParam
|
|
520
|
+
| BetaCodeExecutionToolResultBlockParam
|
|
521
|
+
| BetaMCPToolUseBlockParam
|
|
522
|
+
| BetaRequestMCPToolResultBlockParam
|
|
488
523
|
| BetaContainerUploadBlockParam;
|
|
489
524
|
|
|
490
525
|
export interface BetaContentBlockSource {
|
|
@@ -645,6 +680,10 @@ export interface BetaMessage {
|
|
|
645
680
|
* - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
|
|
646
681
|
* - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
|
|
647
682
|
* - `"tool_use"`: the model invoked one or more tools
|
|
683
|
+
* - `"pause_turn"`: we paused a long-running turn. You may provide the response
|
|
684
|
+
* back as-is in a subsequent request to let the model continue.
|
|
685
|
+
* - `"refusal"`: when streaming classifiers intervene to handle potential policy
|
|
686
|
+
* violations
|
|
648
687
|
*
|
|
649
688
|
* In non-streaming mode this value is always non-null. In streaming mode, it is
|
|
650
689
|
* null in the `message_start` event and non-null otherwise.
|
|
@@ -767,15 +806,15 @@ export interface BetaRawContentBlockStartEvent {
|
|
|
767
806
|
*/
|
|
768
807
|
content_block:
|
|
769
808
|
| BetaTextBlock
|
|
809
|
+
| BetaThinkingBlock
|
|
810
|
+
| BetaRedactedThinkingBlock
|
|
770
811
|
| BetaToolUseBlock
|
|
771
812
|
| BetaServerToolUseBlock
|
|
772
813
|
| BetaWebSearchToolResultBlock
|
|
773
814
|
| BetaCodeExecutionToolResultBlock
|
|
774
815
|
| BetaMCPToolUseBlock
|
|
775
816
|
| BetaMCPToolResultBlock
|
|
776
|
-
| BetaContainerUploadBlock
|
|
777
|
-
| BetaThinkingBlock
|
|
778
|
-
| BetaRedactedThinkingBlock;
|
|
817
|
+
| BetaContainerUploadBlock;
|
|
779
818
|
|
|
780
819
|
index: number;
|
|
781
820
|
|
|
@@ -912,6 +951,23 @@ export interface BetaRequestMCPToolResultBlockParam {
|
|
|
912
951
|
is_error?: boolean;
|
|
913
952
|
}
|
|
914
953
|
|
|
954
|
+
export interface BetaSearchResultBlockParam {
|
|
955
|
+
content: Array<BetaTextBlockParam>;
|
|
956
|
+
|
|
957
|
+
source: string;
|
|
958
|
+
|
|
959
|
+
title: string;
|
|
960
|
+
|
|
961
|
+
type: 'search_result';
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Create a cache control breakpoint at this content block.
|
|
965
|
+
*/
|
|
966
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
967
|
+
|
|
968
|
+
citations?: BetaCitationsConfigParam;
|
|
969
|
+
}
|
|
970
|
+
|
|
915
971
|
export interface BetaServerToolUsage {
|
|
916
972
|
/**
|
|
917
973
|
* The number of web search tool requests.
|
|
@@ -990,13 +1046,15 @@ export type BetaTextCitation =
|
|
|
990
1046
|
| BetaCitationCharLocation
|
|
991
1047
|
| BetaCitationPageLocation
|
|
992
1048
|
| BetaCitationContentBlockLocation
|
|
993
|
-
| BetaCitationsWebSearchResultLocation
|
|
1049
|
+
| BetaCitationsWebSearchResultLocation
|
|
1050
|
+
| BetaCitationSearchResultLocation;
|
|
994
1051
|
|
|
995
1052
|
export type BetaTextCitationParam =
|
|
996
1053
|
| BetaCitationCharLocationParam
|
|
997
1054
|
| BetaCitationPageLocationParam
|
|
998
1055
|
| BetaCitationContentBlockLocationParam
|
|
999
|
-
| BetaCitationWebSearchResultLocationParam
|
|
1056
|
+
| BetaCitationWebSearchResultLocationParam
|
|
1057
|
+
| BetaCitationSearchResultLocationParam;
|
|
1000
1058
|
|
|
1001
1059
|
export interface BetaTextDelta {
|
|
1002
1060
|
text: string;
|
|
@@ -1279,7 +1337,7 @@ export interface BetaToolResultBlockParam {
|
|
|
1279
1337
|
*/
|
|
1280
1338
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
1281
1339
|
|
|
1282
|
-
content?: string | Array<BetaTextBlockParam | BetaImageBlockParam>;
|
|
1340
|
+
content?: string | Array<BetaTextBlockParam | BetaImageBlockParam | BetaSearchResultBlockParam>;
|
|
1283
1341
|
|
|
1284
1342
|
is_error?: boolean;
|
|
1285
1343
|
}
|
|
@@ -1334,15 +1392,15 @@ export interface BetaToolTextEditor20250429 {
|
|
|
1334
1392
|
|
|
1335
1393
|
export type BetaToolUnion =
|
|
1336
1394
|
| BetaTool
|
|
1337
|
-
| BetaToolComputerUse20241022
|
|
1338
1395
|
| BetaToolBash20241022
|
|
1339
|
-
| BetaToolTextEditor20241022
|
|
1340
|
-
| BetaToolComputerUse20250124
|
|
1341
1396
|
| BetaToolBash20250124
|
|
1397
|
+
| BetaCodeExecutionTool20250522
|
|
1398
|
+
| BetaToolComputerUse20241022
|
|
1399
|
+
| BetaToolComputerUse20250124
|
|
1400
|
+
| BetaToolTextEditor20241022
|
|
1342
1401
|
| BetaToolTextEditor20250124
|
|
1343
1402
|
| BetaToolTextEditor20250429
|
|
1344
|
-
| BetaWebSearchTool20250305
|
|
1345
|
-
| BetaCodeExecutionTool20250522;
|
|
1403
|
+
| BetaWebSearchTool20250305;
|
|
1346
1404
|
|
|
1347
1405
|
export interface BetaToolUseBlock {
|
|
1348
1406
|
id: string;
|
|
@@ -1668,7 +1726,7 @@ export interface MessageCreateParamsBase {
|
|
|
1668
1726
|
* the top-level `system` parameter — there is no `"system"` role for input
|
|
1669
1727
|
* messages in the Messages API.
|
|
1670
1728
|
*
|
|
1671
|
-
* There is a limit of
|
|
1729
|
+
* There is a limit of 100,000 messages in a single request.
|
|
1672
1730
|
*/
|
|
1673
1731
|
messages: Array<BetaMessageParam>;
|
|
1674
1732
|
|
|
@@ -1773,6 +1831,12 @@ export interface MessageCreateParamsBase {
|
|
|
1773
1831
|
* those tools using the tool input generated by the model and then optionally
|
|
1774
1832
|
* return results back to the model using `tool_result` content blocks.
|
|
1775
1833
|
*
|
|
1834
|
+
* There are two types of tools: **client tools** and **server tools**. The
|
|
1835
|
+
* behavior described below applies to client tools. For
|
|
1836
|
+
* [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
|
|
1837
|
+
* see their individual documentation as each has its own behavior (e.g., the
|
|
1838
|
+
* [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
|
|
1839
|
+
*
|
|
1776
1840
|
* Each tool definition includes:
|
|
1777
1841
|
*
|
|
1778
1842
|
* - `name`: Name of the tool.
|
|
@@ -1984,7 +2048,7 @@ export interface MessageCountTokensParams {
|
|
|
1984
2048
|
* the top-level `system` parameter — there is no `"system"` role for input
|
|
1985
2049
|
* messages in the Messages API.
|
|
1986
2050
|
*
|
|
1987
|
-
* There is a limit of
|
|
2051
|
+
* There is a limit of 100,000 messages in a single request.
|
|
1988
2052
|
*/
|
|
1989
2053
|
messages: Array<BetaMessageParam>;
|
|
1990
2054
|
|
|
@@ -2036,6 +2100,12 @@ export interface MessageCountTokensParams {
|
|
|
2036
2100
|
* those tools using the tool input generated by the model and then optionally
|
|
2037
2101
|
* return results back to the model using `tool_result` content blocks.
|
|
2038
2102
|
*
|
|
2103
|
+
* There are two types of tools: **client tools** and **server tools**. The
|
|
2104
|
+
* behavior described below applies to client tools. For
|
|
2105
|
+
* [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
|
|
2106
|
+
* see their individual documentation as each has its own behavior (e.g., the
|
|
2107
|
+
* [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
|
|
2108
|
+
*
|
|
2039
2109
|
* Each tool definition includes:
|
|
2040
2110
|
*
|
|
2041
2111
|
* - `name`: Name of the tool.
|
|
@@ -2101,15 +2171,15 @@ export interface MessageCountTokensParams {
|
|
|
2101
2171
|
*/
|
|
2102
2172
|
tools?: Array<
|
|
2103
2173
|
| BetaTool
|
|
2104
|
-
| BetaToolComputerUse20241022
|
|
2105
2174
|
| BetaToolBash20241022
|
|
2106
|
-
| BetaToolTextEditor20241022
|
|
2107
|
-
| BetaToolComputerUse20250124
|
|
2108
2175
|
| BetaToolBash20250124
|
|
2176
|
+
| BetaCodeExecutionTool20250522
|
|
2177
|
+
| BetaToolComputerUse20241022
|
|
2178
|
+
| BetaToolComputerUse20250124
|
|
2179
|
+
| BetaToolTextEditor20241022
|
|
2109
2180
|
| BetaToolTextEditor20250124
|
|
2110
2181
|
| BetaToolTextEditor20250429
|
|
2111
2182
|
| BetaWebSearchTool20250305
|
|
2112
|
-
| BetaCodeExecutionTool20250522
|
|
2113
2183
|
>;
|
|
2114
2184
|
|
|
2115
2185
|
/**
|
|
@@ -2132,6 +2202,8 @@ export declare namespace Messages {
|
|
|
2132
2202
|
type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
|
|
2133
2203
|
type BetaCitationPageLocation as BetaCitationPageLocation,
|
|
2134
2204
|
type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
|
|
2205
|
+
type BetaCitationSearchResultLocation as BetaCitationSearchResultLocation,
|
|
2206
|
+
type BetaCitationSearchResultLocationParam as BetaCitationSearchResultLocationParam,
|
|
2135
2207
|
type BetaCitationWebSearchResultLocationParam as BetaCitationWebSearchResultLocationParam,
|
|
2136
2208
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
2137
2209
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
@@ -2182,6 +2254,7 @@ export declare namespace Messages {
|
|
|
2182
2254
|
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
|
|
2183
2255
|
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
|
|
2184
2256
|
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
|
|
2257
|
+
type BetaSearchResultBlockParam as BetaSearchResultBlockParam,
|
|
2185
2258
|
type BetaServerToolUsage as BetaServerToolUsage,
|
|
2186
2259
|
type BetaServerToolUseBlock as BetaServerToolUseBlock,
|
|
2187
2260
|
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
|