SPB Git

Repository Public

count_tokens.md 95.3 KB 3,013 lines markdown

1---2title: Count tokens in a Message3url: https://platform.claude.com/docs/en/api/messages/count_tokens4---56# Count tokens in a Message78**POST** `/v1/messages/count_tokens`910Count the number of tokens in a Message.1112The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it.1314Learn more about token counting in our [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)1516## Headers1718- `"anthropic-user-profile-id": optional string`1920  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.2122- `"anthropic-workspace-id": optional string`2324## Body parameters2526- `messages: array of MessageParam`2728  Input messages.2930  Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.3132  Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.3334  If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.3536  Example with a single `user` message:3738  ```json39  [{"role": "user", "content": "Hello, Claude"}]40  ```4142  Example with multiple conversational turns:4344  ```json45  [46    {"role": "user", "content": "Hello there."},47    {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"},48    {"role": "user", "content": "Can you explain LLMs in plain English?"},49  ]50  ```5152  Example with a partially-filled response from Claude:5354  ```json55  [56    {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},57    {"role": "assistant", "content": "The best answer is ("},58  ]59  ```6061  Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent:6263  ```json64  {"role": "user", "content": "Hello, Claude"}65  ```6667  ```json68  {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}69  ```7071  See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).7273  Note that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API.7475  There is a limit of 100,000 messages in a single request.7677  - `content: string or array of ContentBlockParam`7879    - `string`8081    - `array of ContentBlockParam`8283      - `TextBlockParam object`8485        - `type: "text"`8687        - `text: string`8889          minLength: 19091        - `cache_control: optional CacheControlEphemeral or null`9293          Create a cache control breakpoint at this content block.9495          - `type: "ephemeral"`9697          - `ttl: optional "5m" or "1h"`9899            The time-to-live for the cache control breakpoint.100101            This may be one the following values:102103            - `5m`: 5 minutes104            - `1h`: 1 hour105106            Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.107108            - `"5m"`109110            - `"1h"`111112        - `citations: optional array of TextCitationParam or null`113114          - `CitationCharLocationParam object`115116            - `type: "char_location"`117118            - `cited_text: string`119120            - `document_index: number`121122              minimum: 0123124            - `document_title: string or null`125126              maxLength: 500, minLength: 1127128            - `end_char_index: number`129130            - `start_char_index: number`131132              minimum: 0133134          - `CitationPageLocationParam object`135136            - `type: "page_location"`137138            - `cited_text: string`139140            - `document_index: number`141142              minimum: 0143144            - `document_title: string or null`145146              maxLength: 500, minLength: 1147148            - `end_page_number: number`149150            - `start_page_number: number`151152              minimum: 1153154          - `CitationContentBlockLocationParam object`155156            - `type: "content_block_location"`157158            - `cited_text: string`159160              The full text of the cited block range, concatenated.161162              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.163164            - `document_index: number`165166              minimum: 0167168            - `document_title: string or null`169170              maxLength: 500, minLength: 1171172            - `end_block_index: number`173174              Exclusive 0-based end index of the cited block range in the source's `content` array.175176              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.177178            - `start_block_index: number`179180              0-based index of the first cited block in the source's `content` array.181182              minimum: 0183184          - `CitationWebSearchResultLocationParam object`185186            - `type: "web_search_result_location"`187188            - `cited_text: string`189190            - `encrypted_index: string`191192            - `title: string or null`193194              maxLength: 512, minLength: 1195196            - `url: string`197198              minLength: 1199200          - `CitationSearchResultLocationParam object`201202            - `type: "search_result_location"`203204            - `cited_text: string`205206              The full text of the cited block range, concatenated.207208              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.209210            - `end_block_index: number`211212              Exclusive 0-based end index of the cited block range in the source's `content` array.213214              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.215216            - `search_result_index: number`217218              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.219220              Counted separately from `document_index`; server-side web search results are not included in this count.221222              minimum: 0223224            - `source: string`225226            - `start_block_index: number`227228              0-based index of the first cited block in the source's `content` array.229230              minimum: 0231232            - `title: string or null`233234      - `ImageBlockParam object`235236        - `type: "image"`237238        - `source: Base64ImageSource or URLImageSource or FileImageSource`239240          - `Base64ImageSource object`241242            - `type: "base64"`243244            - `data: string`245246              format: byte247248            - `media_type: "image/jpeg" or "image/png" or "image/gif" or "image/webp"`249250              - `"image/jpeg"`251252              - `"image/png"`253254              - `"image/gif"`255256              - `"image/webp"`257258          - `URLImageSource object`259260            - `type: "url"`261262            - `url: string`263264          - `FileImageSource object`265266            - `type: "file"`267268            - `file_id: string`269270        - `cache_control: optional CacheControlEphemeral or null`271272          Create a cache control breakpoint at this content block.273274        - `transformations: optional ImageTransformationsParam or null`275276          Configures the transformations the server applies to this image before the model observes it. Each key names a condition the server transforms images for; its value selects the transformation applied. Omitted keys keep their default behavior, and an empty object is equivalent to omitting the field.277278          - `oversized_image: optional "downsize" or "error"`279280            What the server does when this image exceeds the model's maximum image size. `"downsize"` (the default) scales the image down to fit, which changes the dimensions the model observes without telling you. `"error"` instead rejects the request with a 400 error naming the image's dimensions and the largest dimensions that fit, so you can scale the image deliberately — your image is never silently scaled down.281282            - `"downsize"`283284            - `"error"`285286      - `DocumentBlockParam object`287288        - `type: "document"`289290        - `source: Base64PDFSource or PlainTextSource or ContentBlockSource or 2 more`291292          - `Base64PDFSource object`293294            - `type: "base64"`295296            - `data: string`297298              format: byte299300            - `media_type: "application/pdf"`301302          - `PlainTextSource object`303304            - `type: "text"`305306            - `data: string`307308            - `media_type: "text/plain"`309310          - `ContentBlockSource object`311312            - `type: "content"`313314            - `content: string or array of ContentBlockSourceContent`315316              - `string`317318              - `ContentBlockSourceContent = array of ContentBlockSourceContent`319320                - `TextBlockParam object`321322                - `ImageBlockParam object`323324          - `URLPDFSource object`325326            - `type: "url"`327328            - `url: string`329330          - `FileDocumentSource object`331332            - `type: "file"`333334            - `file_id: string`335336        - `cache_control: optional CacheControlEphemeral or null`337338          Create a cache control breakpoint at this content block.339340        - `citations: optional CitationsConfigParam or null`341342          - `enabled: optional boolean`343344        - `context: optional string or null`345346          minLength: 1347348        - `title: optional string or null`349350          maxLength: 500, minLength: 1351352      - `SearchResultBlockParam object`353354        - `type: "search_result"`355356        - `content: array of TextBlockParam`357358          - `type: "text"`359360          - `text: string`361362            minLength: 1363364          - `cache_control: optional CacheControlEphemeral or null`365366            Create a cache control breakpoint at this content block.367368          - `citations: optional array of TextCitationParam or null`369370        - `source: string`371372        - `title: string`373374        - `cache_control: optional CacheControlEphemeral or null`375376          Create a cache control breakpoint at this content block.377378        - `citations: optional CitationsConfigParam`379380      - `ThinkingBlockParam object`381382        - `type: "thinking"`383384        - `signature: string`385386          The `signature` value of this thinking block, exactly as returned by the API in a previous response. Used to verify that the block was generated by Claude.387388          Thinking blocks must be passed back unmodified and in their original order; a modified block results in a 400 `invalid_request_error`.389390        - `thinking: string`391392          The `thinking` text of this block as returned by the API.393394      - `RedactedThinkingBlockParam object`395396        - `type: "redacted_thinking"`397398        - `data: string`399400          The `data` value of this redacted thinking block, exactly as returned by the API in a previous response. Opaque and encrypted; pass it back unchanged.401402      - `ToolUseBlockParam object`403404        - `type: "tool_use"`405406        - `id: string`407408          pattern: ^[a-zA-Z0-9_-]+$409410        - `input: map[unknown]`411412        - `name: string`413414          maxLength: 200, minLength: 1415416        - `cache_control: optional CacheControlEphemeral or null`417418          Create a cache control breakpoint at this content block.419420        - `caller: optional DirectCaller or ServerToolCaller or ServerToolCaller20260120`421422          - `DirectCaller object`423424            Tool invocation directly from the model.425426            - `type: "direct"`427428          - `ServerToolCaller object`429430            Tool invocation generated by a server-side tool.431432            - `type: "code_execution_20250825"`433434            - `tool_id: string`435436              pattern: ^srvtoolu_[a-zA-Z0-9_]+$437438          - `ServerToolCaller20260120 object`439440            - `type: "code_execution_20260120"`441442            - `tool_id: string`443444              pattern: ^srvtoolu_[a-zA-Z0-9_]+$445446        - `toolset_name: optional string or null`447448          For a toolset member tool_use, the toolset family this member belongs to.449450          maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$451452      - `ToolResultBlockParam object`453454        - `type: "tool_result"`455456        - `tool_use_id: string`457458          pattern: ^[a-zA-Z0-9_-]+$459460        - `cache_control: optional CacheControlEphemeral or null`461462          Create a cache control breakpoint at this content block.463464        - `content: optional string or array of TextBlockParam or ImageBlockParam or SearchResultBlockParam or 3 more`465466          - `string`467468          - `array of TextBlockParam or ImageBlockParam or SearchResultBlockParam or 3 more`469470            - `TextBlockParam object`471472            - `ImageBlockParam object`473474            - `SearchResultBlockParam object`475476            - `DocumentBlockParam object`477478            - `ToolReferenceBlockParam object`479480              Tool reference block that can be included in tool_result content.481482              - `type: "tool_reference"`483484              - `tool_name: string`485486                maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$487488              - `cache_control: optional CacheControlEphemeral or null`489490                Create a cache control breakpoint at this content block.491492            - `BrowserStateBlockParam object`493494              The caller's browser state after a browser toolset member call —495              the full inventory of open tabs, which tab is active, and any side496              effects (tabs opened, download state changes) the call produced.497498              At most one per `tool_result`, only on a non-error result answering a499              browser toolset member `tool_use`. The server renders the500              model-visible text from it; the model never sees the raw fields.501502              - `type: "browser_state"`503504              - `tabs: array of BrowserStateTabEntry`505506                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`.507508                maxItems: 100509510                - `tab_id: string`511512                  The caller-assigned identifier for this tab, unique within the inventory.513514                  maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$515516                - `title: string`517518                  The title of the page the tab is showing. May be empty.519520                  maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$521522                - `url: string`523524                  The URL of the page the tab is showing. May be empty.525526                  maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$527528                - `active: optional boolean`529530                  Whether this tab is the active tab after this call. Whenever `tabs` is non-empty, exactly one entry is marked `active: true`.531532              - `cache_control: optional CacheControlEphemeral or null`533534                Create a cache control breakpoint at this content block.535536              - `state_changes: optional array of BrowserStateChange or null`537538                Tabs opened and download state changes during this call. "Nothing to report" is expressed by omitting the field, never by an empty list.539540                maxItems: 200, minItems: 1541542                - `BrowserStateChangeTabOpened object`543544                  A tab this call's execution opened that remains open at its end —545                  the creation delta of the `tabs` inventory, not an event log.546547                  Carries only the `tab_id`; the tab's `title` and `url` live on its548                  `tabs` entry, which must include the same `tab_id`. A tab opened549                  during a failed call gets no deferred `tab_opened`; it simply appears550                  in the next result's `tabs` inventory.551552                  - `type: "tab_opened"`553554                  - `tab_id: string`555556                    The `tab_id` of the opened tab, present in `tabs`.557558                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$559560                - `BrowserStateChangeDownloadStarted object`561562                  A file download that started during this call.563564                  - `type: "download_started"`565566                  - `download_id: string`567568                    The caller-assigned identifier for this download, stable across the state changes reporting it.569570                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$571572                  - `url: string`573574                    The final post-redirect URL the download was served from.575576                    maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$577578                - `BrowserStateChangeDownloadCompleted object`579580                  A file download that finished during this call, reported with the581                  same `download_id` as its `download_started` — or without a prior582                  `download_started`, when the download finished during the call that583                  started it (at most one state change per `download_id` per result).584585                  - `type: "download_completed"`586587                  - `download_id: string`588589                    The caller-assigned identifier for this download, stable across the state changes reporting it.590591                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$592593                  - `url: string`594595                    The final post-redirect URL the download was served from.596597                    maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$598599                  - `path: optional string or null`600601                    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.602603                    pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096604605                  - `size_bytes: optional number or null`606607                    The completed download's size.608609                    minimum: 0610611                - `BrowserStateChangeDownloadFailed object`612613                  A file download that failed — or was cancelled — during this call.614615                  - `type: "download_failed"`616617                  - `download_id: string`618619                    The caller-assigned identifier for this download, stable across the state changes reporting it.620621                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$622623                  - `url: string`624625                    The final post-redirect URL the download was served from.626627                    maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$628629                  - `error: optional string or null`630631                    The failure or cancellation detail, when known.632633                    pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096634635        - `is_error: optional boolean`636637        - `toolset_name: optional string or null`638639          For a toolset member tool_result, the toolset family of the paired tool_use.640641          maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$642643      - `ServerToolUseBlockParam object`644645        - `type: "server_tool_use"`646647        - `id: string`648649          pattern: ^srvtoolu_[a-zA-Z0-9_]+$650651        - `input: map[unknown]`652653        - `name: "web_search" or "web_fetch" or "code_execution" or 4 more`654655          - `"web_search"`656657          - `"web_fetch"`658659          - `"code_execution"`660661          - `"bash_code_execution"`662663          - `"text_editor_code_execution"`664665          - `"tool_search_tool_regex"`666667          - `"tool_search_tool_bm25"`668669        - `cache_control: optional CacheControlEphemeral or null`670671          Create a cache control breakpoint at this content block.672673        - `caller: optional DirectCaller or ServerToolCaller or ServerToolCaller20260120`674675          - `DirectCaller object`676677            Tool invocation directly from the model.678679          - `ServerToolCaller object`680681            Tool invocation generated by a server-side tool.682683          - `ServerToolCaller20260120 object`684685      - `WebSearchToolResultBlockParam object`686687        - `type: "web_search_tool_result"`688689        - `content: WebSearchToolResultBlockParamContent`690691          - `WebSearchToolResultBlockItem = array of WebSearchResultBlockParam`692693            - `type: "web_search_result"`694695            - `encrypted_content: string`696697            - `title: string`698699            - `url: string`700701            - `page_age: optional string or null`702703          - `WebSearchToolRequestError object`704705            - `type: "web_search_tool_result_error"`706707            - `error_code: WebSearchToolResultErrorCode`708709              - `"invalid_tool_input"`710711              - `"unavailable"`712713              - `"max_uses_exceeded"`714715              - `"too_many_requests"`716717              - `"query_too_long"`718719              - `"request_too_large"`720721        - `tool_use_id: string`722723          pattern: ^srvtoolu_[a-zA-Z0-9_]+$724725        - `cache_control: optional CacheControlEphemeral or null`726727          Create a cache control breakpoint at this content block.728729        - `caller: optional DirectCaller or ServerToolCaller or ServerToolCaller20260120`730731          - `DirectCaller object`732733            Tool invocation directly from the model.734735          - `ServerToolCaller object`736737            Tool invocation generated by a server-side tool.738739          - `ServerToolCaller20260120 object`740741      - `WebFetchToolResultBlockParam object`742743        - `type: "web_fetch_tool_result"`744745        - `content: WebFetchToolResultErrorBlockParam or WebFetchBlockParam`746747          - `WebFetchToolResultErrorBlockParam object`748749            - `type: "web_fetch_tool_result_error"`750751            - `error_code: WebFetchToolResultErrorCode`752753              - `"invalid_tool_input"`754755              - `"url_too_long"`756757              - `"url_not_allowed"`758759              - `"url_not_in_prior_context"`760761              - `"url_not_accessible"`762763              - `"unsupported_content_type"`764765              - `"too_many_requests"`766767              - `"max_uses_exceeded"`768769              - `"unavailable"`770771              - `"content_too_large"`772773          - `WebFetchBlockParam object`774775            - `type: "web_fetch_result"`776777            - `content: DocumentBlockParam`778779            - `url: string`780781              Fetched content URL782783            - `retrieved_at: optional string or null`784785              ISO 8601 timestamp when the content was retrieved786787        - `tool_use_id: string`788789          pattern: ^srvtoolu_[a-zA-Z0-9_]+$790791        - `cache_control: optional CacheControlEphemeral or null`792793          Create a cache control breakpoint at this content block.794795        - `caller: optional DirectCaller or ServerToolCaller or ServerToolCaller20260120`796797          - `DirectCaller object`798799            Tool invocation directly from the model.800801          - `ServerToolCaller object`802803            Tool invocation generated by a server-side tool.804805          - `ServerToolCaller20260120 object`806807      - `CodeExecutionToolResultBlockParam object`808809        - `type: "code_execution_tool_result"`810811        - `content: CodeExecutionToolResultBlockParamContent`812813          - `CodeExecutionToolResultErrorParam object`814815            - `type: "code_execution_tool_result_error"`816817            - `error_code: CodeExecutionToolResultErrorCode`818819              - `"invalid_tool_input"`820821              - `"unavailable"`822823              - `"too_many_requests"`824825              - `"execution_time_exceeded"`826827          - `CodeExecutionResultBlockParam object`828829            - `type: "code_execution_result"`830831            - `content: array of CodeExecutionOutputBlockParam`832833              - `type: "code_execution_output"`834835              - `file_id: string`836837            - `return_code: number`838839            - `stderr: string`840841            - `stdout: string`842843          - `EncryptedCodeExecutionResultBlockParam object`844845            Code execution result with encrypted stdout for PFC + web_search results.846847            - `type: "encrypted_code_execution_result"`848849            - `content: array of CodeExecutionOutputBlockParam`850851              - `type: "code_execution_output"`852853              - `file_id: string`854855            - `encrypted_stdout: string`856857            - `return_code: number`858859            - `stderr: string`860861        - `tool_use_id: string`862863          pattern: ^srvtoolu_[a-zA-Z0-9_]+$864865        - `cache_control: optional CacheControlEphemeral or null`866867          Create a cache control breakpoint at this content block.868869      - `BashCodeExecutionToolResultBlockParam object`870871        - `type: "bash_code_execution_tool_result"`872873        - `content: BashCodeExecutionToolResultErrorParam or BashCodeExecutionResultBlockParam`874875          - `BashCodeExecutionToolResultErrorParam object`876877            - `type: "bash_code_execution_tool_result_error"`878879            - `error_code: BashCodeExecutionToolResultErrorCode`880881              - `"invalid_tool_input"`882883              - `"unavailable"`884885              - `"too_many_requests"`886887              - `"execution_time_exceeded"`888889              - `"output_file_too_large"`890891          - `BashCodeExecutionResultBlockParam object`892893            - `type: "bash_code_execution_result"`894895            - `content: array of BashCodeExecutionOutputBlockParam`896897              - `type: "bash_code_execution_output"`898899              - `file_id: string`900901            - `return_code: number`902903            - `stderr: string`904905            - `stdout: string`906907        - `tool_use_id: string`908909          pattern: ^srvtoolu_[a-zA-Z0-9_]+$910911        - `cache_control: optional CacheControlEphemeral or null`912913          Create a cache control breakpoint at this content block.914915      - `TextEditorCodeExecutionToolResultBlockParam object`916917        - `type: "text_editor_code_execution_tool_result"`918919        - `content: TextEditorCodeExecutionToolResultErrorParam or TextEditorCodeExecutionViewResultBlockParam or TextEditorCodeExecutionCreateResultBlockParam or TextEditorCodeExecutionStrReplaceResultBlockParam`920921          - `TextEditorCodeExecutionToolResultErrorParam object`922923            - `type: "text_editor_code_execution_tool_result_error"`924925            - `error_code: TextEditorCodeExecutionToolResultErrorCode`926927              - `"invalid_tool_input"`928929              - `"unavailable"`930931              - `"too_many_requests"`932933              - `"execution_time_exceeded"`934935              - `"file_not_found"`936937            - `error_message: optional string or null`938939          - `TextEditorCodeExecutionViewResultBlockParam object`940941            - `type: "text_editor_code_execution_view_result"`942943            - `content: string`944945            - `file_type: "text" or "image" or "pdf"`946947              - `"text"`948949              - `"image"`950951              - `"pdf"`952953            - `num_lines: optional number or null`954955            - `start_line: optional number or null`956957            - `total_lines: optional number or null`958959          - `TextEditorCodeExecutionCreateResultBlockParam object`960961            - `type: "text_editor_code_execution_create_result"`962963            - `is_file_update: boolean`964965          - `TextEditorCodeExecutionStrReplaceResultBlockParam object`966967            - `type: "text_editor_code_execution_str_replace_result"`968969            - `lines: optional array of string or null`970971            - `new_lines: optional number or null`972973            - `new_start: optional number or null`974975            - `old_lines: optional number or null`976977            - `old_start: optional number or null`978979        - `tool_use_id: string`980981          pattern: ^srvtoolu_[a-zA-Z0-9_]+$982983        - `cache_control: optional CacheControlEphemeral or null`984985          Create a cache control breakpoint at this content block.986987      - `ToolSearchToolResultBlockParam object`988989        - `type: "tool_search_tool_result"`990991        - `content: ToolSearchToolResultErrorParam or ToolSearchToolSearchResultBlockParam`992993          - `ToolSearchToolResultErrorParam object`994995            - `type: "tool_search_tool_result_error"`996997            - `error_code: ToolSearchToolResultErrorCode`998999              - `"invalid_tool_input"`10001001              - `"unavailable"`10021003              - `"too_many_requests"`10041005              - `"execution_time_exceeded"`10061007            - `error_message: optional string or null`10081009          - `ToolSearchToolSearchResultBlockParam object`10101011            - `type: "tool_search_tool_search_result"`10121013            - `tool_references: array of ToolReferenceBlockParam`10141015              - `type: "tool_reference"`10161017              - `tool_name: string`10181019                maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$10201021              - `cache_control: optional CacheControlEphemeral or null`10221023                Create a cache control breakpoint at this content block.10241025        - `tool_use_id: string`10261027          pattern: ^srvtoolu_[a-zA-Z0-9_]+$10281029        - `cache_control: optional CacheControlEphemeral or null`10301031          Create a cache control breakpoint at this content block.10321033      - `ContainerUploadBlockParam object`10341035        A content block that represents a file to be uploaded to the container1036        Files uploaded via this block will be available in the container's input directory.10371038        - `type: "container_upload"`10391040        - `file_id: string`10411042        - `cache_control: optional CacheControlEphemeral or null`10431044          Create a cache control breakpoint at this content block.10451046  - `role: "user" or "assistant" or "system"`10471048    - `"user"`10491050    - `"assistant"`10511052    - `"system"`10531054- `model: Model`10551056  The model that will complete your prompt.10571058  See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.10591060  - `"claude-fable-5-1" or "claude-mythos-5-1" or "claude-sonnet-5" or 14 more`10611062    The model that will complete your prompt.10631064    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.10651066    - `"claude-fable-5-1"`10671068      Frontier intelligence for ambitious tasks across coding, scientific discovery, and enterprise workflows10691070    - `"claude-mythos-5-1"`10711072      Our most capable model for cybersecurity and biology research, available through trusted access programs10731074    - `"claude-sonnet-5"`10751076      High-performance model for coding and agents10771078    - `"claude-fable-5"`10791080      Next generation of intelligence for the hardest knowledge work and coding problems10811082    - `"claude-mythos-5"`10831084      Most capable model for cybersecurity and biology research10851086    - `"claude-opus-5"`10871088      Powerful intelligence for long-running agents and coding10891090    - `"claude-opus-4-8"`10911092      Powerful intelligence for long-running agents and coding10931094    - `"claude-opus-4-7"`10951096      Powerful intelligence for long-running agents and coding10971098    - `"claude-mythos-preview"`10991100      New class of intelligence, strongest in coding and cybersecurity11011102    - `"claude-opus-4-6"`11031104      Powerful intelligence for long-running agents and coding11051106    - `"claude-sonnet-4-6"`11071108      Best combination of speed and intelligence11091110    - `"claude-haiku-4-5"`11111112      Fastest model with near-frontier intelligence11131114    - `"claude-haiku-4-5-20251001"`11151116      Fastest model with near-frontier intelligence11171118    - `"claude-opus-4-5"`11191120      Powerful intelligence for long-running agents and coding11211122    - `"claude-opus-4-5-20251101"`11231124      Powerful intelligence for long-running agents and coding11251126    - `"claude-sonnet-4-5"`11271128      High-performance model for agents and coding11291130    - `"claude-sonnet-4-5-20250929"`11311132      High-performance model for agents and coding11331134  - `string`11351136- `cache_control: optional CacheControlEphemeral or null`11371138  Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.11391140- `output_config: optional OutputConfig`11411142  Configuration options for the model's output, such as the output format.11431144  - `effort: optional "low" or "medium" or "high" or 2 more or null`11451146    All possible effort levels.11471148    - `"low"`11491150    - `"medium"`11511152    - `"high"`11531154    - `"xhigh"`11551156    - `"max"`11571158  - `format: optional JSONOutputFormat or null`11591160    A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)11611162    - `type: "json_schema"`11631164    - `schema: map[unknown]`11651166      The JSON schema of the format11671168- `system: optional string or array of TextBlockParam`11691170  System prompt.11711172  A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).11731174  - `string`11751176  - `array of TextBlockParam`11771178    - `type: "text"`11791180    - `text: string`11811182      minLength: 111831184    - `cache_control: optional CacheControlEphemeral or null`11851186      Create a cache control breakpoint at this content block.11871188    - `citations: optional array of TextCitationParam or null`11891190- `thinking: optional ThinkingConfigParam`11911192  Configuration for enabling Claude's extended thinking.11931194  When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.11951196  See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.11971198  - `ThinkingConfigEnabled object`11991200    - `type: "enabled"`12011202    - `budget_tokens: number`12031204      Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.12051206      Must be ≥1024 and less than `max_tokens`.12071208      See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.12091210      minimum: 102412111212    - `display: optional "summarized" or "omitted" or null`12131214      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`.12151216      - `"summarized"`12171218      - `"omitted"`12191220  - `ThinkingConfigDisabled object`12211222    - `type: "disabled"`12231224  - `ThinkingConfigAdaptive object`12251226    - `type: "adaptive"`12271228    - `display: optional "summarized" or "omitted" or null`12291230      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`.12311232      - `"summarized"`12331234      - `"omitted"`12351236- `tool_choice: optional ToolChoice`12371238  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.12391240  - `ToolChoiceAuto object`12411242    The model will automatically decide whether to use tools.12431244    - `type: "auto"`12451246    - `disable_parallel_tool_use: optional boolean`12471248      Whether to disable parallel tool use.12491250      Defaults to `false`. If set to `true`, the model will output at most one tool use.12511252  - `ToolChoiceAny object`12531254    The model will use any available tools.12551256    - `type: "any"`12571258    - `disable_parallel_tool_use: optional boolean`12591260      Whether to disable parallel tool use.12611262      Defaults to `false`. If set to `true`, the model will output exactly one tool use.12631264  - `ToolChoiceTool object`12651266    The model will use the specified tool with `tool_choice.name`.12671268    - `type: "tool"`12691270    - `name: string`12711272      The name of the tool to use.12731274    - `disable_parallel_tool_use: optional boolean`12751276      Whether to disable parallel tool use.12771278      Defaults to `false`. If set to `true`, the model will output exactly one tool use.12791280  - `ToolChoiceNone object`12811282    The model will not be allowed to use tools.12831284    - `type: "none"`12851286- `tools: optional array of MessageCountTokensTool`12871288  Definitions of tools that the model may use.12891290  If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.12911292  There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).12931294  Each tool definition includes:12951296  * `name`: Name of the tool.1297  * `description`: Optional, but strongly-recommended description of the tool.1298  * `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.12991300  For example, if you defined `tools` as:13011302  ```json1303  [1304    {1305      "name": "get_stock_price",1306      "description": "Get the current stock price for a given ticker symbol.",1307      "input_schema": {1308        "type": "object",1309        "properties": {1310          "ticker": {1311            "type": "string",1312            "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."1313          }1314        },1315        "required": ["ticker"]1316      }1317    }1318  ]1319  ```13201321  And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this:13221323  ```json1324  [1325    {1326      "type": "tool_use",1327      "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",1328      "name": "get_stock_price",1329      "input": { "ticker": "^GSPC" }1330    }1331  ]1332  ```13331334  You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message:13351336  ```json1337  [1338    {1339      "type": "tool_result",1340      "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",1341      "content": "259.75 USD"1342    }1343  ]1344  ```13451346  Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.13471348  See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.13491350  - `Tool object`13511352    - `type: optional "custom" or null`13531354    - `input_schema: object`13551356      [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.13571358      This defines the shape of the `input` that your tool accepts and that the model will produce.13591360      - `type: "object"`13611362      - `properties: optional map[unknown] or null`13631364      - `required: optional array of string or null`13651366    - `name: string`13671368      Name of the tool.13691370      This is how the tool will be called by the model and in `tool_use` blocks.13711372      maxLength: 128, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,128}$13731374    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`13751376      - `"direct"`13771378      - `"code_execution_20250825"`13791380      - `"code_execution_20260120"`13811382      - `"code_execution_20260521"`13831384    - `cache_control: optional CacheControlEphemeral or null`13851386      Create a cache control breakpoint at this content block.13871388    - `defer_loading: optional boolean`13891390      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.13911392    - `description: optional string`13931394      Description of what this tool does.13951396      Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.13971398    - `eager_input_streaming: optional boolean or null`13991400      Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.14011402    - `input_examples: optional array of map[unknown]`14031404    - `strict: optional boolean`14051406      When true, guarantees schema validation on tool names and inputs14071408  - `ToolBash20250124 object`14091410    - `type: "bash_20250124"`14111412    - `name: "bash"`14131414      Name of the tool.14151416      This is how the tool will be called by the model and in `tool_use` blocks.14171418    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`14191420      - `"direct"`14211422      - `"code_execution_20250825"`14231424      - `"code_execution_20260120"`14251426      - `"code_execution_20260521"`14271428    - `cache_control: optional CacheControlEphemeral or null`14291430      Create a cache control breakpoint at this content block.14311432    - `defer_loading: optional boolean`14331434      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.14351436    - `input_examples: optional array of map[unknown]`14371438    - `strict: optional boolean`14391440      When true, guarantees schema validation on tool names and inputs14411442  - `CodeExecutionTool20250522 object`14431444    - `type: "code_execution_20250522"`14451446    - `name: "code_execution"`14471448      Name of the tool.14491450      This is how the tool will be called by the model and in `tool_use` blocks.14511452    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`14531454      - `"direct"`14551456      - `"code_execution_20250825"`14571458      - `"code_execution_20260120"`14591460      - `"code_execution_20260521"`14611462    - `cache_control: optional CacheControlEphemeral or null`14631464      Create a cache control breakpoint at this content block.14651466    - `defer_loading: optional boolean`14671468      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.14691470    - `strict: optional boolean`14711472      When true, guarantees schema validation on tool names and inputs14731474  - `CodeExecutionTool20250825 object`14751476    - `type: "code_execution_20250825"`14771478    - `name: "code_execution"`14791480      Name of the tool.14811482      This is how the tool will be called by the model and in `tool_use` blocks.14831484    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`14851486      - `"direct"`14871488      - `"code_execution_20250825"`14891490      - `"code_execution_20260120"`14911492      - `"code_execution_20260521"`14931494    - `cache_control: optional CacheControlEphemeral or null`14951496      Create a cache control breakpoint at this content block.14971498    - `defer_loading: optional boolean`14991500      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.15011502    - `strict: optional boolean`15031504      When true, guarantees schema validation on tool names and inputs15051506  - `CodeExecutionTool20260120 object`15071508    Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).15091510    - `type: "code_execution_20260120"`15111512    - `name: "code_execution"`15131514      Name of the tool.15151516      This is how the tool will be called by the model and in `tool_use` blocks.15171518    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`15191520      - `"direct"`15211522      - `"code_execution_20250825"`15231524      - `"code_execution_20260120"`15251526      - `"code_execution_20260521"`15271528    - `cache_control: optional CacheControlEphemeral or null`15291530      Create a cache control breakpoint at this content block.15311532    - `defer_loading: optional boolean`15331534      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.15351536    - `strict: optional boolean`15371538      When true, guarantees schema validation on tool names and inputs15391540  - `CodeExecutionTool20260521 object`15411542    Code execution tool with REPL state persistence.15431544    - `type: "code_execution_20260521"`15451546    - `name: "code_execution"`15471548      Name of the tool.15491550      This is how the tool will be called by the model and in `tool_use` blocks.15511552    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`15531554      - `"direct"`15551556      - `"code_execution_20250825"`15571558      - `"code_execution_20260120"`15591560      - `"code_execution_20260521"`15611562    - `cache_control: optional CacheControlEphemeral or null`15631564      Create a cache control breakpoint at this content block.15651566    - `defer_loading: optional boolean`15671568      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.15691570    - `strict: optional boolean`15711572      When true, guarantees schema validation on tool names and inputs15731574  - `BrowserToolset20260801 object`15751576    The browser toolset: a single `tools[]` entry (carrying no1577    `name`) that declares the browser tool family. The model is served1578    the family's tool with any members disabled via `configs` removed1579    from its schema.15801581    - `type: "browser_toolset_20260801"`15821583    - `cache_control: optional CacheControlEphemeral or null`15841585      Create a cache control breakpoint at this content block.15861587    - `configs: optional BrowserToolsetConfigs or null`15881589      Per-member configuration for `browser_toolset_20260801`: one1590      optional field per member tool, keyed by the member name — the same1591      name the member's `tool_use` blocks carry. Every member is an1592      accepted key, and a member's defaults apply wherever its key is1593      absent. Unknown keys are rejected: the field set is this toolset1594      version's complete member set.15951596      - `type: optional BrowserTypeConfig or null`15971598        `type`'s config overrides.15991600        - `defer_loading: optional boolean or null`16011602          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16031604        - `enabled: optional boolean or null`16051606          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.16071608      - `close_tab: optional BrowserCloseTabConfig or null`16091610        `close_tab`'s config overrides.16111612        - `defer_loading: optional boolean or null`16131614          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16151616        - `enabled: optional boolean or null`16171618          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.16191620      - `double_click: optional BrowserDoubleClickConfig or null`16211622        `double_click`'s config overrides.16231624        - `defer_loading: optional boolean or null`16251626          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16271628        - `enabled: optional boolean or null`16291630          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.16311632      - `file_upload: optional BrowserFileUploadConfig or null`16331634        `file_upload`'s config overrides.16351636        - `defer_loading: optional boolean or null`16371638          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16391640        - `enabled: optional boolean or null`16411642          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.16431644      - `find: optional BrowserFindConfig or null`16451646        `find`'s config overrides.16471648        - `defer_loading: optional boolean or null`16491650          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16511652        - `enabled: optional boolean or null`16531654          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.16551656      - `form_input: optional BrowserFormInputConfig or null`16571658        `form_input`'s config overrides.16591660        - `defer_loading: optional boolean or null`16611662          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16631664        - `enabled: optional boolean or null`16651666          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.16671668      - `get_page_text: optional BrowserGetPageTextConfig or null`16691670        `get_page_text`'s config overrides.16711672        - `defer_loading: optional boolean or null`16731674          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16751676        - `enabled: optional boolean or null`16771678          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.16791680      - `hold_key: optional BrowserHoldKeyConfig or null`16811682        `hold_key`'s config overrides.16831684        - `defer_loading: optional boolean or null`16851686          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16871688        - `enabled: optional boolean or null`16891690          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.16911692      - `hover: optional BrowserHoverConfig or null`16931694        `hover`'s config overrides.16951696        - `defer_loading: optional boolean or null`16971698          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.16991700        - `enabled: optional boolean or null`17011702          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.17031704      - `javascript_exec: optional BrowserJavascriptExecConfig or null`17051706        `javascript_exec`'s config overrides.17071708        - `defer_loading: optional boolean or null`17091710          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17111712        - `enabled: optional boolean or null`17131714          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.17151716      - `key: optional BrowserKeyConfig or null`17171718        `key`'s config overrides.17191720        - `defer_loading: optional boolean or null`17211722          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17231724        - `enabled: optional boolean or null`17251726          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.17271728      - `left_click: optional BrowserLeftClickConfig or null`17291730        `left_click`'s config overrides.17311732        - `defer_loading: optional boolean or null`17331734          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17351736        - `enabled: optional boolean or null`17371738          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.17391740      - `left_click_drag: optional BrowserLeftClickDragConfig or null`17411742        `left_click_drag`'s config overrides.17431744        - `defer_loading: optional boolean or null`17451746          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17471748        - `enabled: optional boolean or null`17491750          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.17511752      - `left_mouse_down: optional BrowserLeftMouseDownConfig or null`17531754        `left_mouse_down`'s config overrides.17551756        - `defer_loading: optional boolean or null`17571758          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17591760        - `enabled: optional boolean or null`17611762          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.17631764      - `left_mouse_up: optional BrowserLeftMouseUpConfig or null`17651766        `left_mouse_up`'s config overrides.17671768        - `defer_loading: optional boolean or null`17691770          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17711772        - `enabled: optional boolean or null`17731774          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.17751776      - `list_tabs: optional BrowserListTabsConfig or null`17771778        `list_tabs`'s config overrides.17791780        - `defer_loading: optional boolean or null`17811782          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17831784        - `enabled: optional boolean or null`17851786          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.17871788      - `middle_click: optional BrowserMiddleClickConfig or null`17891790        `middle_click`'s config overrides.17911792        - `defer_loading: optional boolean or null`17931794          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.17951796        - `enabled: optional boolean or null`17971798          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.17991800      - `mouse_move: optional BrowserMouseMoveConfig or null`18011802        `mouse_move`'s config overrides.18031804        - `defer_loading: optional boolean or null`18051806          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18071808        - `enabled: optional boolean or null`18091810          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.18111812      - `navigate: optional BrowserNavigateConfig or null`18131814        `navigate`'s config overrides.18151816        - `defer_loading: optional boolean or null`18171818          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18191820        - `enabled: optional boolean or null`18211822          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.18231824      - `new_tab: optional BrowserNewTabConfig or null`18251826        `new_tab`'s config overrides.18271828        - `defer_loading: optional boolean or null`18291830          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18311832        - `enabled: optional boolean or null`18331834          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.18351836      - `read_console: optional BrowserReadConsoleConfig or null`18371838        `read_console`'s config overrides.18391840        - `defer_loading: optional boolean or null`18411842          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18431844        - `enabled: optional boolean or null`18451846          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.18471848      - `read_network: optional BrowserReadNetworkConfig or null`18491850        `read_network`'s config overrides.18511852        - `defer_loading: optional boolean or null`18531854          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18551856        - `enabled: optional boolean or null`18571858          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.18591860      - `read_page: optional BrowserReadPageConfig or null`18611862        `read_page`'s config overrides.18631864        - `defer_loading: optional boolean or null`18651866          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18671868        - `enabled: optional boolean or null`18691870          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.18711872      - `right_click: optional BrowserRightClickConfig or null`18731874        `right_click`'s config overrides.18751876        - `defer_loading: optional boolean or null`18771878          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18791880        - `enabled: optional boolean or null`18811882          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.18831884      - `screenshot: optional BrowserScreenshotConfig or null`18851886        `screenshot`'s config overrides.18871888        - `defer_loading: optional boolean or null`18891890          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.18911892        - `enabled: optional boolean or null`18931894          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.18951896      - `scroll: optional BrowserScrollConfig or null`18971898        `scroll`'s config overrides.18991900        - `defer_loading: optional boolean or null`19011902          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.19031904        - `enabled: optional boolean or null`19051906          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.19071908      - `scroll_to: optional BrowserScrollToConfig or null`19091910        `scroll_to`'s config overrides.19111912        - `defer_loading: optional boolean or null`19131914          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.19151916        - `enabled: optional boolean or null`19171918          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.19191920      - `switch_tab: optional BrowserSwitchTabConfig or null`19211922        `switch_tab`'s config overrides.19231924        - `defer_loading: optional boolean or null`19251926          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.19271928        - `enabled: optional boolean or null`19291930          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.19311932      - `triple_click: optional BrowserTripleClickConfig or null`19331934        `triple_click`'s config overrides.19351936        - `defer_loading: optional boolean or null`19371938          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.19391940        - `enabled: optional boolean or null`19411942          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.19431944      - `wait: optional BrowserWaitConfig or null`19451946        `wait`'s config overrides.19471948        - `defer_loading: optional boolean or null`19491950          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.19511952        - `enabled: optional boolean or null`19531954          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.19551956      - `zoom: optional BrowserZoomConfig or null`19571958        `zoom`'s config overrides.19591960        - `defer_loading: optional boolean or null`19611962          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.19631964        - `enabled: optional boolean or null`19651966          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.19671968  - `MemoryTool20250818 object`19691970    - `type: "memory_20250818"`19711972    - `name: "memory"`19731974      Name of the tool.19751976      This is how the tool will be called by the model and in `tool_use` blocks.19771978    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`19791980      - `"direct"`19811982      - `"code_execution_20250825"`19831984      - `"code_execution_20260120"`19851986      - `"code_execution_20260521"`19871988    - `cache_control: optional CacheControlEphemeral or null`19891990      Create a cache control breakpoint at this content block.19911992    - `defer_loading: optional boolean`19931994      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.19951996    - `input_examples: optional array of map[unknown]`19971998    - `strict: optional boolean`19992000      When true, guarantees schema validation on tool names and inputs20012002  - `ComputerToolset20260801 object`20032004    The computer toolset: a single `tools[]` entry (carrying no2005    `name`) that declares the computer tool family. The model is2006    served the family's tool with any members disabled via `configs`2007    removed from its schema. Every member is enabled by default, zoom2008    included. The single-tool options `display_number` and2009    `enable_zoom` are not fields of a toolset entry — it carries only2010    `type`, `configs`, and `cache_control`; zoom is controlled2011    via `configs.zoom.enabled`.20122013    - `type: "computer_toolset_20260801"`20142015    - `cache_control: optional CacheControlEphemeral or null`20162017      Create a cache control breakpoint at this content block.20182019    - `configs: optional ComputerToolsetConfigs or null`20202021      Per-member configuration for `computer_toolset_20260801`: one2022      optional field per member tool, keyed by the member name — the same2023      name the member's `tool_use` blocks carry. Every member is an2024      accepted key, and a member's defaults apply wherever its key is2025      absent. Unknown keys are rejected: the field set is this toolset2026      version's complete member set.20272028      - `type: optional ComputerTypeConfig or null`20292030        `type`'s config overrides.20312032        - `defer_loading: optional boolean or null`20332034          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.20352036        - `enabled: optional boolean or null`20372038          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.20392040      - `cursor_position: optional ComputerCursorPositionConfig or null`20412042        `cursor_position`'s config overrides.20432044        - `defer_loading: optional boolean or null`20452046          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.20472048        - `enabled: optional boolean or null`20492050          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.20512052      - `double_click: optional ComputerDoubleClickConfig or null`20532054        `double_click`'s config overrides.20552056        - `defer_loading: optional boolean or null`20572058          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.20592060        - `enabled: optional boolean or null`20612062          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.20632064      - `hold_key: optional ComputerHoldKeyConfig or null`20652066        `hold_key`'s config overrides.20672068        - `defer_loading: optional boolean or null`20692070          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.20712072        - `enabled: optional boolean or null`20732074          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.20752076      - `key: optional ComputerKeyConfig or null`20772078        `key`'s config overrides.20792080        - `defer_loading: optional boolean or null`20812082          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.20832084        - `enabled: optional boolean or null`20852086          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.20872088      - `left_click: optional ComputerLeftClickConfig or null`20892090        `left_click`'s config overrides.20912092        - `defer_loading: optional boolean or null`20932094          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.20952096        - `enabled: optional boolean or null`20972098          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.20992100      - `left_click_drag: optional ComputerLeftClickDragConfig or null`21012102        `left_click_drag`'s config overrides.21032104        - `defer_loading: optional boolean or null`21052106          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21072108        - `enabled: optional boolean or null`21092110          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.21112112      - `left_mouse_down: optional ComputerLeftMouseDownConfig or null`21132114        `left_mouse_down`'s config overrides.21152116        - `defer_loading: optional boolean or null`21172118          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21192120        - `enabled: optional boolean or null`21212122          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.21232124      - `left_mouse_up: optional ComputerLeftMouseUpConfig or null`21252126        `left_mouse_up`'s config overrides.21272128        - `defer_loading: optional boolean or null`21292130          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21312132        - `enabled: optional boolean or null`21332134          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.21352136      - `middle_click: optional ComputerMiddleClickConfig or null`21372138        `middle_click`'s config overrides.21392140        - `defer_loading: optional boolean or null`21412142          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21432144        - `enabled: optional boolean or null`21452146          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.21472148      - `mouse_move: optional ComputerMouseMoveConfig or null`21492150        `mouse_move`'s config overrides.21512152        - `defer_loading: optional boolean or null`21532154          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21552156        - `enabled: optional boolean or null`21572158          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.21592160      - `right_click: optional ComputerRightClickConfig or null`21612162        `right_click`'s config overrides.21632164        - `defer_loading: optional boolean or null`21652166          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21672168        - `enabled: optional boolean or null`21692170          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.21712172      - `screenshot: optional ComputerScreenshotConfig or null`21732174        `screenshot`'s config overrides.21752176        - `defer_loading: optional boolean or null`21772178          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21792180        - `enabled: optional boolean or null`21812182          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.21832184      - `scroll: optional ComputerScrollConfig or null`21852186        `scroll`'s config overrides.21872188        - `defer_loading: optional boolean or null`21892190          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.21912192        - `enabled: optional boolean or null`21932194          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.21952196      - `triple_click: optional ComputerTripleClickConfig or null`21972198        `triple_click`'s config overrides.21992200        - `defer_loading: optional boolean or null`22012202          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22032204        - `enabled: optional boolean or null`22052206          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.22072208      - `wait: optional ComputerWaitConfig or null`22092210        `wait`'s config overrides.22112212        - `defer_loading: optional boolean or null`22132214          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22152216        - `enabled: optional boolean or null`22172218          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.22192220      - `zoom: optional ComputerZoomConfig or null`22212222        `zoom`'s config overrides.22232224        - `defer_loading: optional boolean or null`22252226          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22272228        - `enabled: optional boolean or null`22292230          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.22312232  - `ToolTextEditor20250124 object`22332234    - `type: "text_editor_20250124"`22352236    - `name: "str_replace_editor"`22372238      Name of the tool.22392240      This is how the tool will be called by the model and in `tool_use` blocks.22412242    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`22432244      - `"direct"`22452246      - `"code_execution_20250825"`22472248      - `"code_execution_20260120"`22492250      - `"code_execution_20260521"`22512252    - `cache_control: optional CacheControlEphemeral or null`22532254      Create a cache control breakpoint at this content block.22552256    - `defer_loading: optional boolean`22572258      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.22592260    - `input_examples: optional array of map[unknown]`22612262    - `strict: optional boolean`22632264      When true, guarantees schema validation on tool names and inputs22652266  - `ToolTextEditor20250429 object`22672268    - `type: "text_editor_20250429"`22692270    - `name: "str_replace_based_edit_tool"`22712272      Name of the tool.22732274      This is how the tool will be called by the model and in `tool_use` blocks.22752276    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`22772278      - `"direct"`22792280      - `"code_execution_20250825"`22812282      - `"code_execution_20260120"`22832284      - `"code_execution_20260521"`22852286    - `cache_control: optional CacheControlEphemeral or null`22872288      Create a cache control breakpoint at this content block.22892290    - `defer_loading: optional boolean`22912292      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.22932294    - `input_examples: optional array of map[unknown]`22952296    - `strict: optional boolean`22972298      When true, guarantees schema validation on tool names and inputs22992300  - `ToolTextEditor20250728 object`23012302    - `type: "text_editor_20250728"`23032304    - `name: "str_replace_based_edit_tool"`23052306      Name of the tool.23072308      This is how the tool will be called by the model and in `tool_use` blocks.23092310    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`23112312      - `"direct"`23132314      - `"code_execution_20250825"`23152316      - `"code_execution_20260120"`23172318      - `"code_execution_20260521"`23192320    - `cache_control: optional CacheControlEphemeral or null`23212322      Create a cache control breakpoint at this content block.23232324    - `defer_loading: optional boolean`23252326      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.23272328    - `input_examples: optional array of map[unknown]`23292330    - `max_characters: optional number or null`23312332      Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.23332334      minimum: 123352336    - `strict: optional boolean`23372338      When true, guarantees schema validation on tool names and inputs23392340  - `WebSearchTool20250305 object`23412342    - `type: "web_search_20250305"`23432344    - `name: "web_search"`23452346      Name of the tool.23472348      This is how the tool will be called by the model and in `tool_use` blocks.23492350    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`23512352      - `"direct"`23532354      - `"code_execution_20250825"`23552356      - `"code_execution_20260120"`23572358      - `"code_execution_20260521"`23592360    - `allowed_domains: optional array of string or null`23612362      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.23632364    - `blocked_domains: optional array of string or null`23652366      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.23672368    - `cache_control: optional CacheControlEphemeral or null`23692370      Create a cache control breakpoint at this content block.23712372    - `defer_loading: optional boolean`23732374      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.23752376    - `max_uses: optional number or null`23772378      Maximum number of times the tool can be used in the API request.23792380      exclusiveMinimum: 023812382    - `strict: optional boolean`23832384      When true, guarantees schema validation on tool names and inputs23852386    - `user_location: optional UserLocation or null`23872388      Parameters for the user's location. Used to provide more relevant search results.23892390      - `type: "approximate"`23912392      - `city: optional string or null`23932394        The city of the user.23952396        maxLength: 255, minLength: 123972398      - `country: optional string or null`23992400        The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.24012402        maxLength: 2, minLength: 224032404      - `region: optional string or null`24052406        The region of the user.24072408        maxLength: 255, minLength: 124092410      - `timezone: optional string or null`24112412        The [IANA timezone](https://nodatime.org/TimeZones) of the user.24132414        maxLength: 255, minLength: 124152416  - `WebFetchTool20250910 object`24172418    - `type: "web_fetch_20250910"`24192420    - `name: "web_fetch"`24212422      Name of the tool.24232424      This is how the tool will be called by the model and in `tool_use` blocks.24252426    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`24272428      - `"direct"`24292430      - `"code_execution_20250825"`24312432      - `"code_execution_20260120"`24332434      - `"code_execution_20260521"`24352436    - `allowed_domains: optional array of string or null`24372438      List of domains to allow fetching from24392440    - `blocked_domains: optional array of string or null`24412442      List of domains to block fetching from24432444    - `cache_control: optional CacheControlEphemeral or null`24452446      Create a cache control breakpoint at this content block.24472448    - `citations: optional CitationsConfigParam or null`24492450      Citations configuration for fetched documents. Citations are disabled by default.24512452    - `defer_loading: optional boolean`24532454      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.24552456    - `max_content_tokens: optional number or null`24572458      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.24592460      exclusiveMinimum: 024612462    - `max_uses: optional number or null`24632464      Maximum number of times the tool can be used in the API request.24652466      exclusiveMinimum: 024672468    - `strict: optional boolean`24692470      When true, guarantees schema validation on tool names and inputs24712472    - `url_sources: optional WebFetchURLSources or null`24732474      Which sources contribute to the set of URLs web fetch may fetch.24752476      Each key is a tagged variant: `user_input` is `all` or `none`; the2477      two tool filters are `all`, `none`, `only` (only the named tools'2478      results) or `except` (every result but the named tools'). A named tool2479      must be declared in this request's `tools[]`.24802481      - `client_tool_results: optional WebFetchURLSourceAll or WebFetchURLSourceNone or WebFetchURLSourceOnly or WebFetchURLSourceExcept`24822483        Which client tools' results contribute fetchable URLs: "all", "none", or an only or except list of client tool names from tools[].24842485        - `WebFetchURLSourceAll object`24862487          The `url_sources` variant under which a source contributes in2488          full: every result of the tool filter's source, or all user input.24892490          - `type: "all"`24912492        - `WebFetchURLSourceNone object`24932494          The `url_sources` variant under which a source contributes nothing:2495          no result of the tool filter's source, or no user input.24962497          - `type: "none"`24982499        - `WebFetchURLSourceOnly object`25002501          The tool filter variant under which only the named tools' results2502          contribute.25032504          - `type: "only"`25052506          - `tools: array of WebFetchURLSourceToolReference`25072508            - `type: "tool_reference"`25092510            - `name: string`25112512        - `WebFetchURLSourceExcept object`25132514          The tool filter variant under which every result but the named2515          tools' contributes.25162517          - `type: "except"`25182519          - `tools: array of WebFetchURLSourceToolReference`25202521            - `type: "tool_reference"`25222523            - `name: string`25242525      - `server_tool_results: optional WebFetchURLSourceAll or WebFetchURLSourceNone or WebFetchURLSourceOnly or WebFetchURLSourceExcept`25262527        Which server tools' results contribute fetchable URLs: "all", "none", or an only or except list of server tool names from tools[]; only web_search and web_fetch results ever contribute.25282529        - `WebFetchURLSourceAll object`25302531          The `url_sources` variant under which a source contributes in2532          full: every result of the tool filter's source, or all user input.25332534        - `WebFetchURLSourceNone object`25352536          The `url_sources` variant under which a source contributes nothing:2537          no result of the tool filter's source, or no user input.25382539        - `WebFetchURLSourceOnly object`25402541          The tool filter variant under which only the named tools' results2542          contribute.25432544        - `WebFetchURLSourceExcept object`25452546          The tool filter variant under which every result but the named2547          tools' contributes.25482549      - `user_input: optional WebFetchURLSourceAll or WebFetchURLSourceNone`25502551        Whether URLs in user messages are fetchable: "all" or "none".25522553        - `WebFetchURLSourceAll object`25542555          The `url_sources` variant under which a source contributes in2556          full: every result of the tool filter's source, or all user input.25572558        - `WebFetchURLSourceNone object`25592560          The `url_sources` variant under which a source contributes nothing:2561          no result of the tool filter's source, or no user input.25622563  - `WebSearchTool20260209 object`25642565    - `type: "web_search_20260209"`25662567    - `name: "web_search"`25682569      Name of the tool.25702571      This is how the tool will be called by the model and in `tool_use` blocks.25722573    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`25742575      - `"direct"`25762577      - `"code_execution_20250825"`25782579      - `"code_execution_20260120"`25802581      - `"code_execution_20260521"`25822583    - `allowed_domains: optional array of string or null`25842585      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.25862587    - `blocked_domains: optional array of string or null`25882589      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.25902591    - `cache_control: optional CacheControlEphemeral or null`25922593      Create a cache control breakpoint at this content block.25942595    - `defer_loading: optional boolean`25962597      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.25982599    - `max_uses: optional number or null`26002601      Maximum number of times the tool can be used in the API request.26022603      exclusiveMinimum: 026042605    - `strict: optional boolean`26062607      When true, guarantees schema validation on tool names and inputs26082609    - `user_location: optional UserLocation or null`26102611      Parameters for the user's location. Used to provide more relevant search results.26122613  - `WebFetchTool20260209 object`26142615    - `type: "web_fetch_20260209"`26162617    - `name: "web_fetch"`26182619      Name of the tool.26202621      This is how the tool will be called by the model and in `tool_use` blocks.26222623    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`26242625      - `"direct"`26262627      - `"code_execution_20250825"`26282629      - `"code_execution_20260120"`26302631      - `"code_execution_20260521"`26322633    - `allowed_domains: optional array of string or null`26342635      List of domains to allow fetching from26362637    - `blocked_domains: optional array of string or null`26382639      List of domains to block fetching from26402641    - `cache_control: optional CacheControlEphemeral or null`26422643      Create a cache control breakpoint at this content block.26442645    - `citations: optional CitationsConfigParam or null`26462647      Citations configuration for fetched documents. Citations are disabled by default.26482649    - `defer_loading: optional boolean`26502651      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.26522653    - `max_content_tokens: optional number or null`26542655      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.26562657      exclusiveMinimum: 026582659    - `max_uses: optional number or null`26602661      Maximum number of times the tool can be used in the API request.26622663      exclusiveMinimum: 026642665    - `strict: optional boolean`26662667      When true, guarantees schema validation on tool names and inputs26682669    - `url_sources: optional WebFetchURLSources or null`26702671      Which sources contribute to the set of URLs web fetch may fetch.26722673      Each key is a tagged variant: `user_input` is `all` or `none`; the2674      two tool filters are `all`, `none`, `only` (only the named tools'2675      results) or `except` (every result but the named tools'). A named tool2676      must be declared in this request's `tools[]`.26772678  - `WebFetchTool20260309 object`26792680    Web fetch tool with use_cache parameter for bypassing cached content.26812682    - `type: "web_fetch_20260309"`26832684    - `name: "web_fetch"`26852686      Name of the tool.26872688      This is how the tool will be called by the model and in `tool_use` blocks.26892690    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`26912692      - `"direct"`26932694      - `"code_execution_20250825"`26952696      - `"code_execution_20260120"`26972698      - `"code_execution_20260521"`26992700    - `allowed_domains: optional array of string or null`27012702      List of domains to allow fetching from27032704    - `blocked_domains: optional array of string or null`27052706      List of domains to block fetching from27072708    - `cache_control: optional CacheControlEphemeral or null`27092710      Create a cache control breakpoint at this content block.27112712    - `citations: optional CitationsConfigParam or null`27132714      Citations configuration for fetched documents. Citations are disabled by default.27152716    - `defer_loading: optional boolean`27172718      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.27192720    - `max_content_tokens: optional number or null`27212722      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.27232724      exclusiveMinimum: 027252726    - `max_uses: optional number or null`27272728      Maximum number of times the tool can be used in the API request.27292730      exclusiveMinimum: 027312732    - `strict: optional boolean`27332734      When true, guarantees schema validation on tool names and inputs27352736    - `url_sources: optional WebFetchURLSources or null`27372738      Which sources contribute to the set of URLs web fetch may fetch.27392740      Each key is a tagged variant: `user_input` is `all` or `none`; the2741      two tool filters are `all`, `none`, `only` (only the named tools'2742      results) or `except` (every result but the named tools'). A named tool2743      must be declared in this request's `tools[]`.27442745    - `use_cache: optional boolean`27462747      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.27482749  - `WebSearchTool20260318 object`27502751    - `type: "web_search_20260318"`27522753    - `name: "web_search"`27542755      Name of the tool.27562757      This is how the tool will be called by the model and in `tool_use` blocks.27582759    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`27602761      - `"direct"`27622763      - `"code_execution_20250825"`27642765      - `"code_execution_20260120"`27662767      - `"code_execution_20260521"`27682769    - `allowed_domains: optional array of string or null`27702771      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.27722773    - `blocked_domains: optional array of string or null`27742775      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.27762777    - `cache_control: optional CacheControlEphemeral or null`27782779      Create a cache control breakpoint at this content block.27802781    - `defer_loading: optional boolean`27822783      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.27842785    - `max_uses: optional number or null`27862787      Maximum number of times the tool can be used in the API request.27882789      exclusiveMinimum: 027902791    - `response_inclusion: optional "full" or "excluded"`27922793      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.27942795      - `"full"`27962797      - `"excluded"`27982799    - `strict: optional boolean`28002801      When true, guarantees schema validation on tool names and inputs28022803    - `user_location: optional UserLocation or null`28042805      Parameters for the user's location. Used to provide more relevant search results.28062807  - `WebFetchTool20260318 object`28082809    - `type: "web_fetch_20260318"`28102811    - `name: "web_fetch"`28122813      Name of the tool.28142815      This is how the tool will be called by the model and in `tool_use` blocks.28162817    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`28182819      - `"direct"`28202821      - `"code_execution_20250825"`28222823      - `"code_execution_20260120"`28242825      - `"code_execution_20260521"`28262827    - `allowed_domains: optional array of string or null`28282829      List of domains to allow fetching from28302831    - `blocked_domains: optional array of string or null`28322833      List of domains to block fetching from28342835    - `cache_control: optional CacheControlEphemeral or null`28362837      Create a cache control breakpoint at this content block.28382839    - `citations: optional CitationsConfigParam or null`28402841      Citations configuration for fetched documents. Citations are disabled by default.28422843    - `defer_loading: optional boolean`28442845      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.28462847    - `max_content_tokens: optional number or null`28482849      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.28502851      exclusiveMinimum: 028522853    - `max_uses: optional number or null`28542855      Maximum number of times the tool can be used in the API request.28562857      exclusiveMinimum: 028582859    - `response_inclusion: optional "full" or "excluded"`28602861      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.28622863      - `"full"`28642865      - `"excluded"`28662867    - `strict: optional boolean`28682869      When true, guarantees schema validation on tool names and inputs28702871    - `url_sources: optional WebFetchURLSources or null`28722873      Which sources contribute to the set of URLs web fetch may fetch.28742875      Each key is a tagged variant: `user_input` is `all` or `none`; the2876      two tool filters are `all`, `none`, `only` (only the named tools'2877      results) or `except` (every result but the named tools'). A named tool2878      must be declared in this request's `tools[]`.28792880    - `use_cache: optional boolean`28812882      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.28832884  - `ToolSearchToolBm25_20251119 object`28852886    - `type: "tool_search_tool_bm25_20251119" or "tool_search_tool_bm25"`28872888      - `"tool_search_tool_bm25_20251119"`28892890      - `"tool_search_tool_bm25"`28912892    - `name: "tool_search_tool_bm25"`28932894      Name of the tool.28952896      This is how the tool will be called by the model and in `tool_use` blocks.28972898    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`28992900      - `"direct"`29012902      - `"code_execution_20250825"`29032904      - `"code_execution_20260120"`29052906      - `"code_execution_20260521"`29072908    - `cache_control: optional CacheControlEphemeral or null`29092910      Create a cache control breakpoint at this content block.29112912    - `defer_loading: optional boolean`29132914      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.29152916    - `strict: optional boolean`29172918      When true, guarantees schema validation on tool names and inputs29192920  - `ToolSearchToolRegex20251119 object`29212922    - `type: "tool_search_tool_regex_20251119" or "tool_search_tool_regex"`29232924      - `"tool_search_tool_regex_20251119"`29252926      - `"tool_search_tool_regex"`29272928    - `name: "tool_search_tool_regex"`29292930      Name of the tool.29312932      This is how the tool will be called by the model and in `tool_use` blocks.29332934    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`29352936      - `"direct"`29372938      - `"code_execution_20250825"`29392940      - `"code_execution_20260120"`29412942      - `"code_execution_20260521"`29432944    - `cache_control: optional CacheControlEphemeral or null`29452946      Create a cache control breakpoint at this content block.29472948    - `defer_loading: optional boolean`29492950      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.29512952    - `strict: optional boolean`29532954      When true, guarantees schema validation on tool names and inputs29552956## Returns29572958- `MessageTokensCount object`29592960  - `input_tokens: number`29612962    The total number of tokens across the provided list of messages, system prompt, and tools.29632964## Example29652966```bash2967curl https://api.anthropic.com/v1/messages/count_tokens \2968    -H 'Content-Type: application/json' \2969    -H 'anthropic-version: 2023-06-01' \2970    -H "X-Api-Key: $ANTHROPIC_API_KEY" \2971    -d '{2972          "messages": [2973            {2974              "content": "Hello, world",2975              "role": "user"2976            }2977          ],2978          "model": "claude-opus-5",2979          "system": [2980            {2981              "text": "Today'\''s date is 2024-06-01.",2982              "type": "text"2983            }2984          ],2985          "thinking": {2986            "type": "adaptive"2987          },2988          "tools": [2989            {2990              "input_schema": {2991                "type": "object",2992                "properties": {2993                  "location": "bar",2994                  "unit": "bar"2995                },2996                "required": [2997                  "location"2998                ]2999              },3000              "name": "name"3001            }3002          ]3003        }'3004```30053006### Response (200)30073008```json3009{3010  "input_tokens": 20953011}3012```3013
Files main
Menu

Theme