API/count_tokens
Count the input tokens of a Messages payload. No model runs, no credit is spent and it does not count toward your inference limits.
https://api.framewharf.com/v1/messages/count_tokensAuthorization: Bearer sk-your_api_keyYou need an API key and a model from the catalog. The response has the shape { "input_tokens": number }.
curl "https://api.framewharf.com/v1/messages/count_tokens" \
-H "Authorization: Bearer sk-your_api_key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"messages": [{"role": "user", "content": "Hello"}]
}'{
"input_tokens": 12
}Claude Code calls this endpoint to estimate context before sending an inference request. A client that can't call count_tokens falls back to counting through /v1/messages, and that request is billed.