Count Tokens (Anthropic)
POST /v1/messages/count_tokensCounts the input tokens of a Messages request, as Anthropic’s count tokens endpoint does. It works for Claude models your organization serves through its own Anthropic account: the request goes to Anthropic unchanged, and Anthropic’s answer comes back unchanged. See Claude on your own Anthropic key.
curl https://api.aiand.com/v1/messages/count_tokens \ -H "x-api-key: sk-your-api-key" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{"model": "<claude-model-id>", "messages": [{"role": "user", "content": "Hello!"}]}'Replace <claude-model-id> with a Claude model your Anthropic account offers.
{ "input_tokens": 10 }Counting writes no request log and costs nothing on ai&.