$ man token-count
/token-count
PRICE / CALL
$0.001
USDC · base mainnet · scheme: exact
METHOD
POST
CLUSTER
wordmintCATEGORY
uncategorized
STATUS
● live
NAME
token-count — token count / tokenizer estimate / gpt-4 token count / claude token count / gemini token count / context-window pre-flight
SYNOPSIS
POST https://x402.agentutility.ai/token-count
Content-Type: application/json
X-PAYMENT: <signed-transferWithAuthorization>
{ ... }↳ first call →
402 Payment Required. Sign USDCtransferWithAuthorization, retry with theX-PAYMENT header.DESCRIPTION
Token count / tokenizer estimate / GPT-4 token count / Claude token count / Gemini token count / context-window pre-flight. Pure-local heuristic estimator targeting cl100k_base / o200k_base (GPT-4o) with calibrated multipliers for Claude and Gemini. Input model name is matched against an internal table of supported tokenizers. Accuracy ±5% versus tiktoken on typical English. No upstream call.
INPUT — request schema
| property | type | description | req? |
|---|---|---|---|
| text | string | Text to count. Up to 1,000,000 chars. | required |
| model | string | Target model. Examples: 'gpt-4o' (default), 'claude-sonnet-4-5', 'gemini-2-pro'. Free-form; matched against an internal multiplier table. | optional |
OUTPUT — response shape
| field | type | description |
|---|---|---|
| text_chars | string | Character count of the input text that was tokenized. |
| model | string | Model name supplied in the request (e.g. gpt-4o, claude-3-5-sonnet, gemini-1.5-pro). |
| matched_tokenizer | string | Internal tokenizer family matched to the model (e.g. cl100k_base, o200k_base, claude-approx, gemini-approx). |
| estimated_tokens | string | Estimated token count for the input text under the matched tokenizer. |
| accuracy_note | string | Expected accuracy band versus the official tokenizer, typically within plus or minus 5% on English prose. |
| source | string | Origin of the estimate; always local-heuristic since no upstream tokenizer API is called. |
EXAMPLES — two ways to call
EXAMPLE 1 · curl
curl -X POST https://x402.agentutility.ai/token-count \
-H 'Content-Type: application/json' \
-d '{ }'first response =
402 Payment Required with payment requirements; sign + retry with X-PAYMENT.EXAMPLE 2 · mcp
# MCP packages on npm under # @agentutility/mcp-* (one per cluster) # # Catalog + install: # https://mcp.agentutility.ai # # Or call token-count directly over HTTP — see above.
MCP server handles payment automatically — your coding agent just calls the tool by name.
METADATA
- tags
- wordminttokenizertoken-countcontext-windowgpt-4claude-tokenstiktokencl100k
- methods
- POST
- cluster
- wordmint
- price
- $0.001 USDC per call
ADJACENT — other endpoints in wordmint
| endpoint | description | price |
|---|---|---|
| content-simhash | SimHash / 64-bit content fingerprint / near-duplicate detection / dedup hashing / locality-sensitive hash. | $0.001 |
| hash-string | String hasher / multi-algorithm digest / cache-key generator / content fingerprinter / SHA-256 / SHA-1 / SHA-384 / SHA-512 / MD5. | $0.001 |
| slugify | URL slug generator / slugifier / canonical-identifier maker / safe-string converter / SEO slug builder / filename slug / cache-key normal… | $0.001 |
| text-normalize | Text normalize. | $0.001 |
| type-inference-from-json | Type inference from JSON / JSON to TypeScript / JSON to Zod / JSON to JSON Schema / JSON shape inferer / quicktype-style type generator. | $0.001 |
| unicode-normalize | Unicode normalize / NFC NFD NFKC NFKD / homoglyph detection / IDN spoof / lookalike chars / invisible characters / zero-width / phishing… | $0.001 |
| cron-explain | Cron expression explainer / cron parser / scheduling translator. | $0.002 |
| cron-parse | Cron parser. | $0.002 |
SEE ALSO