# PennyRail BPE Token Counter

> PennyRail BPE 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 BPE (Byte Pair Encoding) tokens in a given text string using a tokenizer-compatible method

## Facts

- Endpoint: POST https://pennyrail.vercel.app/api/p/nano/text.token-count--bpe-token-count
- 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-bpe-token-counter-3940b40a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_G5RfXKhu1dYumxceoEVB5

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-bpe-token-counter-3940b40a -d '<json body>'
```

Example prompt: How many BPE tokens is this text? 'The quick brown fox jumps over the lazy dog near the riverbank at dusk.' I need to know before sending it to an LLM.

## When to prefer this

Use this endpoint when you need fast, programmatic BPE token counts for LLM prompt management, context-window enforcement, or cost estimation — especially inside autonomous agent pipelines that require metered, pay-per-call access via x402 USDC micropayments without managing API keys.

## Known failure modes

- Missing or malformed 'input' object returns a validation error
- Empty or null text field may return zero or an error
- Payment failure (402) if USDC balance is insufficient
- Ambiguous tokenizer type (BPE variant not specified) may produce unexpected counts
- Very large inputs may time out or be rejected

## How this service works

Machine-readable settlement service

## Output

Returns a token count (integer) representing how many BPE tokens the input text encodes to, enabling callers to measure prompt length, enforce context window limits, or estimate LLM API costs.

## 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-bpe-token-counter-3940b40a/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)
