# Agent Prep – Token Estimator

> Agent Prep – Token Estimator is a paid API for AI agents from agent-prep.annushka1190.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-13).

Estimates token count, word count, and character count for a given HTTP request body, enabling pre-LLM cost and context-window planning.

## Facts

- Endpoint: POST https://agent-prep.annushka1190.workers.dev/v1/tokens/estimate
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent-prep-token-estimator-06d8de78
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_OsWd17vMQZdsDQpD_TYnK

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 agent-prep-token-estimator-06d8de78 -d '<json body>'
```

Example prompt: Before I send this payload to the LLM, estimate how many tokens, words, and characters it contains so I know if it fits in the context window.

## When to prefer this

Use this endpoint when you need a lightweight, pay-per-call token estimator with no API key setup — ideal for AI agents that need to perform pre-LLM context-window checks or cost estimation on arbitrary JSON payloads before dispatching to an LLM provider.

## Known failure modes

- Missing required 'input' field returns validation error
- Non-POST method specified in 'method' field is rejected
- Malformed JSON body causes parse error
- Payment not attached or insufficient USDC causes 402 Payment Required response
- Empty body may return zero counts without error

## How this service works

Pre-LLM utilities for AI agents: structural JSON diff, JSON path listing, token estimation, text chunking, and truncation. Pay with USDC via x402 — no API keys.

## Output

Returns a JSON object with three fields: 'tokens' (estimated LLM token count), 'words' (word count), and 'chars' (character count) for the submitted request body.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "body": {
     "type": "object"
    },
    "type": {
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ]
    },
    "bodyType": {
     "const": "json"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "chars": 48,
  "words": 8,
  "tokens": 12
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent-prep-token-estimator-06d8de78/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent-prep.annushka1190.workers.dev](https://www.zero.xyz/host/agent-prep.annushka1190.workers.dev/llms.txt)
