curl --request POST \
--url 'https://api.nsr.stateset.com/v1/messages/count_tokens' \
--header "X-API-Key: $STATESET_NSR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{}'
{
"input_tokens": 1
}
Anthropic-compatible token counting (POST /v1/messages/count_tokens).
Claude Code and the Anthropic SDKs call this before sending requests. Required scope: write
POST
/
v1
/
messages
/
count_tokens
curl --request POST \
--url 'https://api.nsr.stateset.com/v1/messages/count_tokens' \
--header "X-API-Key: $STATESET_NSR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{}'
{
"input_tokens": 1
}
Claude Code and the Anthropic SDKs call this before sending requests.
Required scope:
write
Request body
JSON body of typeany.
Response
CountTokensResponse
integer (int32)
required
Status codes
| Code | Meaning |
|---|---|
200 | Estimated input token count |
401 | Unauthorized — missing or invalid credentials |
403 | Forbidden — the key/token lacks the required scope |
429 | Rate limited — see Retry-After / X-RateLimit-Reset |
curl --request POST \
--url 'https://api.nsr.stateset.com/v1/messages/count_tokens' \
--header "X-API-Key: $STATESET_NSR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{}'
{
"input_tokens": 1
}
Last modified on August 31, 2026