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/countCount 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.
Best for demos, CI checks, server integrations, and non-sensitive workloads. Supports single, batch, and multi-model requests.
POST /api/v1/countBest for enterprise prompts, repositories, and confidential extracted documents. The same measurement core runs inside your process.
npm i @jay0073/tokencalculator-coreThe playground calls the public endpoint. Copy an equivalent cURL, JavaScript, Python, or local npm implementation after the result matches your workload.
{
"object": "token_measurement",
"status": "Run the request to see a live response."
}Combine raw text, chat messages, extracted documents, source files, and multiple image dimensions without flattening the response into one opaque number.
Request only usage, per-part breakdown, cost, context, method, or pricing fields. Caller metadata is echoed for correlation.
Measure up to 25 independent requests in one batch or evaluate one workload across up to ten models with normalized output.
Version headers, request IDs, RFC 9457 error objects, CORS, explicit size limits, and OpenAPI 3.1 make integration behavior inspectable.
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.
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.
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.
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.
Yes. POST /api/v1/compare accepts one request body and up to ten model IDs, returning a normalized measurement for each model.