AI Token Counter API
Count LLM tokens in text: exact counts for OpenAI's o200k_base and cl100k_base tokenizers, estimates for Claude, Gemini and Llama, and how much of common context windows it fills.
POST /api/v1/tools/ai-token-counterMCP ai_token_counterDeveloper ToolsCount tokens exactly for OpenAI o200k_base and cl100k_base, with labelled estimates for Claude, Gemini and Llama, and check which context windows your prompt fits.
Input
Send these as a JSON object. Unknown fields are rejected.
- input
- The text or prompt to count. (string, required)
curl https://pithlab.com/api/v1/tools/ai-token-counter \n -H "Authorization: Bearer $PITHLAB_KEY" \n -H "Content-Type: application/json" \n -d '{"input":"PithLab counts tokens the way GPT-4o does."}'Example response
{
"ok": true,
"result": {
"characters": 42,
"words": 7,
"lines": 1,
"tokens": {
"o200k_base": 13,
"cl100k_base": 14
},
"estimates": {
"claude": 12,
"gemini": 11,
"llama": 11
},
"contextWindows": [
{
"window": "8K",
"tokens": 8192,
"fits": true,
"percent": 0.2,
"remaining": 8179
},
{
"window": "32K",
"tokens": 32768,
"fits": true,
"percent": 0,
"remaining": 32755
},
{
"window": "128K",
"tokens": 128000,
"fits": true,
"percent": 0,
"remaining": 127987
},
{
"window": "200K",
"tokens": 200000,
"fits": true,
"percent": 0,
"remaining": 199987
},
{
"window": "1M",
"tokens": 1000000,
"fits": true,
"percent": 0,
"remaining": 999987
}
]
}
}