TokenCalculator Developer Platform

One payload.
Measurement you can ship.

Count text, chat content, extracted files, source code, and image geometry; return token usage, cost, context pressure, algorithm details, and verified pricing through a versioned edge API or privacy-first local SDK.

PUBLIC HTTP API

Zero-key edge endpoint

Best for demos, CI checks, server integrations, and non-sensitive workloads. Supports single, batch, and multi-model requests.

POST /api/v1/count
LOCAL NPM SDK

Content remains on-device

Best for enterprise prompts, repositories, and confidential extracted documents. The same measurement core runs inside your process.

npm i @jay0073/tokencalculator-core
Live request laboratory

Change the payload. Inspect every layer.

The playground calls the public endpoint. Copy an equivalent cURL, JavaScript, Python, or local npm implementation after the result matches your workload.

POST /api/v1/count
No API key · 60 req/min
Ready. This HTTP test sends the payload to the edge API.
Response
{
  "object": "token_measurement",
  "status": "Run the request to see a live response."
}
01

Composable inputs

Combine raw text, chat messages, extracted documents, source files, and multiple image dimensions without flattening the response into one opaque number.

02

Selective telemetry

Request only usage, per-part breakdown, cost, context, method, or pricing fields. Caller metadata is echoed for correlation.

03

Batch + compare

Measure up to 25 independent requests in one batch or evaluate one workload across up to ten models with normalized output.

04

Operational contracts

Version headers, request IDs, RFC 9457 error objects, CORS, explicit size limits, and OpenAPI 3.1 make integration behavior inspectable.

Choose the right trust boundary

“Free API” and “browser-local” are not the same promise.

The HTTP service processes request content at the Cloudflare edge and does not intentionally store request bodies in application storage. Infrastructure-level security and abuse metadata may still exist. Do not send secrets, regulated records, proprietary repositories, or private prompts to a public endpoint.

For sensitive inputs, use the browser calculator or @jay0073/tokencalculator-core. Those paths execute the tokenizer and pricing engine locally; supported files can be extracted in the browser without an upload.

Read the API reference → Download OpenAPI →
Plain answers

Frequently asked questions

Is the TokenCalculator developer API free?+

Yes. The public v1 API requires no key and currently permits 60 requests per minute per route and Cloudflare edge location. Limits may evolve to protect the shared service.

Does the public API keep my prompt private in my browser?+

No. An HTTP API must receive the submitted payload to process it. TokenCalculator.dev does not intentionally persist request bodies, but confidential content should use the browser calculator or local npm package so it remains on-device.

Can the API count PDF, DOCX, and source files?+

The HTTP API accepts source code and already-extracted file text. The browser app performs PDF and DOCX extraction locally. This avoids uploading binary confidential documents to the public endpoint.

Can I compare the same payload across models?+

Yes. POST /api/v1/compare accepts one request body and up to ten model IDs, returning a normalized measurement for each model.