Skip to content

Commit 2910b28

Browse files
feat(api): add support for Search Result Content Blocks
1 parent 7d8b8ac commit 2910b28

File tree

13 files changed

+159
-56
lines changed

13 files changed

+159
-56
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 26
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-1c66b60af140d913f44b9c08134710b743dd1cde46c101a5d296321ccd57773d.yml
3-
openapi_spec_hash: 58d4e72c7906bd8a680ab17b99de6215
4-
config_hash: e95cb9d3d6fd4c9f48241d429f5d4f44
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-59aad2898ad5b11d8c367967ca73213a83bb46f1ca20cd006ee00fc8010c5e65.yml
3+
openapi_spec_hash: 6dcdf2b065d61612f4403a1786c3bee2
4+
config_hash: f7a432ccea4a4968a1f94085f80bf258

api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ Types:
241241
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRequestMCPServerToolConfiguration</a></code>
242242
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRequestMCPServerURLDefinition</a></code>
243243
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRequestMCPToolResultBlockParam</a></code>
244+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaSearchResultBlockParam</a></code>
245+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaSearchResultLocationCitation</a></code>
246+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaSearchResultLocationCitationParam</a></code>
244247
- <code><a href="./src/resources/beta/messages/messages.ts">BetaServerToolUsage</a></code>
245248
- <code><a href="./src/resources/beta/messages/messages.ts">BetaServerToolUseBlock</a></code>
246249
- <code><a href="./src/resources/beta/messages/messages.ts">BetaServerToolUseBlockParam</a></code>

src/resources/beta/beta.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ import {
7878
BetaRequestMCPServerToolConfiguration,
7979
BetaRequestMCPServerURLDefinition,
8080
BetaRequestMCPToolResultBlockParam,
81+
BetaSearchResultBlockParam,
82+
BetaSearchResultLocationCitation,
83+
BetaSearchResultLocationCitationParam,
8184
BetaServerToolUsage,
8285
BetaServerToolUseBlock,
8386
BetaServerToolUseBlockParam,
@@ -315,6 +318,9 @@ export declare namespace Beta {
315318
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
316319
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
317320
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
321+
type BetaSearchResultBlockParam as BetaSearchResultBlockParam,
322+
type BetaSearchResultLocationCitation as BetaSearchResultLocationCitation,
323+
type BetaSearchResultLocationCitationParam as BetaSearchResultLocationCitationParam,
318324
type BetaServerToolUsage as BetaServerToolUsage,
319325
type BetaServerToolUseBlock as BetaServerToolUseBlock,
320326
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,

src/resources/beta/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ export {
8888
type BetaRequestMCPServerToolConfiguration,
8989
type BetaRequestMCPServerURLDefinition,
9090
type BetaRequestMCPToolResultBlockParam,
91+
type BetaSearchResultBlockParam,
92+
type BetaSearchResultLocationCitation,
93+
type BetaSearchResultLocationCitationParam,
9194
type BetaServerToolUsage,
9295
type BetaServerToolUseBlock,
9396
type BetaServerToolUseBlockParam,

src/resources/beta/messages/batches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Batches extends APIResource {
3434
* messages: [
3535
* { content: 'Hello, world', role: 'user' },
3636
* ],
37-
* model: 'claude-3-7-sonnet-20250219',
37+
* model: 'claude-sonnet-4-20250514',
3838
* },
3939
* },
4040
* ],

src/resources/beta/messages/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export {
8181
type BetaRequestMCPServerToolConfiguration,
8282
type BetaRequestMCPServerURLDefinition,
8383
type BetaRequestMCPToolResultBlockParam,
84+
type BetaSearchResultBlockParam,
85+
type BetaSearchResultLocationCitation,
86+
type BetaSearchResultLocationCitationParam,
8487
type BetaServerToolUsage,
8588
type BetaServerToolUseBlock,
8689
type BetaServerToolUseBlockParam,

src/resources/beta/messages/messages.ts

Lines changed: 101 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class Messages extends APIResource {
6363
* const betaMessage = await client.beta.messages.create({
6464
* max_tokens: 1024,
6565
* messages: [{ content: 'Hello, world', role: 'user' }],
66-
* model: 'claude-3-7-sonnet-20250219',
66+
* model: 'claude-sonnet-4-20250514',
6767
* });
6868
* ```
6969
*/
@@ -299,7 +299,8 @@ export interface BetaCitationsDelta {
299299
| BetaCitationCharLocation
300300
| BetaCitationPageLocation
301301
| BetaCitationContentBlockLocation
302-
| BetaCitationsWebSearchResultLocation;
302+
| BetaCitationsWebSearchResultLocation
303+
| BetaSearchResultLocationCitation;
303304

304305
type: 'citations_delta';
305306
}
@@ -460,32 +461,33 @@ export interface BetaContainerUploadBlockParam {
460461
*/
461462
export type BetaContentBlock =
462463
| BetaTextBlock
464+
| BetaThinkingBlock
465+
| BetaRedactedThinkingBlock
463466
| BetaToolUseBlock
464467
| BetaServerToolUseBlock
465468
| BetaWebSearchToolResultBlock
466469
| BetaCodeExecutionToolResultBlock
467470
| BetaMCPToolUseBlock
468471
| BetaMCPToolResultBlock
469-
| BetaContainerUploadBlock
470-
| BetaThinkingBlock
471-
| BetaRedactedThinkingBlock;
472+
| BetaContainerUploadBlock;
472473

473474
/**
474475
* Regular text content.
475476
*/
476477
export type BetaContentBlockParam =
477-
| BetaServerToolUseBlockParam
478-
| BetaWebSearchToolResultBlockParam
479-
| BetaCodeExecutionToolResultBlockParam
480-
| BetaMCPToolUseBlockParam
481-
| BetaRequestMCPToolResultBlockParam
482478
| BetaTextBlockParam
483479
| BetaImageBlockParam
484-
| BetaToolUseBlockParam
485-
| BetaToolResultBlockParam
486480
| BetaRequestDocumentBlock
481+
| BetaSearchResultBlockParam
487482
| BetaThinkingBlockParam
488483
| BetaRedactedThinkingBlockParam
484+
| BetaToolUseBlockParam
485+
| BetaToolResultBlockParam
486+
| BetaServerToolUseBlockParam
487+
| BetaWebSearchToolResultBlockParam
488+
| BetaCodeExecutionToolResultBlockParam
489+
| BetaMCPToolUseBlockParam
490+
| BetaRequestMCPToolResultBlockParam
489491
| BetaContainerUploadBlockParam;
490492

491493
export interface BetaContentBlockSource {
@@ -646,6 +648,10 @@ export interface BetaMessage {
646648
* - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
647649
* - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
648650
* - `"tool_use"`: the model invoked one or more tools
651+
* - `"pause_turn"`: we paused a long-running turn. You may provide the response
652+
* back as-is in a subsequent request to let the model continue.
653+
* - `"refusal"`: when streaming classifiers intervene to handle potential policy
654+
* violations
649655
*
650656
* In non-streaming mode this value is always non-null. In streaming mode, it is
651657
* null in the `message_start` event and non-null otherwise.
@@ -768,15 +774,15 @@ export interface BetaRawContentBlockStartEvent {
768774
*/
769775
content_block:
770776
| BetaTextBlock
777+
| BetaThinkingBlock
778+
| BetaRedactedThinkingBlock
771779
| BetaToolUseBlock
772780
| BetaServerToolUseBlock
773781
| BetaWebSearchToolResultBlock
774782
| BetaCodeExecutionToolResultBlock
775783
| BetaMCPToolUseBlock
776784
| BetaMCPToolResultBlock
777-
| BetaContainerUploadBlock
778-
| BetaThinkingBlock
779-
| BetaRedactedThinkingBlock;
785+
| BetaContainerUploadBlock;
780786

781787
index: number;
782788

@@ -913,6 +919,55 @@ export interface BetaRequestMCPToolResultBlockParam {
913919
is_error?: boolean;
914920
}
915921

922+
export interface BetaSearchResultBlockParam {
923+
content: Array<BetaTextBlockParam>;
924+
925+
source: string;
926+
927+
title: string;
928+
929+
type: 'search_result';
930+
931+
/**
932+
* Create a cache control breakpoint at this content block.
933+
*/
934+
cache_control?: BetaCacheControlEphemeral | null;
935+
936+
citations?: BetaCitationsConfigParam;
937+
}
938+
939+
export interface BetaSearchResultLocationCitation {
940+
cited_text: string;
941+
942+
end_block_index: number;
943+
944+
search_result_index: number;
945+
946+
source: string;
947+
948+
start_block_index: number;
949+
950+
title: string | null;
951+
952+
type: 'search_result_location';
953+
}
954+
955+
export interface BetaSearchResultLocationCitationParam {
956+
cited_text: string;
957+
958+
end_block_index: number;
959+
960+
search_result_index: number;
961+
962+
source: string;
963+
964+
start_block_index: number;
965+
966+
title: string | null;
967+
968+
type: 'search_result_location';
969+
}
970+
916971
export interface BetaServerToolUsage {
917972
/**
918973
* The number of web search tool requests.
@@ -991,13 +1046,15 @@ export type BetaTextCitation =
9911046
| BetaCitationCharLocation
9921047
| BetaCitationPageLocation
9931048
| BetaCitationContentBlockLocation
994-
| BetaCitationsWebSearchResultLocation;
1049+
| BetaCitationsWebSearchResultLocation
1050+
| BetaSearchResultLocationCitation;
9951051

9961052
export type BetaTextCitationParam =
9971053
| BetaCitationCharLocationParam
9981054
| BetaCitationPageLocationParam
9991055
| BetaCitationContentBlockLocationParam
1000-
| BetaCitationWebSearchResultLocationParam;
1056+
| BetaCitationWebSearchResultLocationParam
1057+
| BetaSearchResultLocationCitationParam;
10011058

10021059
export interface BetaTextDelta {
10031060
text: string;
@@ -1280,7 +1337,7 @@ export interface BetaToolResultBlockParam {
12801337
*/
12811338
cache_control?: BetaCacheControlEphemeral | null;
12821339

1283-
content?: string | Array<BetaTextBlockParam | BetaImageBlockParam>;
1340+
content?: string | Array<BetaTextBlockParam | BetaImageBlockParam | BetaSearchResultBlockParam>;
12841341

12851342
is_error?: boolean;
12861343
}
@@ -1335,15 +1392,15 @@ export interface BetaToolTextEditor20250429 {
13351392

13361393
export type BetaToolUnion =
13371394
| BetaTool
1338-
| BetaToolComputerUse20241022
13391395
| BetaToolBash20241022
1340-
| BetaToolTextEditor20241022
1341-
| BetaToolComputerUse20250124
13421396
| BetaToolBash20250124
1397+
| BetaCodeExecutionTool20250522
1398+
| BetaToolComputerUse20241022
1399+
| BetaToolComputerUse20250124
1400+
| BetaToolTextEditor20241022
13431401
| BetaToolTextEditor20250124
13441402
| BetaToolTextEditor20250429
1345-
| BetaWebSearchTool20250305
1346-
| BetaCodeExecutionTool20250522;
1403+
| BetaWebSearchTool20250305;
13471404

13481405
export interface BetaToolUseBlock {
13491406
id: string;
@@ -1669,7 +1726,7 @@ export interface MessageCreateParamsBase {
16691726
* the top-level `system` parameter — there is no `"system"` role for input
16701727
* messages in the Messages API.
16711728
*
1672-
* There is a limit of 100000 messages in a single request.
1729+
* There is a limit of 100,000 messages in a single request.
16731730
*/
16741731
messages: Array<BetaMessageParam>;
16751732

@@ -1774,6 +1831,12 @@ export interface MessageCreateParamsBase {
17741831
* those tools using the tool input generated by the model and then optionally
17751832
* return results back to the model using `tool_result` content blocks.
17761833
*
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+
*
17771840
* Each tool definition includes:
17781841
*
17791842
* - `name`: Name of the tool.
@@ -1985,7 +2048,7 @@ export interface MessageCountTokensParams {
19852048
* the top-level `system` parameter — there is no `"system"` role for input
19862049
* messages in the Messages API.
19872050
*
1988-
* There is a limit of 100000 messages in a single request.
2051+
* There is a limit of 100,000 messages in a single request.
19892052
*/
19902053
messages: Array<BetaMessageParam>;
19912054

@@ -2037,6 +2100,12 @@ export interface MessageCountTokensParams {
20372100
* those tools using the tool input generated by the model and then optionally
20382101
* return results back to the model using `tool_result` content blocks.
20392102
*
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+
*
20402109
* Each tool definition includes:
20412110
*
20422111
* - `name`: Name of the tool.
@@ -2102,15 +2171,15 @@ export interface MessageCountTokensParams {
21022171
*/
21032172
tools?: Array<
21042173
| BetaTool
2105-
| BetaToolComputerUse20241022
21062174
| BetaToolBash20241022
2107-
| BetaToolTextEditor20241022
2108-
| BetaToolComputerUse20250124
21092175
| BetaToolBash20250124
2176+
| BetaCodeExecutionTool20250522
2177+
| BetaToolComputerUse20241022
2178+
| BetaToolComputerUse20250124
2179+
| BetaToolTextEditor20241022
21102180
| BetaToolTextEditor20250124
21112181
| BetaToolTextEditor20250429
21122182
| BetaWebSearchTool20250305
2113-
| BetaCodeExecutionTool20250522
21142183
>;
21152184

21162185
/**
@@ -2183,6 +2252,9 @@ export declare namespace Messages {
21832252
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
21842253
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
21852254
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
2255+
type BetaSearchResultBlockParam as BetaSearchResultBlockParam,
2256+
type BetaSearchResultLocationCitation as BetaSearchResultLocationCitation,
2257+
type BetaSearchResultLocationCitationParam as BetaSearchResultLocationCitationParam,
21862258
type BetaServerToolUsage as BetaServerToolUsage,
21872259
type BetaServerToolUseBlock as BetaServerToolUseBlock,
21882260
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,

src/resources/messages/batches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class Batches extends APIResource {
3333
* messages: [
3434
* { content: 'Hello, world', role: 'user' },
3535
* ],
36-
* model: 'claude-3-7-sonnet-20250219',
36+
* model: 'claude-sonnet-4-20250514',
3737
* },
3838
* },
3939
* ],

0 commit comments

Comments
 (0)