Endpoints

Count tokens

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

Count the number of tokens a request would use, without generating a response. This is free: it is not funds-gated and is not billed.

POSThttps://api.spoofzone.com/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.

Example

curl https://api.spoofzone.com/v1/messages/count_tokens \
-H "x-api-key: $SPOOF_API_KEY" \
-H "content-type: application/json" \
-d '{
  "model": "claude-sonnet-4-6",
  "messages": [{ "role": "user", "content": "How many tokens is this?" }]
}'
bash · 7 lines

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 | Spoof