How Many Tokens Am I Spending?
The Question
- How many tokens I'm spending?
Setup
- curl, claude-sonnet-5, claude-opus-5-5
Results
- How many tokens are used?
claude-sonnet-5
curl https://api.anthropic.com/v1/messages/count_tokens \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "content-type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-5",
"messages": [{
"role": "user",
"content": "how many tokens is this sentence?"
}]
}'
{"input_tokens":17} <--------
claude-opus-5-5
curl https://api.anthropic.com/v1/messages/count_tokens \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "content-type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-5-5",
"messages": [{
"role": "user",
"content": "how many tokens is this sentence?"
}]
}'
{"input_tokens":19} <--------
What I learned
- Not all LLMs "charge" the same amount of tokens
- Available tokens are directly correlated with the chosen LLM and context
GIT Repository
- N/A
Log
- 2026-09-25 — Starting with something simple.