# x402 Utils — Token Counter

> x402 Utils — Token Counter is a paid API for AI agents from qcb7fnxsbd7fbhj4.68r.lambda-web.us-east-1.on.aws, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-29).

Counts tokens, characters, words, and lines in a text for OpenAI models (o200k_base for GPT-4o+, cl100k_base for GPT-4) to help size prompts and estimate LLM costs.

## Facts

- Endpoint: POST https://qcb7fnxsbd7fbhj4.68r.lambda-web.us-east-1.on.aws/v1/tokens?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-utils-token-counter-cc36111b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_8qinnhDR7_IpOmsPkPhp4

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 x402-utils-token-counter-cc36111b -d '<json body>'
```

Example prompt: Count the tokens in this text for both GPT-4o (o200k_base) and GPT-4 (cl100k_base): 'You are a helpful assistant. Please summarize the following article in three bullet points.'

## When to prefer this

Choose this endpoint when you need accurate OpenAI-compatible token counts (tiktoken-based) for GPT-4 or GPT-4o models, especially when you need both encodings in one call along with word and character counts. Ideal for prompt sizing, context-window validation, and cost estimation workflows before making LLM API calls.

## Known failure modes

- Text exceeds 1 MB limit — request rejected
- Invalid encoding name supplied — validation error returned
- Empty text field — may return zero counts or an error
- Network timeout on large inputs near the size limit
- Payment not included or insufficient — HTTP 402 response

## How this service works

Count the tokens of a text for OpenAI models (o200k_base for GPT-4o and later, cl100k_base for GPT-4), with characters, words and lines, to size prompts and estimate cost.

## Output

A JSON object with token counts for each requested encoding (e.g. {"o200k_base": 9, "cl100k_base": 9}), plus top-level word count and character count for the input text.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "text": {
   "type": "string",
   "description": "the text (up to 1 MB)"
  },
  "encodings": {
   "type": "array",
   "items": {
    "enum": [
     "o200k_base",
     "cl100k_base"
    ],
    "type": "string"
   },
   "description": "which encodings (default both)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "words": 6,
  "tokens": {
   "o200k_base": 9,
   "cl100k_base": 9
  },
  "characters": 30
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-utils-token-counter-cc36111b/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from qcb7fnxsbd7fbhj4.68r.lambda-web.us-east-1.on.aws](https://www.zero.xyz/host/qcb7fnxsbd7fbhj4.68r.lambda-web.us-east-1.on.aws/llms.txt)
