Endpoints

Count tokens

POST /v1/messages/count_tokens: count tokens for a prompt before you send it.

Counts the tokens a Messages request would use, without generating a response. Claude Code calls it to size a prompt before sending it. Like Messages, it currently serves Claude Code; other clients get 403. It is free: not funds-gated and not billed.

POSThttps://api.roteo.ai/v1/messages/count_tokens

Request

modelstringrequired

The model the count should be computed for.

messagesarrayrequired

The conversation to count, in the same shape as Messages.

systemstring | array

An optional system prompt to include in the count.

toolsarray

Optional tool definitions to include in the count.

Response

{
  "input_tokens": 14,
  "cache_creation_input_tokens": 0,
  "cache_read_input_tokens": 0
}
json · 5 lines

This endpoint has its own, higher rate limit. See Rate limits.

Count tokens | Roteo