Application Process
To use the Claude Messages Count Tokens API, first go to the Ace Data Cloud Console to obtain your API Token and keep it for later use.
If you have not yet logged in or registered, you will be automatically redirected to the login page and invited to register and log in. After completion, you will automatically return to the current page.
One API Token can call all platform services; there is no need to apply separately for each service. Your first application includes free credits for a free trial; when credits are insufficient, you can recharge your general balance in the Console.
📘 Full documentation: Claude Messages Count Tokens API →
Basic Usage
The request path for the Claude Messages Count Tokens API is/v1/messages/count_tokens, consistent with the official Anthropic API. We need to provide at least two required parameters:
model: Select the Claude model to use;claude-opus-5-5can be used for Messages Token Count, such as the latest flagshipclaude-fable-5-1; the originalclaude-fable-5remains compatible and retained.claude-sonnet-5-5has joined the native Messages series interface, supporting image input and adaptive thinking; its official reference prices for input, output, and cache reads are 2, 10, and 0.20 USD per million Tokens, respectively.messages: An array of input messages, where each message containsrole(role) andcontent(content).
system: System prompt, which is included in the Token count.tools: Tool definitions, which are included in the Token count.thinking: Extended thinking configuration.tool_choice: Tool selection configuration.cache_control: Top-level or content block-level cache control configuration.
messages, system, tool call replays, URL images, and document/PDF content blocks use the same stable request structure as the Messages API.
cURL Example
Python Example
Using the Anthropic SDK
The Claude Messages Count Tokens API accepts the stable request structure of the Anthropic SDK and can be called through theanthropic library. The interface uses the native Count Tokens capability corresponding to the selected model to calculate input, and can be used to check the input size before sending a Messages request.
Token Counting Including Tools
If your request includes tool definitions, these tools will also be included in the Token count:Token Counting Including System Prompts
System prompts are also included in the Token count:Notes
- This API only calculates the number of input Tokens and does not generate any model output.
- Token counting results can be used to estimate input size and check the context window; final billing is based on
usagein the actual Messages response. - Images, PDFs, tool definitions, system prompts, and thinking configurations are included in the result according to the input rules of the selected model.
- This API is completely free and does not consume any credits.

