# Token Count API

> Token Count API is a paid API for AI agents from compute-api-production-245d.up.railway.app, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-11).

Estimates the character count, word count, and token count for a given text string

## Facts

- Endpoint: POST https://compute-api-production-245d.up.railway.app/token-count?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/token-count-api-a7416037
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_R_Q_-9IJkaA6KQPZcfMdj

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability token-count-api-a7416037 -d '<json body>'
```

Example prompt: How many tokens, words, and characters are in this text: 'The quick brown fox jumps over the lazy dog. This is a sample sentence for estimation purposes.'?

## When to prefer this

Use this endpoint when you need a fast, cheap, model-agnostic token estimate without calling a full LLM API. Ideal for pre-flight checks before expensive LLM calls, document chunking logic, or validating that text fits within a context window. Prefer this over tiktoken or similar libraries when you need a hosted, pay-per-call service that integrates into an automated pipeline via x402 payments on Base.

## Known failure modes

- Missing required 'text' field returns a validation error
- Extremely long texts may time out or hit payload size limits
- Token estimate is model-independent and approximate — may differ slightly from model-specific tokenizers like tiktoken
- Payment failure via x402 prevents the call from being processed

## How this service works

Pure computation endpoints paid per call via x402 ($0.001 USDC on Base).

## Output

Returns a JSON object with three integer fields: chars (total character count), words (total word count), and tokens (estimated token count) for the submitted text. The token estimate is model-independent.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "text"
 ],
 "properties": {
  "text": {
   "type": "string"
  },
  "model": {
   "type": "string",
   "description": "Accepted for compatibility; the estimate is model-independent"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "chars": {
   "type": "integer"
  },
  "words": {
   "type": "integer"
  },
  "tokens": {
   "type": "integer"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/token-count-api-a7416037/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from compute-api-production-245d.up.railway.app](https://www.zero.xyz/host/compute-api-production-245d.up.railway.app/llms.txt)
