API reference

Count tokens

Runs a real tokenizer over your messages and tools and returns the input token count. It calls no model and costs nothing.

POST/v1/messages/count_tokens

This is the same count the gateway uses to size the wallet hold on a real request, so it is a truthful preview rather than an approximation. Useful before sending a long document, or for showing a user what a request will cost.

curl https://api.overagent.cc/v1/messages/count_tokens \
  -H "x-api-key: $OVERAGENT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [{"role": "user", "content": "How many tokens is this?"}]
  }'

Very large prompts are refused here with 413 on the same size ceiling that applies to billed requests. See Limits.