Developer API
Token Counting API for LLM Apps
Add token, character, and word counts to your app with a simple key-based API. Request text is processed for the response and is not stored.
Bearer API keys
Create keys in the dashboard and call the API from scripts, apps, or internal tools.
Simple response
Receive token, character, no-space character, and word counts as JSON.
Text not stored
Usage records keep count metrics, not the submitted request text.
How the token API workflow works
The Token-Calculator.net API is a preflight utility for LLM products. Your application sends text before, during, or after an AI workflow, and the API responds with count metrics that can be used for prompt budgets, usage displays, document chunking, or internal cost estimates.
Create an API key
Sign in, choose a plan, and create a bearer key from the dashboard. The full key is only shown when it is created.
Send text
POST a JSON body with a text field to the tokenize endpoint. The endpoint does not require model-specific encoding input.
Use count metrics
Use the response to enforce limits, estimate prompt size, show usage to customers, or decide when to split large content.
Endpoint
- Method
- POST
- URL
- /api/v1/tokenize
cURL
curl https://token-calculator.net/api/v1/tokenize \
-H "Authorization: Bearer tc_live_your_key" \
-H "Content-Type: application/json" \
-d '{"text":"hello world"}'JavaScript
const response = await fetch("https://token-calculator.net/api/v1/tokenize", {
method: "POST",
headers: {
Authorization: "Bearer tc_live_your_key",
"Content-Type": "application/json"
},
body: JSON.stringify({ text: "hello world" })
});
const result = await response.json();Response
{
"tokens": 2,
"characters": 11,
"charactersWithoutSpaces": 10,
"words": 2
}