The two sides of this change are more than 400 edits apart, too far apart to line up, so this is the differ's own diff of it and the words inside a line are not marked.
from line 1
1---
2title: Count tokens in a Message
3url: https://platform.claude.com/docs/en/api/messages/count_tokens
4---
5
6## Count tokens in a Message
7
8**post** `/v1/messages/count_tokens`
1# Count tokens in a Message
2
3**POST** `/v1/messages/count_tokens`
94
105Count the number of tokens in a Message.
116
from line 8
138
149Learn more about token counting in our [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
1510
16### Header Parameters
11## Headers
1712
1813- `"anthropic-user-profile-id": optional string`
1914
2015 The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the `user-profiles` beta header.
2116
22### Body Parameters
17## Body parameters
2318
2419- `messages: array of MessageParam`
2520
from line 73
7873
7974 - `array of ContentBlockParam`
8075
81 - `TextBlockParam object { text, type, cache_control, citations }`
76 - `TextBlockParam object`
8277
8378 - `text: string`
8479
80 minLength: 1
81
8582 - `type: "text"`
8683
87 - `"text"`
88
8984 - `cache_control: optional CacheControlEphemeral or null`
9085
9186 Create a cache control breakpoint at this content block.
9287
9388 - `type: "ephemeral"`
94
95 - `"ephemeral"`
9689
9790 - `ttl: optional "5m" or "1h"`
9891
from line 104
111104
112105 - `citations: optional array of TextCitationParam or null`
113106
114 - `CitationCharLocationParam object { cited_text, document_index, document_title, 3 more }`
107 - `CitationCharLocationParam object`
115108
116109 - `cited_text: string`
117110
118111 - `document_index: number`
119112
113 minimum: 0
114
120115 - `document_title: string or null`
121116
117 maxLength: 500, minLength: 1
118
122119 - `end_char_index: number`
123120
124121 - `start_char_index: number`
125122
123 minimum: 0
124
126125 - `type: "char_location"`
127126
128 - `"char_location"`
129
130 - `CitationPageLocationParam object { cited_text, document_index, document_title, 3 more }`
127 - `CitationPageLocationParam object`
131128
132129 - `cited_text: string`
133130
134131 - `document_index: number`
135132
133 minimum: 0
134
136135 - `document_title: string or null`
137136
137 maxLength: 500, minLength: 1
138
138139 - `end_page_number: number`
139140
140141 - `start_page_number: number`
141142
143 minimum: 1
144
142145 - `type: "page_location"`
143146
144 - `"page_location"`
145
146 - `CitationContentBlockLocationParam object { cited_text, document_index, document_title, 3 more }`
147 - `CitationContentBlockLocationParam object`
147148
148149 - `cited_text: string`
149150
from line 154
153154
154155 - `document_index: number`
155156
157 minimum: 0
158
156159 - `document_title: string or null`
157160
161 maxLength: 500, minLength: 1
162
158163 - `end_block_index: number`
159164
160165 Exclusive 0-based end index of the cited block range in the source's `content` array.
from line 170
165170
166171 0-based index of the first cited block in the source's `content` array.
167172
173 minimum: 0
174
168175 - `type: "content_block_location"`
169176
170 - `"content_block_location"`
171
172 - `CitationWebSearchResultLocationParam object { cited_text, encrypted_index, title, 2 more }`
177 - `CitationWebSearchResultLocationParam object`
173178
174179 - `cited_text: string`
175180
from line 182
177182
178183 - `title: string or null`
179184
185 maxLength: 512, minLength: 1
186
180187 - `type: "web_search_result_location"`
181188
182 - `"web_search_result_location"`
183
184189 - `url: string`
185190
186 - `CitationSearchResultLocationParam object { cited_text, end_block_index, search_result_index, 4 more }`
191 minLength: 1
192
193 - `CitationSearchResultLocationParam object`
187194
188195 - `cited_text: string`
189196
from line 210
203210
204211 Counted separately from `document_index`; server-side web search results are not included in this count.
205212
213 minimum: 0
214
206215 - `source: string`
207216
208217 - `start_block_index: number`
209218
210219 0-based index of the first cited block in the source's `content` array.
211220
221 minimum: 0
222
212223 - `title: string or null`
213224
214225 - `type: "search_result_location"`
215226
216 - `"search_result_location"`
217
218 - `ImageBlockParam object { source, type, cache_control, transformations }`
227 - `ImageBlockParam object`
219228
220229 - `source: Base64ImageSource or URLImageSource or FileImageSource`
221230
222 - `Base64ImageSource object { data, media_type, type }`
231 - `Base64ImageSource object`
223232
224233 - `data: string`
225234
235 format: byte
236
226237 - `media_type: "image/jpeg" or "image/png" or "image/gif" or "image/webp"`
227238
228239 - `"image/jpeg"`
from line 246
235246
236247 - `type: "base64"`
237248
238 - `"base64"`
239
240 - `URLImageSource object { type, url }`
249 - `URLImageSource object`
241250
242251 - `type: "url"`
243252
244 - `"url"`
245
246253 - `url: string`
247254
248 - `FileImageSource object { file_id, type }`
255 - `FileImageSource object`
249256
250257 - `file_id: string`
251258
252259 - `type: "file"`
253260
254 - `"file"`
255
256261 - `type: "image"`
257262
258 - `"image"`
259
260263 - `cache_control: optional CacheControlEphemeral or null`
261264
262265 Create a cache control breakpoint at this content block.
from line 276
273276
274277 - `"error"`
275278
276 - `DocumentBlockParam object { source, type, cache_control, 3 more }`
279 - `DocumentBlockParam object`
277280
278281 - `source: Base64PDFSource or PlainTextSource or ContentBlockSource or 2 more`
279282
280 - `Base64PDFSource object { data, media_type, type }`
283 - `Base64PDFSource object`
281284
282285 - `data: string`
283286
287 format: byte
288
284289 - `media_type: "application/pdf"`
285290
286 - `"application/pdf"`
287
288291 - `type: "base64"`
289292
290 - `"base64"`
291
292 - `PlainTextSource object { data, media_type, type }`
293 - `PlainTextSource object`
293294
294295 - `data: string`
295296
296297 - `media_type: "text/plain"`
297298
298 - `"text/plain"`
299
300299 - `type: "text"`
301300
302 - `"text"`
303
304 - `ContentBlockSource object { content, type }`
301 - `ContentBlockSource object`
305302
306303 - `content: string or array of ContentBlockSourceContent`
307304
from line 306
309306
310307 - `ContentBlockSourceContent = array of ContentBlockSourceContent`
311308
312 - `TextBlockParam object { text, type, cache_control, citations }`
313
314 - `ImageBlockParam object { source, type, cache_control, transformations }`
309 - `TextBlockParam object`
310
311 - `ImageBlockParam object`
315312
316313 - `type: "content"`
317314
318 - `"content"`
319
320 - `URLPDFSource object { type, url }`
315 - `URLPDFSource object`
321316
322317 - `type: "url"`
323318
324 - `"url"`
325
326319 - `url: string`
327320
328 - `FileDocumentSource object { file_id, type }`
321 - `FileDocumentSource object`
329322
330323 - `file_id: string`
331324
332325 - `type: "file"`
333326
334 - `"file"`
335
336327 - `type: "document"`
337328
338 - `"document"`
339
340329 - `cache_control: optional CacheControlEphemeral or null`
341330
342331 Create a cache control breakpoint at this content block.
from line 336
347336
348337 - `context: optional string or null`
349338
339 minLength: 1
340
350341 - `title: optional string or null`
351342
352 - `SearchResultBlockParam object { content, source, title, 3 more }`
343 maxLength: 500, minLength: 1
344
345 - `SearchResultBlockParam object`
353346
354347 - `content: array of TextBlockParam`
355348
356349 - `text: string`
357350
351 minLength: 1
352
358353 - `type: "text"`
359354
360355 - `cache_control: optional CacheControlEphemeral or null`
from line 364
369364
370365 - `type: "search_result"`
371366
372 - `"search_result"`
373
374367 - `cache_control: optional CacheControlEphemeral or null`
375368
376369 Create a cache control breakpoint at this content block.
377370
378371 - `citations: optional CitationsConfigParam`
379372
380 - `ThinkingBlockParam object { signature, thinking, type }`
373 - `ThinkingBlockParam object`
381374
382375 - `signature: string`
383376
from line 384
391384
392385 - `type: "thinking"`
393386
394 - `"thinking"`
395
396 - `RedactedThinkingBlockParam object { data, type }`
387 - `RedactedThinkingBlockParam object`
397388
398389 - `data: string`
399390
from line 392
401392
402393 - `type: "redacted_thinking"`
403394
404 - `"redacted_thinking"`
405
406 - `ToolUseBlockParam object { id, input, name, 4 more }`
395 - `ToolUseBlockParam object`
407396
408397 - `id: string`
409398
399 pattern: ^[a-zA-Z0-9_-]+$
400
410401 - `input: map[unknown]`
411402
412403 - `name: string`
413404
405 maxLength: 200, minLength: 1
406
414407 - `type: "tool_use"`
415408
416 - `"tool_use"`
417
418409 - `cache_control: optional CacheControlEphemeral or null`
419410
420411 Create a cache control breakpoint at this content block.
from line 414
423414
424415 Tool invocation directly from the model.
425416
426 - `DirectCaller object { type }`
417 - `DirectCaller object`
427418
428419 Tool invocation directly from the model.
429420
430421 - `type: "direct"`
431422
432 - `"direct"`
433
434 - `ServerToolCaller object { tool_id, type }`
423 - `ServerToolCaller object`
435424
436425 Tool invocation generated by a server-side tool.
437426
438427 - `tool_id: string`
439428
429 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
430
440431 - `type: "code_execution_20250825"`
441432
442 - `"code_execution_20250825"`
443
444 - `ServerToolCaller20260120 object { tool_id, type }`
433 - `ServerToolCaller20260120 object`
445434
446435 - `tool_id: string`
447436
437 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
438
448439 - `type: "code_execution_20260120"`
449440
450 - `"code_execution_20260120"`
451
452441 - `toolset_name: optional string or null`
453442
454443 For a toolset member tool_use, the toolset family this member belongs to.
455444
456 - `ToolResultBlockParam object { tool_use_id, type, cache_control, 3 more }`
445 maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$
446
447 - `ToolResultBlockParam object`
457448
458449 - `tool_use_id: string`
459450
451 pattern: ^[a-zA-Z0-9_-]+$
452
460453 - `type: "tool_result"`
461454
462 - `"tool_result"`
463
464455 - `cache_control: optional CacheControlEphemeral or null`
465456
466457 Create a cache control breakpoint at this content block.
from line 462
471462
472463 - `array of TextBlockParam or ImageBlockParam or SearchResultBlockParam or 3 more`
473464
474 - `TextBlockParam object { text, type, cache_control, citations }`
475
476 - `ImageBlockParam object { source, type, cache_control, transformations }`
477
478 - `SearchResultBlockParam object { content, source, title, 3 more }`
479
480 - `DocumentBlockParam object { source, type, cache_control, 3 more }`
481
482 - `ToolReferenceBlockParam object { tool_name, type, cache_control }`
465 - `TextBlockParam object`
466
467 - `ImageBlockParam object`
468
469 - `SearchResultBlockParam object`
470
471 - `DocumentBlockParam object`
472
473 - `ToolReferenceBlockParam object`
483474
484475 Tool reference block that can be included in tool_result content.
485476
486477 - `tool_name: string`
487478
479 maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$
480
488481 - `type: "tool_reference"`
489482
490 - `"tool_reference"`
491
492483 - `cache_control: optional CacheControlEphemeral or null`
493484
494485 Create a cache control breakpoint at this content block.
495486
496 - `BrowserStateBlockParam object { tabs, type, cache_control, state_changes }`
487 - `BrowserStateBlockParam object`
497488
498489 The caller's browser state after a browser toolset member call —
499490 the full inventory of open tabs, which tab is active, and any side
from line 498
507498
508499 All tabs open in the browser after this call — the full inventory, not a delta. May be empty. Whenever non-empty, exactly one entry carries `active: true`.
509500
501 maxItems: 100
502
510503 - `tab_id: string`
511504
512505 The caller-assigned identifier for this tab, unique within the inventory.
513506
507 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
508
514509 - `title: string`
515510
516511 The title of the page the tab is showing. May be empty.
517512
513 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
514
518515 - `url: string`
519516
520517 The URL of the page the tab is showing. May be empty.
521518
519 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
520
522521 - `active: optional boolean`
523522
524523 Whether this tab is the active tab after this call. Whenever `tabs` is non-empty, exactly one entry is marked `active: true`.
525524
526525 - `type: "browser_state"`
527526
528 - `"browser_state"`
529
530527 - `cache_control: optional CacheControlEphemeral or null`
531528
532529 Create a cache control breakpoint at this content block.
from line 532
535532
536533 Tabs opened and download state changes during this call. "Nothing to report" is expressed by omitting the field, never by an empty list.
537534
538 - `BrowserStateChangeTabOpened object { tab_id, type }`
535 maxItems: 200, minItems: 1
536
537 - `BrowserStateChangeTabOpened object`
539538
540539 A tab this call's execution opened that remains open at its end —
541540 the creation delta of the `tabs` inventory, not an event log.
from line 548
549548
550549 The `tab_id` of the opened tab, present in `tabs`.
551550
551 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
552
552553 - `type: "tab_opened"`
553554
554 - `"tab_opened"`
555
556 - `BrowserStateChangeDownloadStarted object { download_id, type, url }`
555 - `BrowserStateChangeDownloadStarted object`
557556
558557 A file download that started during this call.
559558
from line 560
561560
562561 The caller-assigned identifier for this download, stable across the state changes reporting it.
563562
563 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
564
564565 - `type: "download_started"`
565566
566 - `"download_started"`
567
568567 - `url: string`
569568
570569 The final post-redirect URL the download was served from.
571570
572 - `BrowserStateChangeDownloadCompleted object { download_id, type, url, 2 more }`
571 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
572
573 - `BrowserStateChangeDownloadCompleted object`
573574
574575 A file download that finished during this call, reported with the
575576 same `download_id` as its `download_started` — or without a prior
from line 581
580581
581582 The caller-assigned identifier for this download, stable across the state changes reporting it.
582583
584 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
585
583586 - `type: "download_completed"`
584587
585 - `"download_completed"`
586
587588 - `url: string`
588589
589590 The final post-redirect URL the download was served from.
590591
592 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
593
591594 - `path: optional string or null`
592595
593596 Where the executor saved the file, on the executor's filesystem. Only included when another tool in the same environment can read the file at that path.
594597
598 pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096
599
595600 - `size_bytes: optional number or null`
596601
597602 The completed download's size.
598603
599 - `BrowserStateChangeDownloadFailed object { download_id, type, url, error }`
604 minimum: 0
605
606 - `BrowserStateChangeDownloadFailed object`
600607
601608 A file download that failed — or was cancelled — during this call.
602609
from line 611
604611
605612 The caller-assigned identifier for this download, stable across the state changes reporting it.
606613
614 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
615
607616 - `type: "download_failed"`
608617
609 - `"download_failed"`
610
611618 - `url: string`
612619
613620 The final post-redirect URL the download was served from.
614621
622 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
623
615624 - `error: optional string or null`
616625
617626 The failure or cancellation detail, when known.
618627
628 pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096
629
619630 - `is_error: optional boolean`
620631
621632 - `toolset_name: optional string or null`
622633
623634 For a toolset member tool_result, the toolset family of the paired tool_use.
624635
625 - `ServerToolUseBlockParam object { id, input, name, 3 more }`
636 maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$
637
638 - `ServerToolUseBlockParam object`
626639
627640 - `id: string`
628641
642 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
643
629644 - `input: map[unknown]`
630645
631646 - `name: "web_search" or "web_fetch" or "code_execution" or 4 more`
from line 661
646661
647662 - `type: "server_tool_use"`
648663
649 - `"server_tool_use"`
650
651664 - `cache_control: optional CacheControlEphemeral or null`
652665
653666 Create a cache control breakpoint at this content block.
from line 669
656669
657670 Tool invocation directly from the model.
658671
659 - `DirectCaller object { type }`
672 - `DirectCaller object`
660673
661674 Tool invocation directly from the model.
662675
663 - `ServerToolCaller object { tool_id, type }`
676 - `ServerToolCaller object`
664677
665678 Tool invocation generated by a server-side tool.
666679
667 - `ServerToolCaller20260120 object { tool_id, type }`
668
669 - `WebSearchToolResultBlockParam object { content, tool_use_id, type, 2 more }`
680 - `ServerToolCaller20260120 object`
681
682 - `WebSearchToolResultBlockParam object`
670683
671684 - `content: WebSearchToolResultBlockParamContent`
672685
from line 691
678691
679692 - `type: "web_search_result"`
680693
681 - `"web_search_result"`
682
683694 - `url: string`
684695
685696 - `page_age: optional string or null`
686697
687 - `WebSearchToolRequestError object { error_code, type }`
698 - `WebSearchToolRequestError object`
688699
689700 - `error_code: WebSearchToolResultErrorCode`
690701
from line 713
702713
703714 - `type: "web_search_tool_result_error"`
704715
705 - `"web_search_tool_result_error"`
706
707716 - `tool_use_id: string`
708717
718 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
719
709720 - `type: "web_search_tool_result"`
710721
711 - `"web_search_tool_result"`
712
713722 - `cache_control: optional CacheControlEphemeral or null`
714723
715724 Create a cache control breakpoint at this content block.
from line 727
718727
719728 Tool invocation directly from the model.
720729
721 - `DirectCaller object { type }`
730 - `DirectCaller object`
722731
723732 Tool invocation directly from the model.
724733
725 - `ServerToolCaller object { tool_id, type }`
734 - `ServerToolCaller object`
726735
727736 Tool invocation generated by a server-side tool.
728737
729 - `ServerToolCaller20260120 object { tool_id, type }`
730
731 - `WebFetchToolResultBlockParam object { content, tool_use_id, type, 2 more }`
738 - `ServerToolCaller20260120 object`
739
740 - `WebFetchToolResultBlockParam object`
732741
733742 - `content: WebFetchToolResultErrorBlockParam or WebFetchBlockParam`
734743
735 - `WebFetchToolResultErrorBlockParam object { error_code, type }`
744 - `WebFetchToolResultErrorBlockParam object`
736745
737746 - `error_code: WebFetchToolResultErrorCode`
738747
from line 765
756765
757766 - `type: "web_fetch_tool_result_error"`
758767
759 - `"web_fetch_tool_result_error"`
760
761 - `WebFetchBlockParam object { content, type, url, retrieved_at }`
768 - `WebFetchBlockParam object`
762769
763770 - `content: DocumentBlockParam`
764771
765772 - `type: "web_fetch_result"`
766773
767 - `"web_fetch_result"`
768
769774 - `url: string`
770775
771776 Fetched content URL
from line 781
776781
777782 - `tool_use_id: string`
778783
784 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
785
779786 - `type: "web_fetch_tool_result"`
780787
781 - `"web_fetch_tool_result"`
782
783788 - `cache_control: optional CacheControlEphemeral or null`
784789
785790 Create a cache control breakpoint at this content block.
from line 793
788793
789794 Tool invocation directly from the model.
790795
791 - `DirectCaller object { type }`
796 - `DirectCaller object`
792797
793798 Tool invocation directly from the model.
794799
795 - `ServerToolCaller object { tool_id, type }`
800 - `ServerToolCaller object`
796801
797802 Tool invocation generated by a server-side tool.
798803
799 - `ServerToolCaller20260120 object { tool_id, type }`
800
801 - `CodeExecutionToolResultBlockParam object { content, tool_use_id, type, cache_control }`
804 - `ServerToolCaller20260120 object`
805
806 - `CodeExecutionToolResultBlockParam object`
802807
803808 - `content: CodeExecutionToolResultBlockParamContent`
804809
805810 Code execution result with encrypted stdout for PFC + web_search results.
806811
807 - `CodeExecutionToolResultErrorParam object { error_code, type }`
812 - `CodeExecutionToolResultErrorParam object`
808813
809814 - `error_code: CodeExecutionToolResultErrorCode`
810815
from line 823
818823
819824 - `type: "code_execution_tool_result_error"`
820825
821 - `"code_execution_tool_result_error"`
822
823 - `CodeExecutionResultBlockParam object { content, return_code, stderr, 2 more }`
826 - `CodeExecutionResultBlockParam object`
824827
825828 - `content: array of CodeExecutionOutputBlockParam`
826829
from line 831
828831
829832 - `type: "code_execution_output"`
830833
831 - `"code_execution_output"`
832
833834 - `return_code: number`
834835
835836 - `stderr: string`
from line 839
838839
839840 - `type: "code_execution_result"`
840841
841 - `"code_execution_result"`
842
843 - `EncryptedCodeExecutionResultBlockParam object { content, encrypted_stdout, return_code, 2 more }`
842 - `EncryptedCodeExecutionResultBlockParam object`
844843
845844 Code execution result with encrypted stdout for PFC + web_search results.
846845
from line 857
858857
859858 - `type: "encrypted_code_execution_result"`
860859
861 - `"encrypted_code_execution_result"`
862
863860 - `tool_use_id: string`
864861
862 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
863
865864 - `type: "code_execution_tool_result"`
866865
867 - `"code_execution_tool_result"`
868
869866 - `cache_control: optional CacheControlEphemeral or null`
870867
871868 Create a cache control breakpoint at this content block.
872869
873 - `BashCodeExecutionToolResultBlockParam object { content, tool_use_id, type, cache_control }`
870 - `BashCodeExecutionToolResultBlockParam object`
874871
875872 - `content: BashCodeExecutionToolResultErrorParam or BashCodeExecutionResultBlockParam`
876873
877 - `BashCodeExecutionToolResultErrorParam object { error_code, type }`
874 - `BashCodeExecutionToolResultErrorParam object`
878875
879876 - `error_code: BashCodeExecutionToolResultErrorCode`
880877
from line 887
890887
891888 - `type: "bash_code_execution_tool_result_error"`
892889
893 - `"bash_code_execution_tool_result_error"`
894
895 - `BashCodeExecutionResultBlockParam object { content, return_code, stderr, 2 more }`
890 - `BashCodeExecutionResultBlockParam object`
896891
897892 - `content: array of BashCodeExecutionOutputBlockParam`
898893
from line 895
900895
901896 - `type: "bash_code_execution_output"`
902897
903 - `"bash_code_execution_output"`
904
905898 - `return_code: number`
906899
907900 - `stderr: string`
from line 903
910903
911904 - `type: "bash_code_execution_result"`
912905
913 - `"bash_code_execution_result"`
914
915906 - `tool_use_id: string`
916907
908 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
909
917910 - `type: "bash_code_execution_tool_result"`
918911
919 - `"bash_code_execution_tool_result"`
920
921912 - `cache_control: optional CacheControlEphemeral or null`
922913
923914 Create a cache control breakpoint at this content block.
924915
925 - `TextEditorCodeExecutionToolResultBlockParam object { content, tool_use_id, type, cache_control }`
916 - `TextEditorCodeExecutionToolResultBlockParam object`
926917
927918 - `content: TextEditorCodeExecutionToolResultErrorParam or TextEditorCodeExecutionViewResultBlockParam or TextEditorCodeExecutionCreateResultBlockParam or TextEditorCodeExecutionStrReplaceResultBlockParam`
928919
929 - `TextEditorCodeExecutionToolResultErrorParam object { error_code, type, error_message }`
920 - `TextEditorCodeExecutionToolResultErrorParam object`
930921
931922 - `error_code: TextEditorCodeExecutionToolResultErrorCode`
932923
from line 933
942933
943934 - `type: "text_editor_code_execution_tool_result_error"`
944935
945 - `"text_editor_code_execution_tool_result_error"`
946
947936 - `error_message: optional string or null`
948937
949 - `TextEditorCodeExecutionViewResultBlockParam object { content, file_type, type, 3 more }`
938 - `TextEditorCodeExecutionViewResultBlockParam object`
950939
951940 - `content: string`
952941
from line 949
960949
961950 - `type: "text_editor_code_execution_view_result"`
962951
963 - `"text_editor_code_execution_view_result"`
964
965952 - `num_lines: optional number or null`
966953
967954 - `start_line: optional number or null`
968955
969956 - `total_lines: optional number or null`
970957
971 - `TextEditorCodeExecutionCreateResultBlockParam object { is_file_update, type }`
958 - `TextEditorCodeExecutionCreateResultBlockParam object`
972959
973960 - `is_file_update: boolean`
974961
975962 - `type: "text_editor_code_execution_create_result"`
976963
977 - `"text_editor_code_execution_create_result"`
978
979 - `TextEditorCodeExecutionStrReplaceResultBlockParam object { type, lines, new_lines, 3 more }`
964 - `TextEditorCodeExecutionStrReplaceResultBlockParam object`
980965
981966 - `type: "text_editor_code_execution_str_replace_result"`
982967
983 - `"text_editor_code_execution_str_replace_result"`
984
985968 - `lines: optional array of string or null`
986969
987970 - `new_lines: optional number or null`
from line 977
994977
995978 - `tool_use_id: string`
996979
980 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
981
997982 - `type: "text_editor_code_execution_tool_result"`
998983
999 - `"text_editor_code_execution_tool_result"`
1000
1001984 - `cache_control: optional CacheControlEphemeral or null`
1002985
1003986 Create a cache control breakpoint at this content block.
1004987
1005 - `ToolSearchToolResultBlockParam object { content, tool_use_id, type, cache_control }`
988 - `ToolSearchToolResultBlockParam object`
1006989
1007990 - `content: ToolSearchToolResultErrorParam or ToolSearchToolSearchResultBlockParam`
1008991
1009 - `ToolSearchToolResultErrorParam object { error_code, type, error_message }`
992 - `ToolSearchToolResultErrorParam object`
1010993
1011994 - `error_code: ToolSearchToolResultErrorCode`
1012995
from line 1003
10201003
10211004 - `type: "tool_search_tool_result_error"`
10221005
1023 - `"tool_search_tool_result_error"`
1024
10251006 - `error_message: optional string or null`
10261007
1027 - `ToolSearchToolSearchResultBlockParam object { tool_references, type }`
1008 - `ToolSearchToolSearchResultBlockParam object`
10281009
10291010 - `tool_references: array of ToolReferenceBlockParam`
10301011
10311012 - `tool_name: string`
10321013
1014 maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$
1015
10331016 - `type: "tool_reference"`
10341017
10351018 - `cache_control: optional CacheControlEphemeral or null`
from line 1021
10381021
10391022 - `type: "tool_search_tool_search_result"`
10401023
1041 - `"tool_search_tool_search_result"`
1042
10431024 - `tool_use_id: string`
10441025
1026 pattern: ^srvtoolu_[a-zA-Z0-9_]+$
1027
10451028 - `type: "tool_search_tool_result"`
10461029
1047 - `"tool_search_tool_result"`
1048
10491030 - `cache_control: optional CacheControlEphemeral or null`
10501031
10511032 Create a cache control breakpoint at this content block.
10521033
1053 - `ContainerUploadBlockParam object { file_id, type, cache_control }`
1034 - `ContainerUploadBlockParam object`
10541035
10551036 A content block that represents a file to be uploaded to the container
10561037 Files uploaded via this block will be available in the container's input directory.
from line 1040
10591040
10601041 - `type: "container_upload"`
10611042
1062 - `"container_upload"`
1063
10641043 - `cache_control: optional CacheControlEphemeral or null`
10651044
10661045 Create a cache control breakpoint at this content block.
from line 1158
11791158
11801159 - `type: "json_schema"`
11811160
1182 - `"json_schema"`
1183
11841161- `system: optional string or array of TextBlockParam`
11851162
11861163 System prompt.
from line 1170
11931170
11941171 - `text: string`
11951172
1173 minLength: 1
1174
11961175 - `type: "text"`
11971176
11981177 - `cache_control: optional CacheControlEphemeral or null`
from line 1188
12091188
12101189 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
12111190
1212 - `ThinkingConfigEnabled object { budget_tokens, type, display }`
1191 - `ThinkingConfigEnabled object`
12131192
12141193 - `budget_tokens: number`
12151194
from line 1198
12191198
12201199 See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.
12211200
1201 minimum: 1024
1202
12221203 - `type: "enabled"`
12231204
1224 - `"enabled"`
1225
12261205 - `display: optional "summarized" or "omitted" or null`
12271206
12281207 Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.
from line 1210
12311210
12321211 - `"omitted"`
12331212
1234 - `ThinkingConfigDisabled object { type }`
1213 - `ThinkingConfigDisabled object`
12351214
12361215 - `type: "disabled"`
12371216
1238 - `"disabled"`
1239
1240 - `ThinkingConfigAdaptive object { type, display }`
1217 - `ThinkingConfigAdaptive object`
12411218
12421219 - `type: "adaptive"`
12431220
1244 - `"adaptive"`
1245
12461221 - `display: optional "summarized" or "omitted" or null`
12471222
12481223 Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.
from line 1230
12551230
12561231 How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.
12571232
1258 - `ToolChoiceAuto object { type, disable_parallel_tool_use }`
1233 - `ToolChoiceAuto object`
12591234
12601235 The model will automatically decide whether to use tools.
12611236
12621237 - `type: "auto"`
12631238
1264 - `"auto"`
1265
12661239 - `disable_parallel_tool_use: optional boolean`
12671240
12681241 Whether to disable parallel tool use.
12691242
12701243 Defaults to `false`. If set to `true`, the model will output at most one tool use.
12711244
1272 - `ToolChoiceAny object { type, disable_parallel_tool_use }`
1245 - `ToolChoiceAny object`
12731246
12741247 The model will use any available tools.
12751248
12761249 - `type: "any"`
12771250
1278 - `"any"`
1279
12801251 - `disable_parallel_tool_use: optional boolean`
12811252
12821253 Whether to disable parallel tool use.
12831254
12841255 Defaults to `false`. If set to `true`, the model will output exactly one tool use.
12851256
1286 - `ToolChoiceTool object { name, type, disable_parallel_tool_use }`
1257 - `ToolChoiceTool object`
12871258
12881259 The model will use the specified tool with `tool_choice.name`.
12891260
from line 1264
12931264
12941265 - `type: "tool"`
12951266
1296 - `"tool"`
1297
12981267 - `disable_parallel_tool_use: optional boolean`
12991268
13001269 Whether to disable parallel tool use.
13011270
13021271 Defaults to `false`. If set to `true`, the model will output exactly one tool use.
13031272
1304 - `ToolChoiceNone object { type }`
1273 - `ToolChoiceNone object`
13051274
13061275 The model will not be allowed to use tools.
13071276
13081277 - `type: "none"`
1309
1310 - `"none"`
13111278
13121279- `tools: optional array of MessageCountTokensTool`
13131280
from line 1340
13731340
13741341 See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.
13751342
1376 - `Tool object { input_schema, name, allowed_callers, 7 more }`
1377
1378 - `input_schema: object { type, properties, required }`
1343 - `Tool object`
1344
1345 - `input_schema: object`
13791346
13801347 [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
13811348
from line 1350
13831350
13841351 - `type: "object"`
13851352
1386 - `"object"`
1387
13881353 - `properties: optional map[unknown] or null`
13891354
13901355 - `required: optional array of string or null`
from line 1360
13951360
13961361 This is how the tool will be called by the model and in `tool_use` blocks.
13971362
1363 maxLength: 128, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,128}$
1364
13981365 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
13991366
14001367 - `"direct"`
from line 1398
14311398
14321399 - `type: optional "custom" or null`
14331400
1434 - `"custom"`
1435
1436 - `ToolBash20250124 object { name, type, allowed_callers, 4 more }`
1401 - `ToolBash20250124 object`
14371402
14381403 - `name: "bash"`
14391404
from line 1406
14411406
14421407 This is how the tool will be called by the model and in `tool_use` blocks.
14431408
1444 - `"bash"`
1445
14461409 - `type: "bash_20250124"`
14471410
1448 - `"bash_20250124"`
1449
14501411 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
14511412
14521413 - `"direct"`
from line 1432
14711432
14721433 When true, guarantees schema validation on tool names and inputs
14731434
1474 - `CodeExecutionTool20250522 object { name, type, allowed_callers, 3 more }`
1435 - `CodeExecutionTool20250522 object`
14751436
14761437 - `name: "code_execution"`
14771438
from line 1440
14791440
14801441 This is how the tool will be called by the model and in `tool_use` blocks.
14811442
1482 - `"code_execution"`
1483
14841443 - `type: "code_execution_20250522"`
14851444
1486 - `"code_execution_20250522"`
1487
14881445 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
14891446
14901447 - `"direct"`
from line 1464
15071464
15081465 When true, guarantees schema validation on tool names and inputs
15091466
1510 - `CodeExecutionTool20250825 object { name, type, allowed_callers, 3 more }`
1467 - `CodeExecutionTool20250825 object`
15111468
15121469 - `name: "code_execution"`
15131470
from line 1472
15151472
15161473 This is how the tool will be called by the model and in `tool_use` blocks.
15171474
1518 - `"code_execution"`
1519
15201475 - `type: "code_execution_20250825"`
15211476
1477 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
1478
1479 - `"direct"`
1480
15221481 - `"code_execution_20250825"`
15231482
1483 - `"code_execution_20260120"`
1484
1485 - `"code_execution_20260521"`
1486
1487 - `cache_control: optional CacheControlEphemeral or null`
1488
1489 Create a cache control breakpoint at this content block.
1490
1491 - `defer_loading: optional boolean`
1492
1493 If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
1494
1495 - `strict: optional boolean`
1496
1497 When true, guarantees schema validation on tool names and inputs
1498
1499 - `CodeExecutionTool20260120 object`
1500
1501 Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).
1502
1503 - `name: "code_execution"`
1504
1505 Name of the tool.
1506
1507 This is how the tool will be called by the model and in `tool_use` blocks.
1508
1509 - `type: "code_execution_20260120"`
1510
15241511 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
15251512
15261513 - `"direct"`
from line 1530
15431530
15441531 When true, guarantees schema validation on tool names and inputs
15451532
1546 - `CodeExecutionTool20260120 object { name, type, allowed_callers, 3 more }`
1547
1548 Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).
1533 - `CodeExecutionTool20260521 object`
1534
1535 Code execution tool with REPL state persistence.
15491536
15501537 - `name: "code_execution"`
15511538
from line 1540
15531540
15541541 This is how the tool will be called by the model and in `tool_use` blocks.
15551542
1556 - `"code_execution"`
1557
1558 - `type: "code_execution_20260120"`
1543 - `type: "code_execution_20260521"`
1544
1545 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
1546
1547 - `"direct"`
1548
1549 - `"code_execution_20250825"`
15591550
15601551 - `"code_execution_20260120"`
15611552
1562 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
1563
1564 - `"direct"`
1565
1566 - `"code_execution_20250825"`
1567
1568 - `"code_execution_20260120"`
1569
15701553 - `"code_execution_20260521"`
15711554
15721555 - `cache_control: optional CacheControlEphemeral or null`
from line 1564
15811564
15821565 When true, guarantees schema validation on tool names and inputs
15831566
1584 - `CodeExecutionTool20260521 object { name, type, allowed_callers, 3 more }`
1585
1586 Code execution tool with REPL state persistence.
1587
1588 - `name: "code_execution"`
1589
1590 Name of the tool.
1591
1592 This is how the tool will be called by the model and in `tool_use` blocks.
1593
1594 - `"code_execution"`
1595
1596 - `type: "code_execution_20260521"`
1597
1598 - `"code_execution_20260521"`
1599
1600 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
1601
1602 - `"direct"`
1603
1604 - `"code_execution_20250825"`
1605
1606 - `"code_execution_20260120"`
1607
1608 - `"code_execution_20260521"`
1609
1610 - `cache_control: optional CacheControlEphemeral or null`
1611
1612 Create a cache control breakpoint at this content block.
1613
1614 - `defer_loading: optional boolean`
1615
1616 If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.
1617
1618 - `strict: optional boolean`
1619
1620 When true, guarantees schema validation on tool names and inputs
1621
1622 - `BrowserToolset20260801 object { type, allowed_callers, cache_control, configs }`
1567 - `BrowserToolset20260801 object`
16231568
16241569 The browser toolset: a single `tools[]` entry (carrying no
16251570 `name`) that declares the browser tool family. The model is served
from line 1572
16271572 from its schema.
16281573
16291574 - `type: "browser_toolset_20260801"`
1630
1631 - `"browser_toolset_20260801"`
16321575
16331576 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
16341577
from line 1968
20251968
20261969 Whether this member is offered to the model. Default is per member, per the toolset's documentation. A member whose enabled resolves false is withheld from the served schema.
20271970
2028 - `MemoryTool20250818 object { name, type, allowed_callers, 4 more }`
1971 - `MemoryTool20250818 object`
20291972
20301973 - `name: "memory"`
20311974
from line 1976
20331976
20341977 This is how the tool will be called by the model and in `tool_use` blocks.
20351978
2036 - `"memory"`
2037
20381979 - `type: "memory_20250818"`
20391980
2040 - `"memory_20250818"`
2041
20421981 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
20431982
20441983 - `"direct"`
from line 2002
20632002
20642003 When true, guarantees schema validation on tool names and inputs
20652004
2066 - `ComputerToolset20260801 object { type, allowed_callers, cache_control, configs }`
2005 - `ComputerToolset20260801 object`
20672006
20682007 The computer toolset: a single `tools[]` entry (carrying no
20692008 `name`) that declares the computer tool family. The model is
from line 2015
20762015
20772016 - `type: "computer_toolset_20260801"`
20782017
2079 - `"computer_toolset_20260801"`
2080
20812018 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
20822019
20832020 - `"direct"`
from line 2242
23052242
23062243 Whether this member is offered to the model. Default is per member, per the toolset's documentation. A member whose enabled resolves false is withheld from the served schema.
23072244
2308 - `ToolTextEditor20250124 object { name, type, allowed_callers, 4 more }`
2245 - `ToolTextEditor20250124 object`
23092246
23102247 - `name: "str_replace_editor"`
23112248
from line 2250
23132250
23142251 This is how the tool will be called by the model and in `tool_use` blocks.
23152252
2316 - `"str_replace_editor"`
2317
23182253 - `type: "text_editor_20250124"`
23192254
2320 - `"text_editor_20250124"`
2321
23222255 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
23232256
23242257 - `"direct"`
from line 2276
23432276
23442277 When true, guarantees schema validation on tool names and inputs
23452278
2346 - `ToolTextEditor20250429 object { name, type, allowed_callers, 4 more }`
2279 - `ToolTextEditor20250429 object`
23472280
23482281 - `name: "str_replace_based_edit_tool"`
23492282
from line 2284
23512284
23522285 This is how the tool will be called by the model and in `tool_use` blocks.
23532286
2354 - `"str_replace_based_edit_tool"`
2355
23562287 - `type: "text_editor_20250429"`
23572288
2358 - `"text_editor_20250429"`
2359
23602289 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
23612290
23622291 - `"direct"`
from line 2310
23812310
23822311 When true, guarantees schema validation on tool names and inputs
23832312
2384 - `ToolTextEditor20250728 object { name, type, allowed_callers, 5 more }`
2313 - `ToolTextEditor20250728 object`
23852314
23862315 - `name: "str_replace_based_edit_tool"`
23872316
from line 2318
23892318
23902319 This is how the tool will be called by the model and in `tool_use` blocks.
23912320
2392 - `"str_replace_based_edit_tool"`
2393
23942321 - `type: "text_editor_20250728"`
23952322
2396 - `"text_editor_20250728"`
2397
23982323 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
23992324
24002325 - `"direct"`
from line 2344
24192344
24202345 Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.
24212346
2347 minimum: 1
2348
24222349 - `strict: optional boolean`
24232350
24242351 When true, guarantees schema validation on tool names and inputs
24252352
2426 - `WebSearchTool20250305 object { name, type, allowed_callers, 7 more }`
2353 - `WebSearchTool20250305 object`
24272354
24282355 - `name: "web_search"`
24292356
from line 2358
24312358
24322359 This is how the tool will be called by the model and in `tool_use` blocks.
24332360
2434 - `"web_search"`
2435
24362361 - `type: "web_search_20250305"`
24372362
2438 - `"web_search_20250305"`
2439
24402363 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
24412364
24422365 - `"direct"`
from line 2390
24672390
24682391 Maximum number of times the tool can be used in the API request.
24692392
2393 exclusiveMinimum: 0
2394
24702395 - `strict: optional boolean`
24712396
24722397 When true, guarantees schema validation on tool names and inputs
from line 2402
24772402
24782403 - `type: "approximate"`
24792404
2480 - `"approximate"`
2481
24822405 - `city: optional string or null`
24832406
24842407 The city of the user.
24852408
2409 maxLength: 255, minLength: 1
2410
24862411 - `country: optional string or null`
24872412
24882413 The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.
24892414
2415 maxLength: 2, minLength: 2
2416
24902417 - `region: optional string or null`
24912418
24922419 The region of the user.
24932420
2421 maxLength: 255, minLength: 1
2422
24942423 - `timezone: optional string or null`
24952424
24962425 The [IANA timezone](https://nodatime.org/TimeZones) of the user.
24972426
2498 - `WebFetchTool20250910 object { name, type, allowed_callers, 8 more }`
2427 maxLength: 255, minLength: 1
2428
2429 - `WebFetchTool20250910 object`
24992430
25002431 - `name: "web_fetch"`
25012432
from line 2434
25032434
25042435 This is how the tool will be called by the model and in `tool_use` blocks.
25052436
2506 - `"web_fetch"`
2507
25082437 - `type: "web_fetch_20250910"`
25092438
2510 - `"web_fetch_20250910"`
2511
25122439 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
25132440
25142441 - `"direct"`
from line 2470
25432470
25442471 Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
25452472
2473 exclusiveMinimum: 0
2474
25462475 - `max_uses: optional number or null`
25472476
25482477 Maximum number of times the tool can be used in the API request.
25492478
2479 exclusiveMinimum: 0
2480
25502481 - `strict: optional boolean`
25512482
25522483 When true, guarantees schema validation on tool names and inputs
25532484
2554 - `WebSearchTool20260209 object { name, type, allowed_callers, 7 more }`
2485 - `WebSearchTool20260209 object`
25552486
25562487 - `name: "web_search"`
25572488
from line 2490
25592490
25602491 This is how the tool will be called by the model and in `tool_use` blocks.
25612492
2562 - `"web_search"`
2563
25642493 - `type: "web_search_20260209"`
25652494
2566 - `"web_search_20260209"`
2567
25682495 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
25692496
25702497 - `"direct"`
from line 2522
25952522
25962523 Maximum number of times the tool can be used in the API request.
25972524
2525 exclusiveMinimum: 0
2526
25982527 - `strict: optional boolean`
25992528
26002529 When true, guarantees schema validation on tool names and inputs
from line 2532
26032532
26042533 Parameters for the user's location. Used to provide more relevant search results.
26052534
2606 - `WebFetchTool20260209 object { name, type, allowed_callers, 8 more }`
2535 - `WebFetchTool20260209 object`
26072536
26082537 - `name: "web_fetch"`
26092538
from line 2540
26112540
26122541 This is how the tool will be called by the model and in `tool_use` blocks.
26132542
2614 - `"web_fetch"`
2615
26162543 - `type: "web_fetch_20260209"`
26172544
2618 - `"web_fetch_20260209"`
2619
26202545 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
26212546
26222547 - `"direct"`
from line 2576
26512576
26522577 Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
26532578
2579 exclusiveMinimum: 0
2580
26542581 - `max_uses: optional number or null`
26552582
26562583 Maximum number of times the tool can be used in the API request.
26572584
2585 exclusiveMinimum: 0
2586
26582587 - `strict: optional boolean`
26592588
26602589 When true, guarantees schema validation on tool names and inputs
26612590
2662 - `WebFetchTool20260309 object { name, type, allowed_callers, 9 more }`
2591 - `WebFetchTool20260309 object`
26632592
26642593 Web fetch tool with use_cache parameter for bypassing cached content.
26652594
from line 2598
26692598
26702599 This is how the tool will be called by the model and in `tool_use` blocks.
26712600
2672 - `"web_fetch"`
2673
26742601 - `type: "web_fetch_20260309"`
26752602
2676 - `"web_fetch_20260309"`
2677
26782603 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
26792604
26802605 - `"direct"`
from line 2634
27092634
27102635 Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
27112636
2637 exclusiveMinimum: 0
2638
27122639 - `max_uses: optional number or null`
27132640
27142641 Maximum number of times the tool can be used in the API request.
27152642
2643 exclusiveMinimum: 0
2644
27162645 - `strict: optional boolean`
27172646
27182647 When true, guarantees schema validation on tool names and inputs
from line 2650
27212650
27222651 Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.
27232652
2724 - `WebSearchTool20260318 object { name, type, allowed_callers, 8 more }`
2653 - `WebSearchTool20260318 object`
27252654
27262655 - `name: "web_search"`
27272656
from line 2658
27292658
27302659 This is how the tool will be called by the model and in `tool_use` blocks.
27312660
2732 - `"web_search"`
2733
27342661 - `type: "web_search_20260318"`
27352662
2736 - `"web_search_20260318"`
2737
27382663 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
27392664
27402665 - `"direct"`
from line 2690
27652690
27662691 Maximum number of times the tool can be used in the API request.
27672692
2693 exclusiveMinimum: 0
2694
27682695 - `response_inclusion: optional "full" or "excluded"`
27692696
27702697 How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn.
from line 2708
27812708
27822709 Parameters for the user's location. Used to provide more relevant search results.
27832710
2784 - `WebFetchTool20260318 object { name, type, allowed_callers, 10 more }`
2711 - `WebFetchTool20260318 object`
27852712
27862713 - `name: "web_fetch"`
27872714
from line 2716
27892716
27902717 This is how the tool will be called by the model and in `tool_use` blocks.
27912718
2792 - `"web_fetch"`
2793
27942719 - `type: "web_fetch_20260318"`
27952720
2796 - `"web_fetch_20260318"`
2797
27982721 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
27992722
28002723 - `"direct"`
from line 2752
28292752
28302753 Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.
28312754
2755 exclusiveMinimum: 0
2756
28322757 - `max_uses: optional number or null`
28332758
28342759 Maximum number of times the tool can be used in the API request.
28352760
2761 exclusiveMinimum: 0
2762
28362763 - `response_inclusion: optional "full" or "excluded"`
28372764
28382765 How this tool's result blocks appear in the API response when the result was consumed by a completed code_execution call in the same turn. 'full' returns the complete content (default). 'excluded' drops the nested server_tool_use and result block pair entirely. Results from direct calls, or from code_execution calls that paused before completing, are always returned in full so they can be sent back on the next turn.
from line 2776
28492776
28502777 Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.
28512778
2852 - `ToolSearchToolBm25_20251119 object { name, type, allowed_callers, 3 more }`
2779 - `ToolSearchToolBm25_20251119 object`
28532780
28542781 - `name: "tool_search_tool_bm25"`
28552782
from line 2784
28572784
28582785 This is how the tool will be called by the model and in `tool_use` blocks.
28592786
2787 - `type: "tool_search_tool_bm25_20251119" or "tool_search_tool_bm25"`
2788
2789 - `"tool_search_tool_bm25_20251119"`
2790
28602791 - `"tool_search_tool_bm25"`
28612792
2862 - `type: "tool_search_tool_bm25_20251119" or "tool_search_tool_bm25"`
2863
2864 - `"tool_search_tool_bm25_20251119"`
2865
2866 - `"tool_search_tool_bm25"`
2867
28682793 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
28692794
28702795 - `"direct"`
from line 2812
28872812
28882813 When true, guarantees schema validation on tool names and inputs
28892814
2890 - `ToolSearchToolRegex20251119 object { name, type, allowed_callers, 3 more }`
2815 - `ToolSearchToolRegex20251119 object`
28912816
28922817 - `name: "tool_search_tool_regex"`
28932818
from line 2820
28952820
28962821 This is how the tool will be called by the model and in `tool_use` blocks.
28972822
2823 - `type: "tool_search_tool_regex_20251119" or "tool_search_tool_regex"`
2824
2825 - `"tool_search_tool_regex_20251119"`
2826
28982827 - `"tool_search_tool_regex"`
28992828
2900 - `type: "tool_search_tool_regex_20251119" or "tool_search_tool_regex"`
2901
2902 - `"tool_search_tool_regex_20251119"`
2903
2904 - `"tool_search_tool_regex"`
2905
29062829 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
29072830
29082831 - `"direct"`
from line 2848
29252848
29262849 When true, guarantees schema validation on tool names and inputs
29272850
2928### Returns
2929
2930- `MessageTokensCount object { input_tokens }`
2851## Returns
2852
2853- `MessageTokensCount object`
29312854
29322855 - `input_tokens: number`
29332856
29342857 The total number of tokens across the provided list of messages, system prompt, and tools.
29352858
2936### Example
2937
2938```http
2859## Example
2860
2861```bash
29392862curl https://api.anthropic.com/v1/messages/count_tokens \
29402863 -H 'Content-Type: application/json' \
29412864 -H 'anthropic-version: 2023-06-01' \
from line 2898
29752898 }'
29762899```
29772900
2978#### Response
2901### Response (200)
29792902
29802903```json
29812904{
29822905
No line in this hunk matches that.