SPB Git

Repository Public

count_tokens.md 122.5 KB 3,932 lines markdown

1---2title: Count tokens in a Message3url: https://platform.claude.com/docs/en/api/beta/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-beta": optional array of AnthropicBeta`1920  Optional header to specify the beta version(s) you want to use.2122  - `string`2324  - `"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 43 more`2526    - `"message-batches-2024-09-24"`2728    - `"prompt-caching-2024-07-31"`2930    - `"computer-use-2024-10-22"`3132    - `"computer-use-2025-01-24"`3334    - `"pdfs-2024-09-25"`3536    - `"token-counting-2024-11-01"`3738    - `"token-efficient-tools-2025-02-19"`3940    - `"output-128k-2025-02-19"`4142    - `"files-api-2025-04-14"`4344    - `"mcp-client-2025-04-04"`4546    - `"mcp-client-2025-11-20"`4748    - `"dev-full-thinking-2025-05-14"`4950    - `"interleaved-thinking-2025-05-14"`5152    - `"code-execution-2025-05-22"`5354    - `"extended-cache-ttl-2025-04-11"`5556    - `"context-1m-2025-08-07"`5758    - `"context-management-2025-06-27"`5960    - `"model-context-window-exceeded-2025-08-26"`6162    - `"skills-2025-10-02"`6364    - `"fast-mode-2026-02-01"`6566    - `"output-300k-2026-03-24"`6768    - `"user-profiles-2026-03-24"`6970    - `"user-profiles-2026-08-18"`7172    - `"user-profiles-2026-09-04"`7374    - `"advisor-tool-2026-03-01"`7576    - `"managed-agents-2026-04-01"`7778    - `"cache-diagnosis-2026-04-07"`7980    - `"dreaming-2026-04-21"`8182    - `"thinking-token-count-2026-05-13"`8384    - `"server-side-fallback-2026-06-01"`8586    - `"server-side-fallback-2026-07-01"`8788    - `"fallback-credit-2026-06-01"`8990    - `"fallback-credit-2026-07-01"`9192    - `"agent-memory-2026-07-22"`9394    - `"mid-conversation-tool-changes-2026-07-01"`9596    - `"compact-2026-01-12"`9798    - `"computer-use-2025-11-24"`99100    - `"mcp-tunnels-2026-06-22"`101102    - `"structured-outputs-2025-11-13"`103104    - `"task-budgets-2026-03-13"`105106    - `"thinking-display-updates-2026-08-18"`107108    - `"ce-user-management-2026-07-13"`109110    - `"mid-conversation-output-config-2026-07-01"`111112    - `"thinking-binding-controls-2026-08-01"`113114    - `"mid-conversation-system-clear-at-2026-08-21"`115116    - `"compact-2026-09-04"`117118- `"anthropic-user-profile-id": optional string`119120  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.121122- `"anthropic-workspace-id": optional string`123124## Body parameters125126- `messages: array of BetaMessageParam`127128  Input messages.129130  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.131132  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.133134  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.135136  Example with a single `user` message:137138  ```json139  [{"role": "user", "content": "Hello, Claude"}]140  ```141142  Example with multiple conversational turns:143144  ```json145  [146    {"role": "user", "content": "Hello there."},147    {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"},148    {"role": "user", "content": "Can you explain LLMs in plain English?"},149  ]150  ```151152  Example with a partially-filled response from Claude:153154  ```json155  [156    {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},157    {"role": "assistant", "content": "The best answer is ("},158  ]159  ```160161  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:162163  ```json164  {"role": "user", "content": "Hello, Claude"}165  ```166167  ```json168  {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}169  ```170171  See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).172173  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.174175  There is a limit of 100,000 messages in a single request.176177  - `content: string or array of BetaContentBlockParam`178179    - `string`180181    - `array of BetaContentBlockParam`182183      - `BetaTextBlockParam object`184185        - `type: "text"`186187        - `text: string`188189          minLength: 1190191        - `cache_control: optional BetaCacheControlEphemeral or null`192193          Create a cache control breakpoint at this content block.194195          - `type: "ephemeral"`196197          - `ttl: optional "5m" or "1h"`198199            The time-to-live for the cache control breakpoint.200201            This may be one the following values:202203            - `5m`: 5 minutes204            - `1h`: 1 hour205206            Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.207208            - `"5m"`209210            - `"1h"`211212        - `citations: optional array of BetaTextCitationParam or null`213214          - `BetaCitationCharLocationParam object`215216            - `type: "char_location"`217218            - `cited_text: string`219220            - `document_index: number`221222              minimum: 0223224            - `document_title: string or null`225226              maxLength: 500, minLength: 1227228            - `end_char_index: number`229230            - `start_char_index: number`231232              minimum: 0233234          - `BetaCitationPageLocationParam object`235236            - `type: "page_location"`237238            - `cited_text: string`239240            - `document_index: number`241242              minimum: 0243244            - `document_title: string or null`245246              maxLength: 500, minLength: 1247248            - `end_page_number: number`249250            - `start_page_number: number`251252              minimum: 1253254          - `BetaCitationContentBlockLocationParam object`255256            - `type: "content_block_location"`257258            - `cited_text: string`259260              The full text of the cited block range, concatenated.261262              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.263264            - `document_index: number`265266              minimum: 0267268            - `document_title: string or null`269270              maxLength: 500, minLength: 1271272            - `end_block_index: number`273274              Exclusive 0-based end index of the cited block range in the source's `content` array.275276              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.277278            - `start_block_index: number`279280              0-based index of the first cited block in the source's `content` array.281282              minimum: 0283284          - `BetaCitationWebSearchResultLocationParam object`285286            - `type: "web_search_result_location"`287288            - `cited_text: string`289290            - `encrypted_index: string`291292            - `title: string or null`293294              maxLength: 512, minLength: 1295296            - `url: string`297298              minLength: 1299300          - `BetaCitationSearchResultLocationParam object`301302            - `type: "search_result_location"`303304            - `cited_text: string`305306              The full text of the cited block range, concatenated.307308              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.309310            - `end_block_index: number`311312              Exclusive 0-based end index of the cited block range in the source's `content` array.313314              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.315316            - `search_result_index: number`317318              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.319320              Counted separately from `document_index`; server-side web search results are not included in this count.321322              minimum: 0323324            - `source: string`325326            - `start_block_index: number`327328              0-based index of the first cited block in the source's `content` array.329330              minimum: 0331332            - `title: string or null`333334      - `BetaImageBlockParam object`335336        - `type: "image"`337338        - `source: BetaBase64ImageSource or BetaURLImageSource or BetaFileImageSource`339340          - `BetaBase64ImageSource object`341342            - `type: "base64"`343344            - `data: string`345346              format: byte347348            - `media_type: "image/jpeg" or "image/png" or "image/gif" or "image/webp"`349350              - `"image/jpeg"`351352              - `"image/png"`353354              - `"image/gif"`355356              - `"image/webp"`357358          - `BetaURLImageSource object`359360            - `type: "url"`361362            - `url: string`363364          - `BetaFileImageSource object`365366            - `type: "file"`367368            - `file_id: string`369370        - `cache_control: optional BetaCacheControlEphemeral or null`371372          Create a cache control breakpoint at this content block.373374        - `transformations: optional BetaImageTransformationsParam or null`375376          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.377378          - `oversized_image: optional "downsize" or "error"`379380            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.381382            - `"downsize"`383384            - `"error"`385386      - `BetaRequestDocumentBlock object`387388        - `type: "document"`389390        - `source: BetaBase64PDFSource or BetaPlainTextSource or BetaContentBlockSource or 2 more`391392          - `BetaBase64PDFSource object`393394            - `type: "base64"`395396            - `data: string`397398              format: byte399400            - `media_type: "application/pdf"`401402          - `BetaPlainTextSource object`403404            - `type: "text"`405406            - `data: string`407408            - `media_type: "text/plain"`409410          - `BetaContentBlockSource object`411412            - `type: "content"`413414            - `content: string or array of BetaContentBlockSourceContent`415416              - `string`417418              - `BetaContentBlockSourceContent = array of BetaContentBlockSourceContent`419420                - `BetaTextBlockParam object`421422                - `BetaImageBlockParam object`423424          - `BetaURLPDFSource object`425426            - `type: "url"`427428            - `url: string`429430          - `BetaFileDocumentSource object`431432            - `type: "file"`433434            - `file_id: string`435436        - `cache_control: optional BetaCacheControlEphemeral or null`437438          Create a cache control breakpoint at this content block.439440        - `citations: optional BetaCitationsConfigParam or null`441442          - `enabled: optional boolean`443444        - `context: optional string or null`445446          minLength: 1447448        - `title: optional string or null`449450          maxLength: 500, minLength: 1451452      - `BetaSearchResultBlockParam object`453454        - `type: "search_result"`455456        - `content: array of BetaTextBlockParam`457458          - `type: "text"`459460          - `text: string`461462            minLength: 1463464          - `cache_control: optional BetaCacheControlEphemeral or null`465466            Create a cache control breakpoint at this content block.467468          - `citations: optional array of BetaTextCitationParam or null`469470        - `source: string`471472        - `title: string`473474        - `cache_control: optional BetaCacheControlEphemeral or null`475476          Create a cache control breakpoint at this content block.477478        - `citations: optional BetaCitationsConfigParam`479480      - `BetaThinkingBlockParam object`481482        - `type: "thinking"`483484        - `signature: string`485486          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.487488          Thinking blocks must be passed back unmodified and in their original order; a modified block results in a 400 `invalid_request_error`.489490        - `thinking: string`491492          The `thinking` text of this block as returned by the API.493494      - `BetaRedactedThinkingBlockParam object`495496        - `type: "redacted_thinking"`497498        - `data: string`499500          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.501502      - `BetaToolUseBlockParam object`503504        - `type: "tool_use"`505506        - `id: string`507508          pattern: ^[a-zA-Z0-9_-]+$509510        - `input: map[unknown]`511512        - `name: string`513514          maxLength: 200, minLength: 1515516        - `cache_control: optional BetaCacheControlEphemeral or null`517518          Create a cache control breakpoint at this content block.519520        - `caller: optional BetaDirectCaller or BetaServerToolCaller or BetaServerToolCaller20260120`521522          - `BetaDirectCaller object`523524            Tool invocation directly from the model.525526            - `type: "direct"`527528          - `BetaServerToolCaller object`529530            Tool invocation generated by a server-side tool.531532            - `type: "code_execution_20250825"`533534            - `tool_id: string`535536              pattern: ^srvtoolu_[a-zA-Z0-9_]+$537538          - `BetaServerToolCaller20260120 object`539540            - `type: "code_execution_20260120"`541542            - `tool_id: string`543544              pattern: ^srvtoolu_[a-zA-Z0-9_]+$545546        - `toolset_name: optional string or null`547548          For a toolset member tool_use, the toolset family this member belongs to.549550          maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$551552      - `BetaToolResultBlockParam object`553554        - `type: "tool_result"`555556        - `tool_use_id: string`557558          pattern: ^[a-zA-Z0-9_-]+$559560        - `cache_control: optional BetaCacheControlEphemeral or null`561562          Create a cache control breakpoint at this content block.563564        - `content: optional string or array of BetaTextBlockParam or BetaImageBlockParam or BetaSearchResultBlockParam or 3 more`565566          - `string`567568          - `array of BetaTextBlockParam or BetaImageBlockParam or BetaSearchResultBlockParam or 3 more`569570            - `BetaTextBlockParam object`571572            - `BetaImageBlockParam object`573574            - `BetaSearchResultBlockParam object`575576            - `BetaRequestDocumentBlock object`577578            - `BetaToolReferenceBlockParam object`579580              Tool reference block that can be included in tool_result content.581582              - `type: "tool_reference"`583584              - `tool_name: string`585586                maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$587588              - `cache_control: optional BetaCacheControlEphemeral or null`589590                Create a cache control breakpoint at this content block.591592            - `BetaBrowserStateBlockParam object`593594              The caller's browser state after a browser toolset member call —595              the full inventory of open tabs, which tab is active, and any side596              effects (tabs opened, download state changes) the call produced.597598              At most one per `tool_result`, only on a non-error result answering a599              browser toolset member `tool_use`. The server renders the600              model-visible text from it; the model never sees the raw fields.601602              - `type: "browser_state"`603604              - `tabs: array of BetaBrowserStateTabEntry`605606                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`.607608                maxItems: 100609610                - `tab_id: string`611612                  The caller-assigned identifier for this tab, unique within the inventory.613614                  maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$615616                - `title: string`617618                  The title of the page the tab is showing. May be empty.619620                  maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$621622                - `url: string`623624                  The URL of the page the tab is showing. May be empty.625626                  maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$627628                - `active: optional boolean`629630                  Whether this tab is the active tab after this call. Whenever `tabs` is non-empty, exactly one entry is marked `active: true`.631632              - `cache_control: optional BetaCacheControlEphemeral or null`633634                Create a cache control breakpoint at this content block.635636              - `state_changes: optional array of BetaBrowserStateChange or null`637638                Tabs opened and download state changes during this call. "Nothing to report" is expressed by omitting the field, never by an empty list.639640                maxItems: 200, minItems: 1641642                - `BetaBrowserStateChangeTabOpened object`643644                  A tab this call's execution opened that remains open at its end —645                  the creation delta of the `tabs` inventory, not an event log.646647                  Carries only the `tab_id`; the tab's `title` and `url` live on its648                  `tabs` entry, which must include the same `tab_id`. A tab opened649                  during a failed call gets no deferred `tab_opened`; it simply appears650                  in the next result's `tabs` inventory.651652                  - `type: "tab_opened"`653654                  - `tab_id: string`655656                    The `tab_id` of the opened tab, present in `tabs`.657658                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$659660                - `BetaBrowserStateChangeDownloadStarted object`661662                  A file download that started during this call.663664                  - `type: "download_started"`665666                  - `download_id: string`667668                    The caller-assigned identifier for this download, stable across the state changes reporting it.669670                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$671672                  - `url: string`673674                    The final post-redirect URL the download was served from.675676                    maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$677678                - `BetaBrowserStateChangeDownloadCompleted object`679680                  A file download that finished during this call, reported with the681                  same `download_id` as its `download_started` — or without a prior682                  `download_started`, when the download finished during the call that683                  started it (at most one state change per `download_id` per result).684685                  - `type: "download_completed"`686687                  - `download_id: string`688689                    The caller-assigned identifier for this download, stable across the state changes reporting it.690691                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$692693                  - `url: string`694695                    The final post-redirect URL the download was served from.696697                    maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$698699                  - `path: optional string or null`700701                    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.702703                    pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096704705                  - `size_bytes: optional number or null`706707                    The completed download's size.708709                    minimum: 0710711                - `BetaBrowserStateChangeDownloadFailed object`712713                  A file download that failed — or was cancelled — during this call.714715                  - `type: "download_failed"`716717                  - `download_id: string`718719                    The caller-assigned identifier for this download, stable across the state changes reporting it.720721                    maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$722723                  - `url: string`724725                    The final post-redirect URL the download was served from.726727                    maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$728729                  - `error: optional string or null`730731                    The failure or cancellation detail, when known.732733                    pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096734735        - `is_error: optional boolean`736737        - `toolset_name: optional string or null`738739          For a toolset member tool_result, the toolset family of the paired tool_use.740741          maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$742743      - `BetaServerToolUseBlockParam object`744745        - `type: "server_tool_use"`746747        - `id: string`748749          pattern: ^srvtoolu_[a-zA-Z0-9_]+$750751        - `input: map[unknown]`752753        - `name: "advisor" or "web_search" or "web_fetch" or 5 more`754755          - `"advisor"`756757          - `"web_search"`758759          - `"web_fetch"`760761          - `"code_execution"`762763          - `"bash_code_execution"`764765          - `"text_editor_code_execution"`766767          - `"tool_search_tool_regex"`768769          - `"tool_search_tool_bm25"`770771        - `cache_control: optional BetaCacheControlEphemeral or null`772773          Create a cache control breakpoint at this content block.774775        - `caller: optional BetaDirectCaller or BetaServerToolCaller or BetaServerToolCaller20260120`776777          - `BetaDirectCaller object`778779            Tool invocation directly from the model.780781          - `BetaServerToolCaller object`782783            Tool invocation generated by a server-side tool.784785          - `BetaServerToolCaller20260120 object`786787      - `BetaWebSearchToolResultBlockParam object`788789        - `type: "web_search_tool_result"`790791        - `content: BetaWebSearchToolResultBlockParamContent`792793          - `ResultBlock = array of BetaWebSearchResultBlockParam`794795            - `type: "web_search_result"`796797            - `encrypted_content: string`798799            - `title: string`800801            - `url: string`802803            - `page_age: optional string or null`804805          - `BetaWebSearchToolRequestError object`806807            - `type: "web_search_tool_result_error"`808809            - `error_code: BetaWebSearchToolResultErrorCode`810811              - `"invalid_tool_input"`812813              - `"unavailable"`814815              - `"max_uses_exceeded"`816817              - `"too_many_requests"`818819              - `"query_too_long"`820821              - `"request_too_large"`822823        - `tool_use_id: string`824825          pattern: ^srvtoolu_[a-zA-Z0-9_]+$826827        - `cache_control: optional BetaCacheControlEphemeral or null`828829          Create a cache control breakpoint at this content block.830831        - `caller: optional BetaDirectCaller or BetaServerToolCaller or BetaServerToolCaller20260120`832833          - `BetaDirectCaller object`834835            Tool invocation directly from the model.836837          - `BetaServerToolCaller object`838839            Tool invocation generated by a server-side tool.840841          - `BetaServerToolCaller20260120 object`842843      - `BetaWebFetchToolResultBlockParam object`844845        - `type: "web_fetch_tool_result"`846847        - `content: BetaWebFetchToolResultErrorBlockParam or BetaWebFetchBlockParam`848849          - `BetaWebFetchToolResultErrorBlockParam object`850851            - `type: "web_fetch_tool_result_error"`852853            - `error_code: BetaWebFetchToolResultErrorCode`854855              - `"invalid_tool_input"`856857              - `"url_too_long"`858859              - `"url_not_allowed"`860861              - `"url_not_in_prior_context"`862863              - `"url_not_accessible"`864865              - `"unsupported_content_type"`866867              - `"too_many_requests"`868869              - `"max_uses_exceeded"`870871              - `"unavailable"`872873              - `"content_too_large"`874875          - `BetaWebFetchBlockParam object`876877            - `type: "web_fetch_result"`878879            - `content: BetaRequestDocumentBlock`880881            - `url: string`882883              Fetched content URL884885            - `retrieved_at: optional string or null`886887              ISO 8601 timestamp when the content was retrieved888889        - `tool_use_id: string`890891          pattern: ^srvtoolu_[a-zA-Z0-9_]+$892893        - `cache_control: optional BetaCacheControlEphemeral or null`894895          Create a cache control breakpoint at this content block.896897        - `caller: optional BetaDirectCaller or BetaServerToolCaller or BetaServerToolCaller20260120`898899          - `BetaDirectCaller object`900901            Tool invocation directly from the model.902903          - `BetaServerToolCaller object`904905            Tool invocation generated by a server-side tool.906907          - `BetaServerToolCaller20260120 object`908909      - `BetaAdvisorToolResultBlockParam object`910911        - `type: "advisor_tool_result"`912913        - `content: BetaAdvisorToolResultErrorParam or BetaAdvisorResultBlockParam or BetaAdvisorRedactedResultBlockParam`914915          - `BetaAdvisorToolResultErrorParam object`916917            - `type: "advisor_tool_result_error"`918919            - `error_code: "max_uses_exceeded" or "prompt_too_long" or "too_many_requests" or 4 more`920921              - `"max_uses_exceeded"`922923              - `"prompt_too_long"`924925              - `"too_many_requests"`926927              - `"overloaded"`928929              - `"unavailable"`930931              - `"execution_time_exceeded"`932933              - `"model_not_found"`934935          - `BetaAdvisorResultBlockParam object`936937            - `type: "advisor_result"`938939            - `text: string`940941            - `stop_reason: optional string or null`942943          - `BetaAdvisorRedactedResultBlockParam object`944945            - `type: "advisor_redacted_result"`946947            - `encrypted_content: string`948949              Opaque blob produced by a prior response; must be round-tripped verbatim.950951            - `stop_reason: optional string or null`952953        - `tool_use_id: string`954955          pattern: ^srvtoolu_[a-zA-Z0-9_]+$956957        - `cache_control: optional BetaCacheControlEphemeral or null`958959          Create a cache control breakpoint at this content block.960961      - `BetaCodeExecutionToolResultBlockParam object`962963        - `type: "code_execution_tool_result"`964965        - `content: BetaCodeExecutionToolResultBlockParamContent`966967          - `BetaCodeExecutionToolResultErrorParam object`968969            - `type: "code_execution_tool_result_error"`970971            - `error_code: BetaCodeExecutionToolResultErrorCode`972973              - `"invalid_tool_input"`974975              - `"unavailable"`976977              - `"too_many_requests"`978979              - `"execution_time_exceeded"`980981          - `BetaCodeExecutionResultBlockParam object`982983            - `type: "code_execution_result"`984985            - `content: array of BetaCodeExecutionOutputBlockParam`986987              - `type: "code_execution_output"`988989              - `file_id: string`990991            - `return_code: number`992993            - `stderr: string`994995            - `stdout: string`996997          - `BetaEncryptedCodeExecutionResultBlockParam object`998999            Code execution result with encrypted stdout for PFC + web_search results.10001001            - `type: "encrypted_code_execution_result"`10021003            - `content: array of BetaCodeExecutionOutputBlockParam`10041005              - `type: "code_execution_output"`10061007              - `file_id: string`10081009            - `encrypted_stdout: string`10101011            - `return_code: number`10121013            - `stderr: string`10141015        - `tool_use_id: string`10161017          pattern: ^srvtoolu_[a-zA-Z0-9_]+$10181019        - `cache_control: optional BetaCacheControlEphemeral or null`10201021          Create a cache control breakpoint at this content block.10221023      - `BetaBashCodeExecutionToolResultBlockParam object`10241025        - `type: "bash_code_execution_tool_result"`10261027        - `content: BetaBashCodeExecutionToolResultErrorParam or BetaBashCodeExecutionResultBlockParam`10281029          - `BetaBashCodeExecutionToolResultErrorParam object`10301031            - `type: "bash_code_execution_tool_result_error"`10321033            - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or 2 more`10341035              - `"invalid_tool_input"`10361037              - `"unavailable"`10381039              - `"too_many_requests"`10401041              - `"execution_time_exceeded"`10421043              - `"output_file_too_large"`10441045          - `BetaBashCodeExecutionResultBlockParam object`10461047            - `type: "bash_code_execution_result"`10481049            - `content: array of BetaBashCodeExecutionOutputBlockParam`10501051              - `type: "bash_code_execution_output"`10521053              - `file_id: string`10541055            - `return_code: number`10561057            - `stderr: string`10581059            - `stdout: string`10601061        - `tool_use_id: string`10621063          pattern: ^srvtoolu_[a-zA-Z0-9_]+$10641065        - `cache_control: optional BetaCacheControlEphemeral or null`10661067          Create a cache control breakpoint at this content block.10681069      - `BetaTextEditorCodeExecutionToolResultBlockParam object`10701071        - `type: "text_editor_code_execution_tool_result"`10721073        - `content: BetaTextEditorCodeExecutionToolResultErrorParam or BetaTextEditorCodeExecutionViewResultBlockParam or BetaTextEditorCodeExecutionCreateResultBlockParam or BetaTextEditorCodeExecutionStrReplaceResultBlockParam`10741075          - `BetaTextEditorCodeExecutionToolResultErrorParam object`10761077            - `type: "text_editor_code_execution_tool_result_error"`10781079            - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or 2 more`10801081              - `"invalid_tool_input"`10821083              - `"unavailable"`10841085              - `"too_many_requests"`10861087              - `"execution_time_exceeded"`10881089              - `"file_not_found"`10901091            - `error_message: optional string or null`10921093          - `BetaTextEditorCodeExecutionViewResultBlockParam object`10941095            - `type: "text_editor_code_execution_view_result"`10961097            - `content: string`10981099            - `file_type: "text" or "image" or "pdf"`11001101              - `"text"`11021103              - `"image"`11041105              - `"pdf"`11061107            - `num_lines: optional number or null`11081109            - `start_line: optional number or null`11101111            - `total_lines: optional number or null`11121113          - `BetaTextEditorCodeExecutionCreateResultBlockParam object`11141115            - `type: "text_editor_code_execution_create_result"`11161117            - `is_file_update: boolean`11181119          - `BetaTextEditorCodeExecutionStrReplaceResultBlockParam object`11201121            - `type: "text_editor_code_execution_str_replace_result"`11221123            - `lines: optional array of string or null`11241125            - `new_lines: optional number or null`11261127            - `new_start: optional number or null`11281129            - `old_lines: optional number or null`11301131            - `old_start: optional number or null`11321133        - `tool_use_id: string`11341135          pattern: ^srvtoolu_[a-zA-Z0-9_]+$11361137        - `cache_control: optional BetaCacheControlEphemeral or null`11381139          Create a cache control breakpoint at this content block.11401141      - `BetaToolSearchToolResultBlockParam object`11421143        - `type: "tool_search_tool_result"`11441145        - `content: BetaToolSearchToolResultErrorParam or BetaToolSearchToolSearchResultBlockParam`11461147          - `BetaToolSearchToolResultErrorParam object`11481149            - `type: "tool_search_tool_result_error"`11501151            - `error_code: "invalid_tool_input" or "unavailable" or "too_many_requests" or "execution_time_exceeded"`11521153              - `"invalid_tool_input"`11541155              - `"unavailable"`11561157              - `"too_many_requests"`11581159              - `"execution_time_exceeded"`11601161            - `error_message: optional string or null`11621163          - `BetaToolSearchToolSearchResultBlockParam object`11641165            - `type: "tool_search_tool_search_result"`11661167            - `tool_references: array of BetaToolReferenceBlockParam`11681169              - `type: "tool_reference"`11701171              - `tool_name: string`11721173                maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$11741175              - `cache_control: optional BetaCacheControlEphemeral or null`11761177                Create a cache control breakpoint at this content block.11781179        - `tool_use_id: string`11801181          pattern: ^srvtoolu_[a-zA-Z0-9_]+$11821183        - `cache_control: optional BetaCacheControlEphemeral or null`11841185          Create a cache control breakpoint at this content block.11861187      - `BetaMCPToolUseBlockParam object`11881189        - `type: "mcp_tool_use"`11901191        - `id: string`11921193          pattern: ^[a-zA-Z0-9_-]+$11941195        - `input: map[unknown]`11961197        - `name: string`11981199        - `server_name: string`12001201          The name of the MCP server12021203        - `cache_control: optional BetaCacheControlEphemeral or null`12041205          Create a cache control breakpoint at this content block.12061207      - `BetaRequestMCPToolResultBlockParam object`12081209        - `type: "mcp_tool_result"`12101211        - `tool_use_id: string`12121213          pattern: ^[a-zA-Z0-9_-]+$12141215        - `cache_control: optional BetaCacheControlEphemeral or null`12161217          Create a cache control breakpoint at this content block.12181219        - `content: optional string or array of BetaTextBlockParam`12201221          - `string`12221223          - `BetaMCPToolResultBlockParamContent = array of BetaTextBlockParam`12241225            - `type: "text"`12261227            - `text: string`12281229              minLength: 112301231            - `cache_control: optional BetaCacheControlEphemeral or null`12321233              Create a cache control breakpoint at this content block.12341235            - `citations: optional array of BetaTextCitationParam or null`12361237        - `is_error: optional boolean`12381239      - `BetaContainerUploadBlockParam object`12401241        A content block that represents a file to be uploaded to the container1242        Files uploaded via this block will be available in the container's input directory.12431244        - `type: "container_upload"`12451246        - `file_id: string`12471248        - `cache_control: optional BetaCacheControlEphemeral or null`12491250          Create a cache control breakpoint at this content block.12511252      - `BetaCompactionBlockParam object`12531254        A compaction block containing summary of previous context.12551256        Users should round-trip these blocks from responses to subsequent requests1257        to maintain context across compaction boundaries.12581259        When content is None, the block represents a failed compaction. The server1260        treats these as no-ops. Empty string content is not allowed.12611262        - `type: "compaction"`12631264        - `cache_control: optional BetaCacheControlEphemeral or null`12651266          Create a cache control breakpoint at this content block.12671268        - `content: optional string or null`12691270          Summary of previously compacted content, or null if compaction failed12711272        - `encrypted_content: optional string or null`12731274          Opaque metadata from prior compaction, to be round-tripped verbatim12751276        - `signature: optional string or null`12771278          The block's signature as returned, to be sent back verbatim12791280      - `BetaRequestToolAdditionBlock object`12811282        Mid-conversation directive to surface a declared tool.12831284        `tool` references a tool (or MCP toolset) by name from the request's1285        `tools`; it is offered to the model from this point in the1286        conversation onward.12871288        - `type: "tool_addition"`12891290        - `tool: BetaToolChangeToolReference or BetaToolChangeMCPToolReference or BetaToolChangeMCPToolsetReference`12911292          - `BetaToolChangeToolReference object`12931294            Reference to a single tool the caller declared directly in1295            `tools[]`. Does not accept the composed `{server}_{name}` form the1296            server assigns to MCP-resolved tools — use `mcp_tool_reference` or1297            `mcp_toolset_reference` for those.12981299            - `type: "tool_reference"`13001301            - `name: string`13021303              pattern: ^[a-zA-Z0-9_-]{1,128}$13041305          - `BetaToolChangeMCPToolReference object`13061307            Reference to a single MCP tool by its server and remote name; the1308            same `server_name`/`name` pair `mcp_tool_use` carries.13091310            - `type: "mcp_tool_reference"`13111312            - `name: string`13131314            - `server_name: string`13151316          - `BetaToolChangeMCPToolsetReference object`13171318            Reference to every tool in the named MCP server's toolset.13191320            - `type: "mcp_toolset_reference"`13211322            - `server_name: string`13231324        - `cache_control: optional BetaCacheControlEphemeral or null`13251326          Create a cache control breakpoint at this content block.13271328      - `BetaRequestToolRemovalBlock object`13291330        Mid-conversation directive to withdraw a tool.13311332        `tool` references a tool (or MCP toolset) by name from the request's1333        `tools`; it is no longer offered to the model from this point in the1334        conversation onward.13351336        - `type: "tool_removal"`13371338        - `tool: BetaToolChangeToolReference or BetaToolChangeMCPToolReference or BetaToolChangeMCPToolsetReference`13391340          - `BetaToolChangeToolReference object`13411342            Reference to a single tool the caller declared directly in1343            `tools[]`. Does not accept the composed `{server}_{name}` form the1344            server assigns to MCP-resolved tools — use `mcp_tool_reference` or1345            `mcp_toolset_reference` for those.13461347          - `BetaToolChangeMCPToolReference object`13481349            Reference to a single MCP tool by its server and remote name; the1350            same `server_name`/`name` pair `mcp_tool_use` carries.13511352          - `BetaToolChangeMCPToolsetReference object`13531354            Reference to every tool in the named MCP server's toolset.13551356        - `cache_control: optional BetaCacheControlEphemeral or null`13571358          Create a cache control breakpoint at this content block.13591360      - `BetaFallbackBlockParam object`13611362        A `fallback` block echoed back from a prior response.13631364        Accepted in `messages[].content` and not rendered into the prompt; not1365        validated against the request's `fallbacks` chain or top-level `model`.13661367        Echo the assistant turn back verbatim, including this block in its1368        original position. The block marks the boundary between content produced1369        before and after a fallback hop, and the server relies on that boundary1370        to validate the turn: when thinking runs flank the boundary, omitting1371        the block merges them into one span the server cannot validate (the1372        request is rejected), and moving it into the middle of a single run is1373        likewise rejected; between non-thinking blocks the block's placement has1374        no validation effect.13751376        - `type: "fallback"`13771378        - `from: BetaFallbackInfoParam`13791380          Identifies one hop of a fallback transition.13811382          - `model: Model`13831384            The model that will complete your prompt.13851386            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.13871388            - `"claude-fable-5-1" or "claude-mythos-5-1" or "claude-sonnet-5" or 14 more`13891390              The model that will complete your prompt.13911392              See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.13931394              - `"claude-fable-5-1"`13951396                Frontier intelligence for ambitious tasks across coding, scientific discovery, and enterprise workflows13971398              - `"claude-mythos-5-1"`13991400                Our most capable model for cybersecurity and biology research, available through trusted access programs14011402              - `"claude-sonnet-5"`14031404                High-performance model for coding and agents14051406              - `"claude-fable-5"`14071408                Next generation of intelligence for the hardest knowledge work and coding problems14091410              - `"claude-mythos-5"`14111412                Most capable model for cybersecurity and biology research14131414              - `"claude-opus-5"`14151416                Powerful intelligence for long-running agents and coding14171418              - `"claude-opus-4-8"`14191420                Powerful intelligence for long-running agents and coding14211422              - `"claude-opus-4-7"`14231424                Powerful intelligence for long-running agents and coding14251426              - `"claude-mythos-preview"`14271428                New class of intelligence, strongest in coding and cybersecurity14291430              - `"claude-opus-4-6"`14311432                Powerful intelligence for long-running agents and coding14331434              - `"claude-sonnet-4-6"`14351436                Best combination of speed and intelligence14371438              - `"claude-haiku-4-5"`14391440                Fastest model with near-frontier intelligence14411442              - `"claude-haiku-4-5-20251001"`14431444                Fastest model with near-frontier intelligence14451446              - `"claude-opus-4-5"`14471448                Powerful intelligence for long-running agents and coding14491450              - `"claude-opus-4-5-20251101"`14511452                Powerful intelligence for long-running agents and coding14531454              - `"claude-sonnet-4-5"`14551456                High-performance model for agents and coding14571458              - `"claude-sonnet-4-5-20250929"`14591460                High-performance model for agents and coding14611462            - `string`14631464        - `to: BetaFallbackInfoParam`14651466          Identifies one hop of a fallback transition.14671468        - `trigger: optional unknown`14691470          The response block's `trigger`, echoed verbatim. Accepted and ignored by the server; any object or `null` is allowed.14711472  - `role: "user" or "assistant" or "system"`14731474    - `"user"`14751476    - `"assistant"`14771478    - `"system"`14791480  - `clear_at: optional "next_user_message" or "never" or null`14811482    How long this system message's text stays in front of the model. `"never"` (the default) renders it on every request that includes it. `"next_user_message"` renders it only for the user turn it follows: once a later `role: "user"` message exists in `messages` the message stays in the array (send it unchanged) but is no longer shown to the model. Only permitted on `role: "system"` messages.14831484    - `"next_user_message"`14851486    - `"never"`14871488  - `output_config: optional BetaSystemMessageOutputConfig or null`14891490    Per-message output configuration on a role:"system" input message.14911492    Fields here apply per-turn; `format` remains top-level only. An1493    empty `{}` is accepted on a message that carries content; a message1494    with neither content nor output_config fields is rejected.14951496    - `effort: optional "low" or "medium" or "high" or 2 more or null`14971498      All possible effort levels.14991500      - `"low"`15011502      - `"medium"`15031504      - `"high"`15051506      - `"xhigh"`15071508      - `"max"`15091510- `model: Model`15111512  The model that will complete your prompt.15131514  See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.15151516- `cache_control: optional BetaCacheControlEphemeral or null`15171518  Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.15191520- `compaction: optional BetaCompactionConfig or null`15211522  Compact the whole conversation and return a signed `compaction` block,1523  alone, that a later request sends back first in `messages`, in place of1524  the messages it summarizes. There is no trigger and no pause flag: sending1525  the parameter compacts, and nothing is sampled after the block.15261527  The summarization prompt is the server's own unless `instructions` are1528  given, which then replace it for this request; a value that is empty or1529  only whitespace counts as absent.15301531  - `type: "summarize"`15321533  - `instructions: optional string or null`15341535    Replaces the server's default summarization prompt for this request. An empty or whitespace-only value counts as absent.15361537    maxLength: 1638415381539- `context_management: optional BetaContextManagementConfig or null`15401541  Context management configuration.15421543  This allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.15441545  - `edits: optional array of BetaClearToolUses20250919Edit or BetaClearThinking20251015Edit or BetaCompact20260112Edit`15461547    List of context management edits to apply15481549    minItems: 015501551    - `BetaClearToolUses20250919Edit object`15521553      - `type: "clear_tool_uses_20250919"`15541555      - `clear_at_least: optional BetaInputTokensClearAtLeast or null`15561557        Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.15581559        - `type: "input_tokens"`15601561        - `value: number`15621563          minimum: 015641565      - `clear_tool_inputs: optional boolean or array of string or null`15661567        Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)15681569        - `boolean`15701571        - `array of string`15721573      - `exclude_tools: optional array of string or null`15741575        Tool names whose uses are preserved from clearing15761577      - `keep: optional BetaToolUsesKeep`15781579        Number of tool uses to retain in the conversation15801581        - `type: "tool_uses"`15821583        - `value: number`15841585          minimum: 015861587      - `trigger: optional BetaInputTokensTrigger or BetaToolUsesTrigger`15881589        Condition that triggers the context management strategy15901591        - `BetaInputTokensTrigger object`15921593          - `type: "input_tokens"`15941595          - `value: number`15961597            minimum: 115981599        - `BetaToolUsesTrigger object`16001601          - `type: "tool_uses"`16021603          - `value: number`16041605            minimum: 116061607    - `BetaClearThinking20251015Edit object`16081609      - `type: "clear_thinking_20251015"`16101611      - `keep: optional BetaThinkingTurns or BetaAllThinkingTurns or "all"`16121613        Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.16141615        - `BetaThinkingTurns object`16161617          - `type: "thinking_turns"`16181619          - `value: number`16201621            minimum: 116221623        - `BetaAllThinkingTurns object`16241625          - `type: "all"`16261627        - `"all"`16281629    - `BetaCompact20260112Edit object`16301631      Automatically compact older context when reaching the configured trigger threshold.16321633      - `type: "compact_20260112"`16341635      - `instructions: optional string or null`16361637        Additional instructions for summarization.16381639      - `pause_after_compaction: optional boolean`16401641        Whether to pause after compaction and return the compaction block to the user.16421643      - `trigger: optional BetaInputTokensTrigger or null`16441645        When to trigger compaction. Defaults to 150000 input tokens.16461647- `mcp_servers: optional array of BetaRequestMCPServerURLDefinition`16481649  MCP servers to be utilized in this request16501651  maxItems: 2016521653  - `type: "url"`16541655  - `name: string`16561657  - `url: string`16581659  - `authorization_token: optional string or null`16601661  - `tool_configuration: optional BetaRequestMCPServerToolConfiguration or null`16621663    - `allowed_tools: optional array of string or null`16641665    - `enabled: optional boolean or null`16661667- `output_config: optional BetaOutputConfig`16681669  Configuration options for the model's output, such as the output format.16701671  - `effort: optional "low" or "medium" or "high" or 2 more or null`16721673    All possible effort levels.16741675    - `"low"`16761677    - `"medium"`16781679    - `"high"`16801681    - `"xhigh"`16821683    - `"max"`16841685  - `format: optional BetaJSONOutputFormat or null`16861687    A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)16881689    - `type: "json_schema"`16901691    - `schema: map[unknown]`16921693      The JSON schema of the format16941695  - `task_budget: optional BetaTokenTaskBudget or null`16961697    User-configurable total token budget across contexts.16981699    - `type: "tokens"`17001701      The budget type. Currently only 'tokens' is supported.17021703    - `total: number`17041705      Total token budget across all contexts in the session.17061707      minimum: 102417081709    - `remaining: optional number or null`17101711      Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.17121713      minimum: 017141715- `speed: optional "standard" or "fast" or null`17161717  Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.17181719  - `"standard"`17201721  - `"fast"`17221723- `system: optional string or array of BetaTextBlockParam`17241725  System prompt.17261727  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).17281729  - `string`17301731  - `array of BetaTextBlockParam`17321733    - `type: "text"`17341735    - `text: string`17361737      minLength: 117381739    - `cache_control: optional BetaCacheControlEphemeral or null`17401741      Create a cache control breakpoint at this content block.17421743    - `citations: optional array of BetaTextCitationParam or null`17441745- `thinking: optional BetaThinkingConfigParam`17461747  Configuration for enabling Claude's extended thinking.17481749  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.17501751  See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.17521753  - `BetaThinkingConfigEnabled object`17541755    - `type: "enabled"`17561757    - `budget_tokens: number`17581759      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.17601761      Must be ≥1024 and less than `max_tokens`.17621763      See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.17641765      minimum: 102417661767    - `block_binding: optional BetaThinkingBlockBinding or null`17681769      Controls for block binding: what happens when a thinking block this1770      request sends back fails the conversation check. Every field is optional;1771      an empty object means every default.17721773      - `prefix_mismatch_behavior: optional BetaThinkingPrefixMismatchBehavior or null`17741775        What happens when a thinking block in `messages` fails the conversation1776        check: it was created in a different conversation, or the messages before1777        it have changed since. `"error"` (the default) fails the request with a1778        400 error. `"drop_block"` removes the failing blocks and the request1779        proceeds; the model no longer sees the dropped reasoning.17801781        - `"error"`17821783        - `"drop_block"`17841785    - `display: optional "summarized" or "omitted" or "updates" or null`17861787      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`.17881789      - `"summarized"`17901791      - `"omitted"`17921793      - `"updates"`17941795  - `BetaThinkingConfigDisabled object`17961797    - `type: "disabled"`17981799  - `BetaThinkingConfigAdaptive object`18001801    - `type: "adaptive"`18021803    - `block_binding: optional BetaThinkingBlockBinding or null`18041805      Controls for block binding: what happens when a thinking block this1806      request sends back fails the conversation check. Every field is optional;1807      an empty object means every default.18081809    - `display: optional "summarized" or "omitted" or "updates" or null`18101811      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`.18121813      - `"summarized"`18141815      - `"omitted"`18161817      - `"updates"`18181819- `tool_choice: optional BetaToolChoice`18201821  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.18221823  - `BetaToolChoiceAuto object`18241825    The model will automatically decide whether to use tools.18261827    - `type: "auto"`18281829    - `disable_parallel_tool_use: optional boolean`18301831      Whether to disable parallel tool use.18321833      Defaults to `false`. If set to `true`, the model will output at most one tool use.18341835  - `BetaToolChoiceAny object`18361837    The model will use any available tools.18381839    - `type: "any"`18401841    - `disable_parallel_tool_use: optional boolean`18421843      Whether to disable parallel tool use.18441845      Defaults to `false`. If set to `true`, the model will output exactly one tool use.18461847  - `BetaToolChoiceTool object`18481849    The model will use the specified tool with `tool_choice.name`.18501851    - `type: "tool"`18521853    - `name: string`18541855      The name of the tool to use.18561857    - `disable_parallel_tool_use: optional boolean`18581859      Whether to disable parallel tool use.18601861      Defaults to `false`. If set to `true`, the model will output exactly one tool use.18621863  - `BetaToolChoiceNone object`18641865    The model will not be allowed to use tools.18661867    - `type: "none"`18681869- `tools: optional array of BetaTool or BetaToolBash20241022 or BetaToolBash20250124 or 25 more`18701871  Definitions of tools that the model may use.18721873  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.18741875  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)).18761877  Each tool definition includes:18781879  * `name`: Name of the tool.1880  * `description`: Optional, but strongly-recommended description of the tool.1881  * `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.18821883  For example, if you defined `tools` as:18841885  ```json1886  [1887    {1888      "name": "get_stock_price",1889      "description": "Get the current stock price for a given ticker symbol.",1890      "input_schema": {1891        "type": "object",1892        "properties": {1893          "ticker": {1894            "type": "string",1895            "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."1896          }1897        },1898        "required": ["ticker"]1899      }1900    }1901  ]1902  ```19031904  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:19051906  ```json1907  [1908    {1909      "type": "tool_use",1910      "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",1911      "name": "get_stock_price",1912      "input": { "ticker": "^GSPC" }1913    }1914  ]1915  ```19161917  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:19181919  ```json1920  [1921    {1922      "type": "tool_result",1923      "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",1924      "content": "259.75 USD"1925    }1926  ]1927  ```19281929  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.19301931  See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.19321933  - `BetaTool object`19341935    - `type: optional "custom" or null`19361937    - `input_schema: object`19381939      [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.19401941      This defines the shape of the `input` that your tool accepts and that the model will produce.19421943      - `type: "object"`19441945      - `properties: optional map[unknown] or null`19461947      - `required: optional array of string or null`19481949    - `name: string`19501951      Name of the tool.19521953      This is how the tool will be called by the model and in `tool_use` blocks.19541955      maxLength: 128, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,128}$19561957    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`19581959      - `"direct"`19601961      - `"code_execution_20250825"`19621963      - `"code_execution_20260120"`19641965      - `"code_execution_20260521"`19661967    - `cache_control: optional BetaCacheControlEphemeral or null`19681969      Create a cache control breakpoint at this content block.19701971    - `defer_loading: optional boolean`19721973      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.19741975    - `description: optional string`19761977      Description of what this tool does.19781979      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.19801981    - `eager_input_streaming: optional boolean or null`19821983      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.19841985    - `input_examples: optional array of map[unknown]`19861987    - `strict: optional boolean`19881989      When true, guarantees schema validation on tool names and inputs19901991  - `BetaToolBash20241022 object`19921993    - `type: "bash_20241022"`19941995    - `name: "bash"`19961997      Name of the tool.19981999      This is how the tool will be called by the model and in `tool_use` blocks.20002001    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`20022003      - `"direct"`20042005      - `"code_execution_20250825"`20062007      - `"code_execution_20260120"`20082009      - `"code_execution_20260521"`20102011    - `cache_control: optional BetaCacheControlEphemeral or null`20122013      Create a cache control breakpoint at this content block.20142015    - `defer_loading: optional boolean`20162017      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.20182019    - `input_examples: optional array of map[unknown]`20202021    - `strict: optional boolean`20222023      When true, guarantees schema validation on tool names and inputs20242025  - `BetaToolBash20250124 object`20262027    - `type: "bash_20250124"`20282029    - `name: "bash"`20302031      Name of the tool.20322033      This is how the tool will be called by the model and in `tool_use` blocks.20342035    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`20362037      - `"direct"`20382039      - `"code_execution_20250825"`20402041      - `"code_execution_20260120"`20422043      - `"code_execution_20260521"`20442045    - `cache_control: optional BetaCacheControlEphemeral or null`20462047      Create a cache control breakpoint at this content block.20482049    - `defer_loading: optional boolean`20502051      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.20522053    - `input_examples: optional array of map[unknown]`20542055    - `strict: optional boolean`20562057      When true, guarantees schema validation on tool names and inputs20582059  - `BetaCodeExecutionTool20250522 object`20602061    - `type: "code_execution_20250522"`20622063    - `name: "code_execution"`20642065      Name of the tool.20662067      This is how the tool will be called by the model and in `tool_use` blocks.20682069    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`20702071      - `"direct"`20722073      - `"code_execution_20250825"`20742075      - `"code_execution_20260120"`20762077      - `"code_execution_20260521"`20782079    - `cache_control: optional BetaCacheControlEphemeral or null`20802081      Create a cache control breakpoint at this content block.20822083    - `defer_loading: optional boolean`20842085      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.20862087    - `strict: optional boolean`20882089      When true, guarantees schema validation on tool names and inputs20902091  - `BetaCodeExecutionTool20250825 object`20922093    - `type: "code_execution_20250825"`20942095    - `name: "code_execution"`20962097      Name of the tool.20982099      This is how the tool will be called by the model and in `tool_use` blocks.21002101    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`21022103      - `"direct"`21042105      - `"code_execution_20250825"`21062107      - `"code_execution_20260120"`21082109      - `"code_execution_20260521"`21102111    - `cache_control: optional BetaCacheControlEphemeral or null`21122113      Create a cache control breakpoint at this content block.21142115    - `defer_loading: optional boolean`21162117      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.21182119    - `strict: optional boolean`21202121      When true, guarantees schema validation on tool names and inputs21222123  - `BetaCodeExecutionTool20260120 object`21242125    Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).21262127    - `type: "code_execution_20260120"`21282129    - `name: "code_execution"`21302131      Name of the tool.21322133      This is how the tool will be called by the model and in `tool_use` blocks.21342135    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`21362137      - `"direct"`21382139      - `"code_execution_20250825"`21402141      - `"code_execution_20260120"`21422143      - `"code_execution_20260521"`21442145    - `cache_control: optional BetaCacheControlEphemeral or null`21462147      Create a cache control breakpoint at this content block.21482149    - `defer_loading: optional boolean`21502151      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.21522153    - `strict: optional boolean`21542155      When true, guarantees schema validation on tool names and inputs21562157  - `BetaCodeExecutionTool20260521 object`21582159    Code execution tool with REPL state persistence.21602161    - `type: "code_execution_20260521"`21622163    - `name: "code_execution"`21642165      Name of the tool.21662167      This is how the tool will be called by the model and in `tool_use` blocks.21682169    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`21702171      - `"direct"`21722173      - `"code_execution_20250825"`21742175      - `"code_execution_20260120"`21762177      - `"code_execution_20260521"`21782179    - `cache_control: optional BetaCacheControlEphemeral or null`21802181      Create a cache control breakpoint at this content block.21822183    - `defer_loading: optional boolean`21842185      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.21862187    - `strict: optional boolean`21882189      When true, guarantees schema validation on tool names and inputs21902191  - `BetaBrowserToolset20260801 object`21922193    The browser toolset: a single `tools[]` entry (carrying no2194    `name`) that declares the browser tool family. The model is served2195    the family's tool with any members disabled via `configs` removed2196    from its schema.21972198    - `type: "browser_toolset_20260801"`21992200    - `cache_control: optional BetaCacheControlEphemeral or null`22012202      Create a cache control breakpoint at this content block.22032204    - `configs: optional BetaBrowserToolsetConfigs or null`22052206      Per-member configuration for `browser_toolset_20260801`: one2207      optional field per member tool, keyed by the member name — the same2208      name the member's `tool_use` blocks carry. Every member is an2209      accepted key, and a member's defaults apply wherever its key is2210      absent. Unknown keys are rejected: the field set is this toolset2211      version's complete member set.22122213      - `type: optional BetaBrowserTypeConfig or null`22142215        `type`'s config overrides.22162217        - `defer_loading: optional boolean or null`22182219          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22202221        - `enabled: optional boolean or null`22222223          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.22242225      - `close_tab: optional BetaBrowserCloseTabConfig or null`22262227        `close_tab`'s config overrides.22282229        - `defer_loading: optional boolean or null`22302231          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22322233        - `enabled: optional boolean or null`22342235          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.22362237      - `double_click: optional BetaBrowserDoubleClickConfig or null`22382239        `double_click`'s config overrides.22402241        - `defer_loading: optional boolean or null`22422243          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22442245        - `enabled: optional boolean or null`22462247          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.22482249      - `file_upload: optional BetaBrowserFileUploadConfig or null`22502251        `file_upload`'s config overrides.22522253        - `defer_loading: optional boolean or null`22542255          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22562257        - `enabled: optional boolean or null`22582259          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.22602261      - `find: optional BetaBrowserFindConfig or null`22622263        `find`'s config overrides.22642265        - `defer_loading: optional boolean or null`22662267          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22682269        - `enabled: optional boolean or null`22702271          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.22722273      - `form_input: optional BetaBrowserFormInputConfig or null`22742275        `form_input`'s config overrides.22762277        - `defer_loading: optional boolean or null`22782279          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22802281        - `enabled: optional boolean or null`22822283          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.22842285      - `get_page_text: optional BetaBrowserGetPageTextConfig or null`22862287        `get_page_text`'s config overrides.22882289        - `defer_loading: optional boolean or null`22902291          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.22922293        - `enabled: optional boolean or null`22942295          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.22962297      - `hold_key: optional BetaBrowserHoldKeyConfig or null`22982299        `hold_key`'s config overrides.23002301        - `defer_loading: optional boolean or null`23022303          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23042305        - `enabled: optional boolean or null`23062307          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.23082309      - `hover: optional BetaBrowserHoverConfig or null`23102311        `hover`'s config overrides.23122313        - `defer_loading: optional boolean or null`23142315          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23162317        - `enabled: optional boolean or null`23182319          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.23202321      - `javascript_exec: optional BetaBrowserJavascriptExecConfig or null`23222323        `javascript_exec`'s config overrides.23242325        - `defer_loading: optional boolean or null`23262327          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23282329        - `enabled: optional boolean or null`23302331          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.23322333      - `key: optional BetaBrowserKeyConfig or null`23342335        `key`'s config overrides.23362337        - `defer_loading: optional boolean or null`23382339          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23402341        - `enabled: optional boolean or null`23422343          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.23442345      - `left_click: optional BetaBrowserLeftClickConfig or null`23462347        `left_click`'s config overrides.23482349        - `defer_loading: optional boolean or null`23502351          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23522353        - `enabled: optional boolean or null`23542355          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.23562357      - `left_click_drag: optional BetaBrowserLeftClickDragConfig or null`23582359        `left_click_drag`'s config overrides.23602361        - `defer_loading: optional boolean or null`23622363          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23642365        - `enabled: optional boolean or null`23662367          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.23682369      - `left_mouse_down: optional BetaBrowserLeftMouseDownConfig or null`23702371        `left_mouse_down`'s config overrides.23722373        - `defer_loading: optional boolean or null`23742375          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23762377        - `enabled: optional boolean or null`23782379          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.23802381      - `left_mouse_up: optional BetaBrowserLeftMouseUpConfig or null`23822383        `left_mouse_up`'s config overrides.23842385        - `defer_loading: optional boolean or null`23862387          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.23882389        - `enabled: optional boolean or null`23902391          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.23922393      - `list_tabs: optional BetaBrowserListTabsConfig or null`23942395        `list_tabs`'s config overrides.23962397        - `defer_loading: optional boolean or null`23982399          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24002401        - `enabled: optional boolean or null`24022403          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.24042405      - `middle_click: optional BetaBrowserMiddleClickConfig or null`24062407        `middle_click`'s config overrides.24082409        - `defer_loading: optional boolean or null`24102411          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24122413        - `enabled: optional boolean or null`24142415          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.24162417      - `mouse_move: optional BetaBrowserMouseMoveConfig or null`24182419        `mouse_move`'s config overrides.24202421        - `defer_loading: optional boolean or null`24222423          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24242425        - `enabled: optional boolean or null`24262427          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.24282429      - `navigate: optional BetaBrowserNavigateConfig or null`24302431        `navigate`'s config overrides.24322433        - `defer_loading: optional boolean or null`24342435          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24362437        - `enabled: optional boolean or null`24382439          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.24402441      - `new_tab: optional BetaBrowserNewTabConfig or null`24422443        `new_tab`'s config overrides.24442445        - `defer_loading: optional boolean or null`24462447          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24482449        - `enabled: optional boolean or null`24502451          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.24522453      - `read_console: optional BetaBrowserReadConsoleConfig or null`24542455        `read_console`'s config overrides.24562457        - `defer_loading: optional boolean or null`24582459          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24602461        - `enabled: optional boolean or null`24622463          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.24642465      - `read_network: optional BetaBrowserReadNetworkConfig or null`24662467        `read_network`'s config overrides.24682469        - `defer_loading: optional boolean or null`24702471          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24722473        - `enabled: optional boolean or null`24742475          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.24762477      - `read_page: optional BetaBrowserReadPageConfig or null`24782479        `read_page`'s config overrides.24802481        - `defer_loading: optional boolean or null`24822483          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24842485        - `enabled: optional boolean or null`24862487          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.24882489      - `right_click: optional BetaBrowserRightClickConfig or null`24902491        `right_click`'s config overrides.24922493        - `defer_loading: optional boolean or null`24942495          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.24962497        - `enabled: optional boolean or null`24982499          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.25002501      - `screenshot: optional BetaBrowserScreenshotConfig or null`25022503        `screenshot`'s config overrides.25042505        - `defer_loading: optional boolean or null`25062507          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25082509        - `enabled: optional boolean or null`25102511          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.25122513      - `scroll: optional BetaBrowserScrollConfig or null`25142515        `scroll`'s config overrides.25162517        - `defer_loading: optional boolean or null`25182519          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25202521        - `enabled: optional boolean or null`25222523          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.25242525      - `scroll_to: optional BetaBrowserScrollToConfig or null`25262527        `scroll_to`'s config overrides.25282529        - `defer_loading: optional boolean or null`25302531          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25322533        - `enabled: optional boolean or null`25342535          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.25362537      - `switch_tab: optional BetaBrowserSwitchTabConfig or null`25382539        `switch_tab`'s config overrides.25402541        - `defer_loading: optional boolean or null`25422543          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25442545        - `enabled: optional boolean or null`25462547          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.25482549      - `triple_click: optional BetaBrowserTripleClickConfig or null`25502551        `triple_click`'s config overrides.25522553        - `defer_loading: optional boolean or null`25542555          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25562557        - `enabled: optional boolean or null`25582559          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.25602561      - `wait: optional BetaBrowserWaitConfig or null`25622563        `wait`'s config overrides.25642565        - `defer_loading: optional boolean or null`25662567          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25682569        - `enabled: optional boolean or null`25702571          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.25722573      - `zoom: optional BetaBrowserZoomConfig or null`25742575        `zoom`'s config overrides.25762577        - `defer_loading: optional boolean or null`25782579          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.25802581        - `enabled: optional boolean or null`25822583          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.25842585  - `BetaToolComputerUse20241022 object`25862587    - `type: "computer_20241022"`25882589    - `display_height_px: number`25902591      The height of the display in pixels.25922593      minimum: 125942595    - `display_width_px: number`25962597      The width of the display in pixels.25982599      minimum: 126002601    - `name: "computer"`26022603      Name of the tool.26042605      This is how the tool will be called by the model and in `tool_use` blocks.26062607    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`26082609      - `"direct"`26102611      - `"code_execution_20250825"`26122613      - `"code_execution_20260120"`26142615      - `"code_execution_20260521"`26162617    - `cache_control: optional BetaCacheControlEphemeral or null`26182619      Create a cache control breakpoint at this content block.26202621    - `defer_loading: optional boolean`26222623      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.26242625    - `display_number: optional number or null`26262627      The X11 display number (e.g. 0, 1) for the display.26282629      minimum: 026302631    - `input_examples: optional array of map[unknown]`26322633    - `strict: optional boolean`26342635      When true, guarantees schema validation on tool names and inputs26362637  - `BetaMemoryTool20250818 object`26382639    - `type: "memory_20250818"`26402641    - `name: "memory"`26422643      Name of the tool.26442645      This is how the tool will be called by the model and in `tool_use` blocks.26462647    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`26482649      - `"direct"`26502651      - `"code_execution_20250825"`26522653      - `"code_execution_20260120"`26542655      - `"code_execution_20260521"`26562657    - `cache_control: optional BetaCacheControlEphemeral or null`26582659      Create a cache control breakpoint at this content block.26602661    - `defer_loading: optional boolean`26622663      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.26642665    - `input_examples: optional array of map[unknown]`26662667    - `strict: optional boolean`26682669      When true, guarantees schema validation on tool names and inputs26702671  - `BetaToolComputerUse20250124 object`26722673    - `type: "computer_20250124"`26742675    - `display_height_px: number`26762677      The height of the display in pixels.26782679      minimum: 126802681    - `display_width_px: number`26822683      The width of the display in pixels.26842685      minimum: 126862687    - `name: "computer"`26882689      Name of the tool.26902691      This is how the tool will be called by the model and in `tool_use` blocks.26922693    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`26942695      - `"direct"`26962697      - `"code_execution_20250825"`26982699      - `"code_execution_20260120"`27002701      - `"code_execution_20260521"`27022703    - `cache_control: optional BetaCacheControlEphemeral or null`27042705      Create a cache control breakpoint at this content block.27062707    - `defer_loading: optional boolean`27082709      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.27102711    - `display_number: optional number or null`27122713      The X11 display number (e.g. 0, 1) for the display.27142715      minimum: 027162717    - `input_examples: optional array of map[unknown]`27182719    - `strict: optional boolean`27202721      When true, guarantees schema validation on tool names and inputs27222723  - `BetaToolTextEditor20241022 object`27242725    - `type: "text_editor_20241022"`27262727    - `name: "str_replace_editor"`27282729      Name of the tool.27302731      This is how the tool will be called by the model and in `tool_use` blocks.27322733    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`27342735      - `"direct"`27362737      - `"code_execution_20250825"`27382739      - `"code_execution_20260120"`27402741      - `"code_execution_20260521"`27422743    - `cache_control: optional BetaCacheControlEphemeral or null`27442745      Create a cache control breakpoint at this content block.27462747    - `defer_loading: optional boolean`27482749      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.27502751    - `input_examples: optional array of map[unknown]`27522753    - `strict: optional boolean`27542755      When true, guarantees schema validation on tool names and inputs27562757  - `BetaToolComputerUse20251124 object`27582759    - `type: "computer_20251124"`27602761    - `display_height_px: number`27622763      The height of the display in pixels.27642765      minimum: 127662767    - `display_width_px: number`27682769      The width of the display in pixels.27702771      minimum: 127722773    - `name: "computer"`27742775      Name of the tool.27762777      This is how the tool will be called by the model and in `tool_use` blocks.27782779    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`27802781      - `"direct"`27822783      - `"code_execution_20250825"`27842785      - `"code_execution_20260120"`27862787      - `"code_execution_20260521"`27882789    - `cache_control: optional BetaCacheControlEphemeral or null`27902791      Create a cache control breakpoint at this content block.27922793    - `defer_loading: optional boolean`27942795      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.27962797    - `display_number: optional number or null`27982799      The X11 display number (e.g. 0, 1) for the display.28002801      minimum: 028022803    - `enable_zoom: optional boolean`28042805      Whether to enable an action to take a zoomed-in screenshot of the screen.28062807    - `input_examples: optional array of map[unknown]`28082809    - `strict: optional boolean`28102811      When true, guarantees schema validation on tool names and inputs28122813  - `BetaComputerToolset20260801 object`28142815    The computer toolset: a single `tools[]` entry (carrying no2816    `name`) that declares the computer tool family. The model is2817    served the family's tool with any members disabled via `configs`2818    removed from its schema. Every member is enabled by default, zoom2819    included. The single-tool options `display_number` and2820    `enable_zoom` are not fields of a toolset entry — it carries only2821    `type`, `configs`, and `cache_control`; zoom is controlled2822    via `configs.zoom.enabled`.28232824    - `type: "computer_toolset_20260801"`28252826    - `cache_control: optional BetaCacheControlEphemeral or null`28272828      Create a cache control breakpoint at this content block.28292830    - `configs: optional BetaComputerToolsetConfigs or null`28312832      Per-member configuration for `computer_toolset_20260801`: one2833      optional field per member tool, keyed by the member name — the same2834      name the member's `tool_use` blocks carry. Every member is an2835      accepted key, and a member's defaults apply wherever its key is2836      absent. Unknown keys are rejected: the field set is this toolset2837      version's complete member set.28382839      - `type: optional BetaComputerTypeConfig or null`28402841        `type`'s config overrides.28422843        - `defer_loading: optional boolean or null`28442845          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.28462847        - `enabled: optional boolean or null`28482849          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.28502851      - `cursor_position: optional BetaComputerCursorPositionConfig or null`28522853        `cursor_position`'s config overrides.28542855        - `defer_loading: optional boolean or null`28562857          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.28582859        - `enabled: optional boolean or null`28602861          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.28622863      - `double_click: optional BetaComputerDoubleClickConfig or null`28642865        `double_click`'s config overrides.28662867        - `defer_loading: optional boolean or null`28682869          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.28702871        - `enabled: optional boolean or null`28722873          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.28742875      - `hold_key: optional BetaComputerHoldKeyConfig or null`28762877        `hold_key`'s config overrides.28782879        - `defer_loading: optional boolean or null`28802881          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.28822883        - `enabled: optional boolean or null`28842885          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.28862887      - `key: optional BetaComputerKeyConfig or null`28882889        `key`'s config overrides.28902891        - `defer_loading: optional boolean or null`28922893          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.28942895        - `enabled: optional boolean or null`28962897          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.28982899      - `left_click: optional BetaComputerLeftClickConfig or null`29002901        `left_click`'s config overrides.29022903        - `defer_loading: optional boolean or null`29042905          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29062907        - `enabled: optional boolean or null`29082909          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.29102911      - `left_click_drag: optional BetaComputerLeftClickDragConfig or null`29122913        `left_click_drag`'s config overrides.29142915        - `defer_loading: optional boolean or null`29162917          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29182919        - `enabled: optional boolean or null`29202921          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.29222923      - `left_mouse_down: optional BetaComputerLeftMouseDownConfig or null`29242925        `left_mouse_down`'s config overrides.29262927        - `defer_loading: optional boolean or null`29282929          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29302931        - `enabled: optional boolean or null`29322933          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.29342935      - `left_mouse_up: optional BetaComputerLeftMouseUpConfig or null`29362937        `left_mouse_up`'s config overrides.29382939        - `defer_loading: optional boolean or null`29402941          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29422943        - `enabled: optional boolean or null`29442945          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.29462947      - `middle_click: optional BetaComputerMiddleClickConfig or null`29482949        `middle_click`'s config overrides.29502951        - `defer_loading: optional boolean or null`29522953          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29542955        - `enabled: optional boolean or null`29562957          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.29582959      - `mouse_move: optional BetaComputerMouseMoveConfig or null`29602961        `mouse_move`'s config overrides.29622963        - `defer_loading: optional boolean or null`29642965          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29662967        - `enabled: optional boolean or null`29682969          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.29702971      - `right_click: optional BetaComputerRightClickConfig or null`29722973        `right_click`'s config overrides.29742975        - `defer_loading: optional boolean or null`29762977          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29782979        - `enabled: optional boolean or null`29802981          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.29822983      - `screenshot: optional BetaComputerScreenshotConfig or null`29842985        `screenshot`'s config overrides.29862987        - `defer_loading: optional boolean or null`29882989          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.29902991        - `enabled: optional boolean or null`29922993          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.29942995      - `scroll: optional BetaComputerScrollConfig or null`29962997        `scroll`'s config overrides.29982999        - `defer_loading: optional boolean or null`30003001          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.30023003        - `enabled: optional boolean or null`30043005          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.30063007      - `triple_click: optional BetaComputerTripleClickConfig or null`30083009        `triple_click`'s config overrides.30103011        - `defer_loading: optional boolean or null`30123013          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.30143015        - `enabled: optional boolean or null`30163017          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.30183019      - `wait: optional BetaComputerWaitConfig or null`30203021        `wait`'s config overrides.30223023        - `defer_loading: optional boolean or null`30243025          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.30263027        - `enabled: optional boolean or null`30283029          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.30303031      - `zoom: optional BetaComputerZoomConfig or null`30323033        `zoom`'s config overrides.30343035        - `defer_loading: optional boolean or null`30363037          Defer loading for this member. Must resolve to the same value on every enabled member of the toolset.30383039        - `enabled: optional boolean or null`30403041          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.30423043  - `BetaToolTextEditor20250124 object`30443045    - `type: "text_editor_20250124"`30463047    - `name: "str_replace_editor"`30483049      Name of the tool.30503051      This is how the tool will be called by the model and in `tool_use` blocks.30523053    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`30543055      - `"direct"`30563057      - `"code_execution_20250825"`30583059      - `"code_execution_20260120"`30603061      - `"code_execution_20260521"`30623063    - `cache_control: optional BetaCacheControlEphemeral or null`30643065      Create a cache control breakpoint at this content block.30663067    - `defer_loading: optional boolean`30683069      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.30703071    - `input_examples: optional array of map[unknown]`30723073    - `strict: optional boolean`30743075      When true, guarantees schema validation on tool names and inputs30763077  - `BetaToolTextEditor20250429 object`30783079    - `type: "text_editor_20250429"`30803081    - `name: "str_replace_based_edit_tool"`30823083      Name of the tool.30843085      This is how the tool will be called by the model and in `tool_use` blocks.30863087    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`30883089      - `"direct"`30903091      - `"code_execution_20250825"`30923093      - `"code_execution_20260120"`30943095      - `"code_execution_20260521"`30963097    - `cache_control: optional BetaCacheControlEphemeral or null`30983099      Create a cache control breakpoint at this content block.31003101    - `defer_loading: optional boolean`31023103      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.31043105    - `input_examples: optional array of map[unknown]`31063107    - `strict: optional boolean`31083109      When true, guarantees schema validation on tool names and inputs31103111  - `BetaToolTextEditor20250728 object`31123113    - `type: "text_editor_20250728"`31143115    - `name: "str_replace_based_edit_tool"`31163117      Name of the tool.31183119      This is how the tool will be called by the model and in `tool_use` blocks.31203121    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`31223123      - `"direct"`31243125      - `"code_execution_20250825"`31263127      - `"code_execution_20260120"`31283129      - `"code_execution_20260521"`31303131    - `cache_control: optional BetaCacheControlEphemeral or null`31323133      Create a cache control breakpoint at this content block.31343135    - `defer_loading: optional boolean`31363137      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.31383139    - `input_examples: optional array of map[unknown]`31403141    - `max_characters: optional number or null`31423143      Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.31443145      minimum: 131463147    - `strict: optional boolean`31483149      When true, guarantees schema validation on tool names and inputs31503151  - `BetaWebSearchTool20250305 object`31523153    - `type: "web_search_20250305"`31543155    - `name: "web_search"`31563157      Name of the tool.31583159      This is how the tool will be called by the model and in `tool_use` blocks.31603161    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`31623163      - `"direct"`31643165      - `"code_execution_20250825"`31663167      - `"code_execution_20260120"`31683169      - `"code_execution_20260521"`31703171    - `allowed_domains: optional array of string or null`31723173      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.31743175    - `blocked_domains: optional array of string or null`31763177      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.31783179    - `cache_control: optional BetaCacheControlEphemeral or null`31803181      Create a cache control breakpoint at this content block.31823183    - `defer_loading: optional boolean`31843185      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.31863187    - `max_uses: optional number or null`31883189      Maximum number of times the tool can be used in the API request.31903191      exclusiveMinimum: 031923193    - `strict: optional boolean`31943195      When true, guarantees schema validation on tool names and inputs31963197    - `user_location: optional BetaUserLocation or null`31983199      Parameters for the user's location. Used to provide more relevant search results.32003201      - `type: "approximate"`32023203      - `city: optional string or null`32043205        The city of the user.32063207        maxLength: 255, minLength: 132083209      - `country: optional string or null`32103211        The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.32123213        maxLength: 2, minLength: 232143215      - `region: optional string or null`32163217        The region of the user.32183219        maxLength: 255, minLength: 132203221      - `timezone: optional string or null`32223223        The [IANA timezone](https://nodatime.org/TimeZones) of the user.32243225        maxLength: 255, minLength: 132263227  - `BetaWebFetchTool20250910 object`32283229    - `type: "web_fetch_20250910"`32303231    - `name: "web_fetch"`32323233      Name of the tool.32343235      This is how the tool will be called by the model and in `tool_use` blocks.32363237    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`32383239      - `"direct"`32403241      - `"code_execution_20250825"`32423243      - `"code_execution_20260120"`32443245      - `"code_execution_20260521"`32463247    - `allowed_domains: optional array of string or null`32483249      List of domains to allow fetching from32503251    - `blocked_domains: optional array of string or null`32523253      List of domains to block fetching from32543255    - `cache_control: optional BetaCacheControlEphemeral or null`32563257      Create a cache control breakpoint at this content block.32583259    - `citations: optional BetaCitationsConfigParam or null`32603261      Citations configuration for fetched documents. Citations are disabled by default.32623263    - `defer_loading: optional boolean`32643265      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.32663267    - `max_content_tokens: optional number or null`32683269      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.32703271      exclusiveMinimum: 032723273    - `max_uses: optional number or null`32743275      Maximum number of times the tool can be used in the API request.32763277      exclusiveMinimum: 032783279    - `strict: optional boolean`32803281      When true, guarantees schema validation on tool names and inputs32823283    - `url_sources: optional BetaWebFetchURLSources or null`32843285      Which sources contribute to the set of URLs web fetch may fetch.32863287      Each key is a tagged variant: `user_input` is `all` or `none`; the3288      two tool filters are `all`, `none`, `only` (only the named tools'3289      results) or `except` (every result but the named tools'). A named tool3290      must be declared in this request's `tools[]`.32913292      - `client_tool_results: optional BetaWebFetchURLSourceAll or BetaWebFetchURLSourceNone or BetaWebFetchURLSourceOnly or BetaWebFetchURLSourceExcept`32933294        Which client tools' results contribute fetchable URLs: "all", "none", or an only or except list of client tool names from tools[].32953296        - `BetaWebFetchURLSourceAll object`32973298          The `url_sources` variant under which a source contributes in3299          full: every result of the tool filter's source, or all user input.33003301          - `type: "all"`33023303        - `BetaWebFetchURLSourceNone object`33043305          The `url_sources` variant under which a source contributes nothing:3306          no result of the tool filter's source, or no user input.33073308          - `type: "none"`33093310        - `BetaWebFetchURLSourceOnly object`33113312          The tool filter variant under which only the named tools' results3313          contribute.33143315          - `type: "only"`33163317          - `tools: array of BetaWebFetchURLSourceToolReference`33183319            - `type: "tool_reference"`33203321            - `name: string`33223323        - `BetaWebFetchURLSourceExcept object`33243325          The tool filter variant under which every result but the named3326          tools' contributes.33273328          - `type: "except"`33293330          - `tools: array of BetaWebFetchURLSourceToolReference`33313332            - `type: "tool_reference"`33333334            - `name: string`33353336      - `server_tool_results: optional BetaWebFetchURLSourceAll or BetaWebFetchURLSourceNone or BetaWebFetchURLSourceOnly or BetaWebFetchURLSourceExcept`33373338        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.33393340        - `BetaWebFetchURLSourceAll object`33413342          The `url_sources` variant under which a source contributes in3343          full: every result of the tool filter's source, or all user input.33443345        - `BetaWebFetchURLSourceNone object`33463347          The `url_sources` variant under which a source contributes nothing:3348          no result of the tool filter's source, or no user input.33493350        - `BetaWebFetchURLSourceOnly object`33513352          The tool filter variant under which only the named tools' results3353          contribute.33543355        - `BetaWebFetchURLSourceExcept object`33563357          The tool filter variant under which every result but the named3358          tools' contributes.33593360      - `user_input: optional BetaWebFetchURLSourceAll or BetaWebFetchURLSourceNone`33613362        Whether URLs in user messages are fetchable: "all" or "none".33633364        - `BetaWebFetchURLSourceAll object`33653366          The `url_sources` variant under which a source contributes in3367          full: every result of the tool filter's source, or all user input.33683369        - `BetaWebFetchURLSourceNone object`33703371          The `url_sources` variant under which a source contributes nothing:3372          no result of the tool filter's source, or no user input.33733374  - `BetaWebSearchTool20260209 object`33753376    - `type: "web_search_20260209"`33773378    - `name: "web_search"`33793380      Name of the tool.33813382      This is how the tool will be called by the model and in `tool_use` blocks.33833384    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`33853386      - `"direct"`33873388      - `"code_execution_20250825"`33893390      - `"code_execution_20260120"`33913392      - `"code_execution_20260521"`33933394    - `allowed_domains: optional array of string or null`33953396      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.33973398    - `blocked_domains: optional array of string or null`33993400      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.34013402    - `cache_control: optional BetaCacheControlEphemeral or null`34033404      Create a cache control breakpoint at this content block.34053406    - `defer_loading: optional boolean`34073408      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.34093410    - `max_uses: optional number or null`34113412      Maximum number of times the tool can be used in the API request.34133414      exclusiveMinimum: 034153416    - `strict: optional boolean`34173418      When true, guarantees schema validation on tool names and inputs34193420    - `user_location: optional BetaUserLocation or null`34213422      Parameters for the user's location. Used to provide more relevant search results.34233424  - `BetaWebFetchTool20260209 object`34253426    - `type: "web_fetch_20260209"`34273428    - `name: "web_fetch"`34293430      Name of the tool.34313432      This is how the tool will be called by the model and in `tool_use` blocks.34333434    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`34353436      - `"direct"`34373438      - `"code_execution_20250825"`34393440      - `"code_execution_20260120"`34413442      - `"code_execution_20260521"`34433444    - `allowed_domains: optional array of string or null`34453446      List of domains to allow fetching from34473448    - `blocked_domains: optional array of string or null`34493450      List of domains to block fetching from34513452    - `cache_control: optional BetaCacheControlEphemeral or null`34533454      Create a cache control breakpoint at this content block.34553456    - `citations: optional BetaCitationsConfigParam or null`34573458      Citations configuration for fetched documents. Citations are disabled by default.34593460    - `defer_loading: optional boolean`34613462      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.34633464    - `max_content_tokens: optional number or null`34653466      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.34673468      exclusiveMinimum: 034693470    - `max_uses: optional number or null`34713472      Maximum number of times the tool can be used in the API request.34733474      exclusiveMinimum: 034753476    - `strict: optional boolean`34773478      When true, guarantees schema validation on tool names and inputs34793480    - `url_sources: optional BetaWebFetchURLSources or null`34813482      Which sources contribute to the set of URLs web fetch may fetch.34833484      Each key is a tagged variant: `user_input` is `all` or `none`; the3485      two tool filters are `all`, `none`, `only` (only the named tools'3486      results) or `except` (every result but the named tools'). A named tool3487      must be declared in this request's `tools[]`.34883489  - `BetaWebFetchTool20260309 object`34903491    Web fetch tool with use_cache parameter for bypassing cached content.34923493    - `type: "web_fetch_20260309"`34943495    - `name: "web_fetch"`34963497      Name of the tool.34983499      This is how the tool will be called by the model and in `tool_use` blocks.35003501    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`35023503      - `"direct"`35043505      - `"code_execution_20250825"`35063507      - `"code_execution_20260120"`35083509      - `"code_execution_20260521"`35103511    - `allowed_domains: optional array of string or null`35123513      List of domains to allow fetching from35143515    - `blocked_domains: optional array of string or null`35163517      List of domains to block fetching from35183519    - `cache_control: optional BetaCacheControlEphemeral or null`35203521      Create a cache control breakpoint at this content block.35223523    - `citations: optional BetaCitationsConfigParam or null`35243525      Citations configuration for fetched documents. Citations are disabled by default.35263527    - `defer_loading: optional boolean`35283529      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.35303531    - `max_content_tokens: optional number or null`35323533      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.35343535      exclusiveMinimum: 035363537    - `max_uses: optional number or null`35383539      Maximum number of times the tool can be used in the API request.35403541      exclusiveMinimum: 035423543    - `strict: optional boolean`35443545      When true, guarantees schema validation on tool names and inputs35463547    - `url_sources: optional BetaWebFetchURLSources or null`35483549      Which sources contribute to the set of URLs web fetch may fetch.35503551      Each key is a tagged variant: `user_input` is `all` or `none`; the3552      two tool filters are `all`, `none`, `only` (only the named tools'3553      results) or `except` (every result but the named tools'). A named tool3554      must be declared in this request's `tools[]`.35553556    - `use_cache: optional boolean`35573558      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.35593560  - `BetaWebSearchTool20260318 object`35613562    - `type: "web_search_20260318"`35633564    - `name: "web_search"`35653566      Name of the tool.35673568      This is how the tool will be called by the model and in `tool_use` blocks.35693570    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`35713572      - `"direct"`35733574      - `"code_execution_20250825"`35753576      - `"code_execution_20260120"`35773578      - `"code_execution_20260521"`35793580    - `allowed_domains: optional array of string or null`35813582      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.35833584    - `blocked_domains: optional array of string or null`35853586      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.35873588    - `cache_control: optional BetaCacheControlEphemeral or null`35893590      Create a cache control breakpoint at this content block.35913592    - `defer_loading: optional boolean`35933594      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.35953596    - `max_uses: optional number or null`35973598      Maximum number of times the tool can be used in the API request.35993600      exclusiveMinimum: 036013602    - `response_inclusion: optional "full" or "excluded"`36033604      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.36053606      - `"full"`36073608      - `"excluded"`36093610    - `strict: optional boolean`36113612      When true, guarantees schema validation on tool names and inputs36133614    - `user_location: optional BetaUserLocation or null`36153616      Parameters for the user's location. Used to provide more relevant search results.36173618  - `BetaWebFetchTool20260318 object`36193620    - `type: "web_fetch_20260318"`36213622    - `name: "web_fetch"`36233624      Name of the tool.36253626      This is how the tool will be called by the model and in `tool_use` blocks.36273628    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`36293630      - `"direct"`36313632      - `"code_execution_20250825"`36333634      - `"code_execution_20260120"`36353636      - `"code_execution_20260521"`36373638    - `allowed_domains: optional array of string or null`36393640      List of domains to allow fetching from36413642    - `blocked_domains: optional array of string or null`36433644      List of domains to block fetching from36453646    - `cache_control: optional BetaCacheControlEphemeral or null`36473648      Create a cache control breakpoint at this content block.36493650    - `citations: optional BetaCitationsConfigParam or null`36513652      Citations configuration for fetched documents. Citations are disabled by default.36533654    - `defer_loading: optional boolean`36553656      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.36573658    - `max_content_tokens: optional number or null`36593660      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.36613662      exclusiveMinimum: 036633664    - `max_uses: optional number or null`36653666      Maximum number of times the tool can be used in the API request.36673668      exclusiveMinimum: 036693670    - `response_inclusion: optional "full" or "excluded"`36713672      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.36733674      - `"full"`36753676      - `"excluded"`36773678    - `strict: optional boolean`36793680      When true, guarantees schema validation on tool names and inputs36813682    - `url_sources: optional BetaWebFetchURLSources or null`36833684      Which sources contribute to the set of URLs web fetch may fetch.36853686      Each key is a tagged variant: `user_input` is `all` or `none`; the3687      two tool filters are `all`, `none`, `only` (only the named tools'3688      results) or `except` (every result but the named tools'). A named tool3689      must be declared in this request's `tools[]`.36903691    - `use_cache: optional boolean`36923693      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.36943695  - `BetaAdvisorTool20260301 object`36963697    - `type: "advisor_20260301"`36983699    - `model: Model`37003701      The model that will complete your prompt.37023703      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.37043705    - `name: "advisor"`37063707      Name of the tool.37083709      This is how the tool will be called by the model and in `tool_use` blocks.37103711    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`37123713      - `"direct"`37143715      - `"code_execution_20250825"`37163717      - `"code_execution_20260120"`37183719      - `"code_execution_20260521"`37203721    - `cache_control: optional BetaCacheControlEphemeral or null`37223723      Create a cache control breakpoint at this content block.37243725    - `caching: optional BetaCacheControlEphemeral or null`37263727      Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached.37283729    - `defer_loading: optional boolean`37303731      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.37323733    - `max_tokens: optional number or null`37343735      Bounds the advisor's total output (thinking + text) per call. When the advisor hits this cap, the returned advisor_result or advisor_redacted_result block carries stop_reason='max_tokens', and a truncation note is appended to the advice text the worker model sees (inside the encrypted blob in redacted mode). When set, the server also emits a remaining-tokens budget block in the advisor's prompt so the advisor self-shapes toward the cap. When omitted, the advisor model's default output cap applies and no budget block is emitted.37363737      minimum: 102437383739    - `max_uses: optional number or null`37403741      Maximum number of times the tool can be used in the API request.37423743      exclusiveMinimum: 037443745    - `strict: optional boolean`37463747      When true, guarantees schema validation on tool names and inputs37483749  - `BetaToolSearchToolBm25_20251119 object`37503751    - `type: "tool_search_tool_bm25_20251119" or "tool_search_tool_bm25"`37523753      - `"tool_search_tool_bm25_20251119"`37543755      - `"tool_search_tool_bm25"`37563757    - `name: "tool_search_tool_bm25"`37583759      Name of the tool.37603761      This is how the tool will be called by the model and in `tool_use` blocks.37623763    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`37643765      - `"direct"`37663767      - `"code_execution_20250825"`37683769      - `"code_execution_20260120"`37703771      - `"code_execution_20260521"`37723773    - `cache_control: optional BetaCacheControlEphemeral or null`37743775      Create a cache control breakpoint at this content block.37763777    - `defer_loading: optional boolean`37783779      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.37803781    - `strict: optional boolean`37823783      When true, guarantees schema validation on tool names and inputs37843785  - `BetaToolSearchToolRegex20251119 object`37863787    - `type: "tool_search_tool_regex_20251119" or "tool_search_tool_regex"`37883789      - `"tool_search_tool_regex_20251119"`37903791      - `"tool_search_tool_regex"`37923793    - `name: "tool_search_tool_regex"`37943795      Name of the tool.37963797      This is how the tool will be called by the model and in `tool_use` blocks.37983799    - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`38003801      - `"direct"`38023803      - `"code_execution_20250825"`38043805      - `"code_execution_20260120"`38063807      - `"code_execution_20260521"`38083809    - `cache_control: optional BetaCacheControlEphemeral or null`38103811      Create a cache control breakpoint at this content block.38123813    - `defer_loading: optional boolean`38143815      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.38163817    - `strict: optional boolean`38183819      When true, guarantees schema validation on tool names and inputs38203821  - `BetaMCPToolset object`38223823    Configuration for a group of tools from an MCP server.38243825    Allows configuring enabled status and defer_loading for all tools3826    from an MCP server, with optional per-tool overrides.38273828    - `type: "mcp_toolset"`38293830    - `mcp_server_name: string`38313832      Name of the MCP server to configure tools for38333834      maxLength: 255, minLength: 138353836    - `cache_control: optional BetaCacheControlEphemeral or null`38373838      Create a cache control breakpoint at this content block.38393840    - `configs: optional map[BetaMCPToolConfig] or null`38413842      Configuration overrides for specific tools, keyed by tool name38433844      - `defer_loading: optional boolean`38453846      - `enabled: optional boolean`38473848    - `default_config: optional BetaMCPToolDefaultConfig`38493850      Default configuration applied to all tools from this server38513852      - `defer_loading: optional boolean`38533854      - `enabled: optional boolean`38553856- `output_format: optional BetaJSONOutputFormat or null`38573858  **Deprecated**38593860  Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)38613862  A schema to specify Claude's output format in responses. This parameter will be removed in a future release.38633864## Returns38653866- `BetaMessageTokensCount object`38673868  - `context_management: BetaCountTokensContextManagementResponse or null`38693870    Information about context management applied to the message.38713872    - `original_input_tokens: number`38733874      The original token count before context management was applied38753876  - `input_tokens: number`38773878    The total number of tokens across the provided list of messages, system prompt, and tools.38793880## Example38813882```bash3883curl https://api.anthropic.com/v1/messages/count_tokens \3884    -H 'Content-Type: application/json' \3885    -H 'anthropic-version: 2023-06-01' \3886    -H "X-Api-Key: $ANTHROPIC_API_KEY" \3887    -d '{3888          "messages": [3889            {3890              "content": "Hello, world",3891              "role": "user"3892            }3893          ],3894          "model": "claude-opus-5",3895          "system": [3896            {3897              "text": "Today'\''s date is 2024-06-01.",3898              "type": "text"3899            }3900          ],3901          "thinking": {3902            "type": "adaptive"3903          },3904          "tools": [3905            {3906              "input_schema": {3907                "type": "object",3908                "properties": {3909                  "location": "bar",3910                  "unit": "bar"3911                },3912                "required": [3913                  "location"3914                ]3915              },3916              "name": "name"3917            }3918          ]3919        }'3920```39213922### Response (200)39233924```json3925{3926  "context_management": {3927    "original_input_tokens": 03928  },3929  "input_tokens": 20953930}3931```3932
Files main
Menu

Theme