Skip to main content
POST
/
anthropic
/
v1
/
messages
/
count_tokens
Anthropic Messages Count Tokens
curl --request POST \
  --url https://api.example.com/anthropic/v1/messages/count_tokens \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "system": "<string>",
  "tools": [
    {
      "name": "<string>",
      "input_schema": {},
      "description": "<string>"
    }
  ],
  "thinking": {
    "enabled": true
  },
  "tool_choice": {}
}
'
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Headers

authorization
string | null
x-api-key
string | null

Body

application/json
model
string
required
messages
Messages · object[]
required
system
tools
AnthropicTool · object[] | null
thinking
AnthropicThinkingConfig · object
tool_choice
Tool Choice · object

Response

Successful Response