Skip to main content
Version: Next

Count tokens in a message

POST 

/v1/messages/count_tokens

Counts the input tokens of a Messages API request, as the model would be sent it, Spice's system prompt and tools included. Only a model with from: anthropic counts tokens: a count is specific to the model's tokenizer. The request and response follow the Messages API reference: <https://docs.claude.com/en/api/messages-count-tokens>.

Request​

Responses​

The input token count