# x402node Token Counter

> x402node Token Counter is a paid API for AI agents from api.x402node.dev, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-14).

Returns exact BPE token counts for GPT-4o/GPT-4/GPT-3.5 and estimates for Claude and Llama, for LLM context budgeting and cost estimation before making an API call.

## Facts

- Endpoint: POST https://api.x402node.dev/ai/token-count
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402node-token-counter-63d9208c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_yWoMWOrPn0WWJAxapQKl9

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 x402node-token-counter-63d9208c -d '<json body>'
```

Example prompt: How many tokens would this system prompt use for GPT-4o: 'You are a helpful assistant. Always respond concisely and cite your sources when making factual claims.' — and give me the Claude estimate too so I can plan my API budget.

## When to prefer this

Use this endpoint when you need to pre-flight check whether a prompt or document will fit within an LLM's context window, or when you want to estimate API costs across multiple model families (OpenAI, Anthropic, Meta) before committing to a call. Prefer this over building your own tiktoken integration when working in environments without native library support.

## Known failure modes

- Empty or missing text body returns a 400 validation error
- Unsupported model name may fall back to heuristic estimate or error
- Very long inputs may time out or exceed payload limits
- Malformed JSON request body returns a parse error

## How this service works

Exact BPE token count for GPT-4o, GPT-4 and GPT-3.5 plus Claude and Llama estimates, for budgeting LLM context and cost before an API call. token count, tokenizer, count tokens, context length, llm cost estimate, tiktoken

## Output

Returns exact BPE token counts for GPT-4o, GPT-4, and GPT-3.5 models, plus heuristic estimates for Claude and Llama models, allowing the caller to budget context window usage and estimate API costs before making an LLM call.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "text": {
   "type": "string",
   "description": "Text to tokenize (required, max 200KB)"
  },
  "model": {
   "type": "string",
   "description": "Model: gpt-4o (default), gpt-4, gpt-3.5"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402node-token-counter-63d9208c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.x402node.dev](https://www.zero.xyz/host/api.x402node.dev/llms.txt)
