Count tokens in a Message changedapi/beta/messages/count_tokens
Nearest release: v2.1.283, published 3 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+93added
Lines−132removed
From line
231
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits12to this page, all time
The whole hunk
from line 231, old and new numbered
/
from line 231
231231
232232 - `document_title: string or null`
233233
234 maxLength: 500, minLength: 1
234 minLength: 1, maxLength: 500
235235
236236 - `end_char_index: number`
237237
from line 251
251251
252252 - `document_title: string or null`
253253
254 maxLength: 500, minLength: 1
254 minLength: 1, maxLength: 500
255255
256256 - `end_page_number: number`
257257
from line 275
275275
276276 - `document_title: string or null`
277277
278 maxLength: 500, minLength: 1
278 minLength: 1, maxLength: 500
279279
280280 - `end_block_index: number`
281281
from line 299
299299
300300 - `title: string or null`
301301
302 maxLength: 512, minLength: 1
302 minLength: 1, maxLength: 512
303303
304304 - `url: string`
305305
from line 455
455455
456456 - `title: optional string or null`
457457
458 maxLength: 500, minLength: 1
458 minLength: 1, maxLength: 500
459459
460460 - `BetaSearchResultBlockParam object`
461461
from line 519
519519
520520 - `name: string`
521521
522 maxLength: 200, minLength: 1
522 minLength: 1, maxLength: 200
523523
524524 - `cache_control: optional BetaCacheControlEphemeral or null`
525525
from line 555
555555
556556 For a toolset member tool_use, the toolset family this member belongs to.
557557
558 maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$
558 minLength: 1, maxLength: 64, pattern: ^[a-zA-Z0-9_-]+$
559559
560560 - `BetaToolResultBlockParam object`
561561
from line 591
591591
592592 - `tool_name: string`
593593
594 maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$
594 minLength: 1, maxLength: 256, pattern: ^[a-zA-Z0-9_-]{1,256}$
595595
596596 - `cache_control: optional BetaCacheControlEphemeral or null`
597597
from line 619
619619
620620 The caller-assigned identifier for this tab, unique within the inventory.
621621
622 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
622 minLength: 1, maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
623623
624624 - `title: string`
625625
from line 645
645645
646646 Tabs opened and download state changes during this call. "Nothing to report" is expressed by omitting the field, never by an empty list.
647647
648 maxItems: 200, minItems: 1
648 minItems: 1, maxItems: 200
649649
650650 - `BetaBrowserStateChangeTabOpened object`
651651
from line 663
663663
664664 The `tab_id` of the opened tab, present in `tabs`.
665665
666 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
666 minLength: 1, maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
667667
668668 - `BetaBrowserStateChangeDownloadStarted object`
669669
from line 675
675675
676676 The caller-assigned identifier for this download, stable across the state changes reporting it.
677677
678 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
678 minLength: 1, maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
679679
680680 - `url: string`
681681
from line 696
696696
697697 The caller-assigned identifier for this download, stable across the state changes reporting it.
698698
699 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
699 minLength: 1, maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
700700
701701 - `url: string`
702702
from line 708
708708
709709 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.
710710
711 pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096
711 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
712712
713713 - `size_bytes: optional number or null`
714714
from line 726
726726
727727 The caller-assigned identifier for this download, stable across the state changes reporting it.
728728
729 maxLength: 4096, minLength: 1, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
729 minLength: 1, maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
730730
731731 - `url: string`
732732
from line 738
738738
739739 The failure or cancellation detail, when known.
740740
741 pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$, maxLength: 4096
741 maxLength: 4096, pattern: ^[^\x00-\x1f\x7f-\x9f\u2028\u2029]*$
742742
743743 - `is_error: optional boolean`
744744
from line 746
746746
747747 For a toolset member tool_result, the toolset family of the paired tool_use.
748748
749 maxLength: 64, minLength: 1, pattern: ^[a-zA-Z0-9_-]+$
749 minLength: 1, maxLength: 64, pattern: ^[a-zA-Z0-9_-]+$
750750
751751 - `BetaServerToolUseBlockParam object`
752752
from line 1178
11781178
11791179 - `tool_name: string`
11801180
1181 maxLength: 256, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,256}$
1181 minLength: 1, maxLength: 256, pattern: ^[a-zA-Z0-9_-]{1,256}$
11821182
11831183 - `cache_control: optional BetaCacheControlEphemeral or null`
11841184
from line 1370
13701370
13711371 This is how the tool will be called by the model and in `tool_use` blocks.
13721372
1373 maxLength: 128, minLength: 1, pattern: ^[a-zA-Z0-9_-]{1,128}$
1373 minLength: 1, maxLength: 128, pattern: ^[a-zA-Z0-9_-]{1,128}$
13741374
13751375 - `allowed_callers: optional array of "direct" or "code_execution_20250825" or "code_execution_20260120" or "code_execution_20260521"`
13761376
from line 1621
16211621
16221622 - `configs: optional BetaBrowserToolsetConfigs or null`
16231623
1624 Per-member configuration for `browser_toolset_20260801`: one
1625 optional field per member tool, keyed by the member name — the same
1626 name the member's `tool_use` blocks carry. Every member is an
1627 accepted key, and a member's defaults apply wherever its key is
1628 absent. Unknown keys are rejected: the field set is this toolset
1629 version's complete member set.
1624 Sparse per-member overrides, keyed by member name. Absent, null, and {} are equivalent; a member's defaults apply wherever its key is absent.
16301625
16311626 - `type: optional BetaBrowserTypeConfig or null`
16321627
from line 2242
22472242
22482243 - `configs: optional BetaComputerToolsetConfigs or null`
22492244
2250 Per-member configuration for `computer_toolset_20260801`: one
2251 optional field per member tool, keyed by the member name — the same
2252 name the member's `tool_use` blocks carry. Every member is an
2253 accepted key, and a member's defaults apply wherever its key is
2254 absent. Unknown keys are rejected: the field set is this toolset
2255 version's complete member set.
2245 Sparse per-member overrides, keyed by member name. Absent, null, and {} are equivalent; a member's defaults apply wherever its key is absent.
22562246
22572247 - `type: optional BetaComputerTypeConfig or null`
22582248
from line 2596
26062596
26072597 Maximum number of times the tool can be used in the API request.
26082598
2609 exclusiveMinimum: 0
2599 minimum: 1
26102600
26112601 - `strict: optional boolean`
26122602
from line 2612
26222612
26232613 The city of the user.
26242614
2625 maxLength: 255, minLength: 1
2615 minLength: 1, maxLength: 255
26262616
26272617 - `country: optional string or null`
26282618
26292619 The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.
26302620
2631 maxLength: 2, minLength: 2
2621 minLength: 2, maxLength: 2
26322622
26332623 - `region: optional string or null`
26342624
26352625 The region of the user.
26362626
2637 maxLength: 255, minLength: 1
2627 minLength: 1, maxLength: 255
26382628
26392629 - `timezone: optional string or null`
26402630
26412631 The [IANA timezone](https://nodatime.org/TimeZones) of the user.
26422632
2643 maxLength: 255, minLength: 1
2633 minLength: 1, maxLength: 255
26442634
26452635 - `BetaWebFetchTool20250910 object`
26462636
from line 2676
26862676
26872677 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.
26882678
2689 exclusiveMinimum: 0
2679 minimum: 1
26902680
26912681 - `max_uses: optional number or null`
26922682
26932683 Maximum number of times the tool can be used in the API request.
26942684
2695 exclusiveMinimum: 0
2685 minimum: 1
26962686
26972687 - `strict: optional boolean`
26982688
from line 2690
27002690
27012691 - `url_sources: optional BetaWebFetchURLSources or null`
27022692
2703 Which sources contribute to the set of URLs web fetch may fetch.
2693 Which sources contribute to the set of URLs the tool may fetch. Omitted means every source.
27042694
2705 Each key is a tagged variant: `user_input` is `all` or `none`; the
2706 two tool filters are `all`, `none`, `only` (only the named tools'
2707 results) or `except` (every result but the named tools'). A named tool
2708 must be declared in this request's `tools[]`.
2709
27102695 - `client_tool_results: optional BetaWebFetchURLSourceAll or BetaWebFetchURLSourceNone or BetaWebFetchURLSourceOnly or BetaWebFetchURLSourceExcept`
27112696
27122697 Which client tools' results contribute fetchable URLs: "all", "none", or an only or except list of client tool names from tools[].
from line 2814
28292814
28302815 Maximum number of times the tool can be used in the API request.
28312816
2832 exclusiveMinimum: 0
2817 minimum: 1
28332818
28342819 - `strict: optional boolean`
28352820
from line 2868
28832868
28842869 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.
28852870
2886 exclusiveMinimum: 0
2871 minimum: 1
28872872
28882873 - `max_uses: optional number or null`
28892874
28902875 Maximum number of times the tool can be used in the API request.
28912876
2892 exclusiveMinimum: 0
2877 minimum: 1
28932878
28942879 - `strict: optional boolean`
28952880
from line 2882
28972882
28982883 - `url_sources: optional BetaWebFetchURLSources or null`
28992884
2900 Which sources contribute to the set of URLs web fetch may fetch.
2885 Which sources contribute to the set of URLs the tool may fetch. Omitted means every source.
29012886
2902 Each key is a tagged variant: `user_input` is `all` or `none`; the
2903 two tool filters are `all`, `none`, `only` (only the named tools'
2904 results) or `except` (every result but the named tools'). A named tool
2905 must be declared in this request's `tools[]`.
2906
29072887 - `BetaWebFetchTool20260309 object`
29082888
29092889 Web fetch tool with use_cache parameter for bypassing cached content.
from line 2930
29502930
29512931 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.
29522932
2953 exclusiveMinimum: 0
2933 minimum: 1
29542934
29552935 - `max_uses: optional number or null`
29562936
29572937 Maximum number of times the tool can be used in the API request.
29582938
2959 exclusiveMinimum: 0
2939 minimum: 1
29602940
29612941 - `strict: optional boolean`
29622942
from line 2944
29642944
29652945 - `url_sources: optional BetaWebFetchURLSources or null`
29662946
2967 Which sources contribute to the set of URLs web fetch may fetch.
2947 Which sources contribute to the set of URLs the tool may fetch. Omitted means every source.
29682948
2969 Each key is a tagged variant: `user_input` is `all` or `none`; the
2970 two tool filters are `all`, `none`, `only` (only the named tools'
2971 results) or `except` (every result but the named tools'). A named tool
2972 must be declared in this request's `tools[]`.
2973
29742949 - `use_cache: optional boolean`
29752950
29762951 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.
from line 2990
30152990
30162991 Maximum number of times the tool can be used in the API request.
30172992
3018 exclusiveMinimum: 0
2993 minimum: 1
30192994
30202995 - `response_inclusion: optional "full" or "excluded"`
30212996
from line 3052
30773052
30783053 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.
30793054
3080 exclusiveMinimum: 0
3055 minimum: 1
30813056
30823057 - `max_uses: optional number or null`
30833058
30843059 Maximum number of times the tool can be used in the API request.
30853060
3086 exclusiveMinimum: 0
3061 minimum: 1
30873062
30883063 - `response_inclusion: optional "full" or "excluded"`
30893064
from line 3074
30993074
31003075 - `url_sources: optional BetaWebFetchURLSources or null`
31013076
3102 Which sources contribute to the set of URLs web fetch may fetch.
3077 Which sources contribute to the set of URLs the tool may fetch. Omitted means every source.
31033078
3104 Each key is a tagged variant: `user_input` is `all` or `none`; the
3105 two tool filters are `all`, `none`, `only` (only the named tools'
3106 results) or `except` (every result but the named tools'). A named tool
3107 must be declared in this request's `tools[]`.
3108
31093079 - `use_cache: optional boolean`
31103080
31113081 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.
from line 3090
31203090
31213091 See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.
31223092
3093 - `string`
3094
31233095 - `"claude-fable-5-1" or "claude-opus-5-5" or "claude-mythos-5-1" or 15 more`
31243096
31253097 The model that will complete your prompt.
from line 3134
31623134
31633135 Powerful intelligence for long-running agents and coding
31643136
3165 - `"claude-mythos-preview"`
3166
3167 New class of intelligence, strongest in coding and cybersecurity
3168
31693137 - `"claude-opus-4-6"`
31703138
31713139 Powerful intelligence for long-running agents and coding
from line 3166
31983166
31993167 High-performance model for agents and coding
32003168
3201 - `string`
3169 - `"claude-mythos-preview"`
32023170
3171 **Deprecated**: Will reach end-of-life on June 30, 2026. Please migrate to claude-mythos-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
3172
3173 New class of intelligence, strongest in coding and cybersecurity
3174
32033175 - `name: "advisor"`
32043176
32053177 Name of the tool.
from line 3210
32383210
32393211 Maximum number of times the tool can be used in the API request.
32403212
3241 exclusiveMinimum: 0
3213 minimum: 1
32423214
32433215 - `strict: optional boolean`
32443216
from line 3301
33293301
33303302 Name of the MCP server to configure tools for
33313303
3332 maxLength: 255, minLength: 1
3304 minLength: 1, maxLength: 255
33333305
33343306 - `cache_control: optional BetaCacheControlEphemeral or null`
33353307
from line 3411
34393411
34403412 The name of the MCP server this listing came from, as `mcp_servers` declares it.
34413413
3442 maxLength: 255, minLength: 1
3414 minLength: 1, maxLength: 255
34433415
34443416 - `tools: array of BetaMCPToolParam`
34453417
from line 3493
35213493
35223494 - `effort: optional "low" or "medium" or "high" or 2 more or null`
35233495
3524 All possible effort levels.
3496 How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.
35253497
3498 Valid values are `low`, `medium`, `high`, `xhigh`, or `max`.
3499
35263500 - `"low"`
35273501
35283502 - `"medium"`
from line 3519
35453519
35463520- `compaction: optional BetaCompactionConfig or null`
35473521
3548 Compact the whole conversation and return a signed `compaction` block,
3549 alone, that a later request sends back first in `messages`, in place of
3550 the messages it summarizes. There is no trigger and no pause flag: sending
3551 the parameter compacts, and nothing is sampled after the block.
3522 Compaction configuration.
35523523
3553 The summarization prompt is the server's own unless `instructions` are
3554 given, which then replace it for this request; a value that is empty or
3555 only whitespace counts as absent.
3524 When set on `POST /v1/messages`, the request is a compaction request: the conversation in `messages` is summarized and the response holds only the resulting `compaction` block (`stop_reason` `"compaction"`), which later requests send first in `messages` in place of the messages it summarizes. `POST /v1/messages/count_tokens` accepts this parameter and ignores it: the count it returns is for the conversation in `messages` as sent. Cannot be combined with `context_management`.
35563525
35573526 - `type: "summarize"`
35583527
from line 3541
35723541
35733542 List of context management edits to apply
35743543
3575 minItems: 0
3576
35773544 - `BetaClearToolUses20250919Edit object`
35783545
35793546 - `type: "clear_tool_uses_20250919"`
from line 3663
36963663
36973664 - `effort: optional "low" or "medium" or "high" or 2 more or null`
36983665
3699 All possible effort levels.
3666 How much effort the model should put into its response. Higher effort levels may result in more thorough analysis but take longer.
37003667
3668 Valid values are `low`, `medium`, `high`, `xhigh`, or `max`.
3669
37013670 - `"low"`
37023671
37033672 - `"medium"`
from line 3689
37203689
37213690 - `task_budget: optional BetaTokenTaskBudget or null`
37223691
3723 User-configurable total token budget across contexts.
3692 Configuration for token budget tracking across contexts.
37243693
37253694 - `type: "tokens"`
37263695
from line 3709
37403709
37413710- `speed: optional "standard" or "fast" or null`
37423711
3743 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.
3712 The inference speed mode for this request. `"fast"` enables high output-tokens-per-second inference.
37443713
37453714 - `"standard"`
37463715
from line 3761
37923761
37933762 - `block_binding: optional BetaThinkingBlockBinding or null`
37943763
3795 Controls for block binding: what happens when a thinking block this
3796 request sends back fails the conversation check. Every field is optional;
3797 an empty object means every default.
3764 Controls for block binding: what happens when a thinking block this request sends back fails the conversation check. `null`, absent or an empty object means every default.
37983765
37993766 - `prefix_mismatch_behavior: optional BetaThinkingPrefixMismatchBehavior or null`
38003767
3801 What happens when a thinking block in `messages` fails the conversation
3802 check: it was created in a different conversation, or the messages before
3803 it have changed since. `"error"` (the default) fails the request with a
3804 400 error. `"drop_block"` removes the failing blocks and the request
3805 proceeds; the model no longer sees the dropped reasoning.
3768 "error" (default) | "drop_block". What happens when a thinking block in `messages` fails the conversation check (it was created in a different conversation, or the messages before it have changed since). "error" fails the request with a 400 error. "drop_block" removes the failing blocks and the request proceeds; each removal is reported in `input_transformations`.
38063769
38073770 - `"error"`
38083771
from line 3791
38283791
38293792 - `block_binding: optional BetaThinkingBlockBinding or null`
38303793
3831 Controls for block binding: what happens when a thinking block this
3832 request sends back fails the conversation check. Every field is optional;
3833 an empty object means every default.
3794 Controls for block binding: what happens when a thinking block this request sends back fails the conversation check. `null`, absent or an empty object means every default.
38343795
38353796 - `display: optional "summarized" or "omitted" or "updates" or null`
38363797
No line in this hunk matches that.