Перейти до основного вмісту
POST
/
v1
/
messages
/
count_tokens
Claude Messages Count Tokens
curl --request POST \
  --url https://api.acedata.cloud/v1/messages/count_tokens \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "claude-sonnet-4-6",
  "messages": [
    {
      "role": "user",
      "content": "<string>"
    }
  ],
  "system": "<string>",
  "thinking": {
    "type": "enabled",
    "budget_tokens": 123
  },
  "tool_choice": {},
  "tools": [
    {}
  ]
}
'
{
  "input_tokens": 123
}

Авторизації

Authorization
string
header
обов'язково

Тіло

application/json
model
string
обов'язково

The model that will complete your prompt.

Приклад:

"claude-sonnet-4-6"

messages
object[]
обов'язково

Input messages.

system
string

System prompt.

thinking
object

Configuration for enabling Claude's extended thinking.

tool_choice
object

How the model should use the provided tools.

tools
object[]

Definitions of tools that the model may use.

Відповідь

OK

input_tokens
integer
обов'язково

The total number of tokens across the provided list of messages, system prompt, and tools.