# PennyRail Token Counter

> PennyRail Token Counter is a paid API for AI agents from pennyrail.vercel.app, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Counts the number of tokens in a given text input using a nano-scale paid API endpoint

## Facts

- Endpoint: POST https://pennyrail.vercel.app/api/p/nano/text.token-count--count-tokens
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/pennyrail-token-counter-46495bad
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_pIhgZqgA3M_C2K-Z9OjK_

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 pennyrail-token-counter-46495bad -d '<json body>'
```

Example prompt: How many tokens is this text: 'The quick brown fox jumps over the lazy dog. Large language models process text as tokens rather than raw characters.'?

## When to prefer this

Choose this endpoint when you need a lightweight, pay-per-use token counting service without spinning up a local tokenizer library. It is ideal for agent pipelines that need to verify token budgets before LLM calls, estimate costs, or enforce input size limits, especially when running in serverless or constrained environments where installing tokenizer dependencies is impractical.

## Known failure modes

- Missing 'input' field in request body returns validation error
- Empty or null text may return zero or an error
- Malformed JSON body causes parse failure
- Payment not included or insufficient USDC triggers 402 response
- Rate limiting or service unavailability returns 5xx error

## How this service works

Machine-readable settlement service

## Output

Returns a count of tokens present in the submitted text, likely as a numeric value or object containing the count and possibly token-level breakdown details.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "additionalProperties": true
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/pennyrail-token-counter-46495bad/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from pennyrail.vercel.app](https://www.zero.xyz/host/pennyrail.vercel.app/llms.txt)
