# PennyRail OpenAI Token Counter

> PennyRail OpenAI 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 OpenAI tokens in a given text input using OpenAI-compatible tokenization

## Facts

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

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-openai-token-counter-042de6cc -d '<json body>'
```

Example prompt: How many OpenAI tokens is this text: 'The quick brown fox jumps over the lazy dog and then runs away into the forest'?

## When to prefer this

Choose this endpoint when you need a fast, pay-per-use token count against OpenAI's tokenization scheme (tiktoken) without spinning up a local library. Ideal for agents that need to check prompt length, estimate costs, or plan chunking strategies on the fly, especially in serverless or constrained environments where installing tiktoken is not practical.

## Known failure modes

- Missing or malformed 'input' object returns a validation error
- Empty text input may return zero tokens or an error
- Payment not settled via x402 protocol results in 402 Payment Required
- Extremely large inputs may exceed processing limits
- Network timeout for unusually long text bodies

## How this service works

Machine-readable settlement service

## Output

Returns a JSON object containing the token count for the submitted text, computed using OpenAI-compatible tokenization (tiktoken). The response indicates how many tokens the input consumes when processed by OpenAI language models.

## 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-openai-token-counter-042de6cc/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)
