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.
What is a token counting API?
A token counting API is a developer endpoint that turns text into count metrics before an LLM request is made. Token-Calculator.net returns token count, total characters, characters without spaces, and word count so applications can estimate cost, reject oversized input, split documents, or show usage to end users.
Cost preflight
Use token counts with provider pricing to estimate input and expected output cost before calling an AI model.
Limit enforcement
Block or split text before a request exceeds a product limit, model context window, or user quota.
Developer telemetry
Record count metrics in your own app for support, analytics, billing previews, or prompt optimization.
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.
Cost planning formula
Token counts are useful because most LLM providers publish prices per one million input or output tokens. After the API returns a count, your application can combine that value with the model rate you plan to use.
Example: if a prompt is 25,000 tokens and the selected model charges $2.00 per 1M input tokens, estimated input cost is 25,000 / 1,000,000 x 2.00 = $0.05.
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
}Official pricing references
Token-Calculator.net provides count metrics and example cost formulas. Always verify final model prices against the provider's official pricing page before displaying production billing estimates.