# NewBotLabor Token Counter

> NewBotLabor Token Counter is a paid API for AI agents from newbotlabor--254ecdfcc2de11f19b541607ee4eb77e.web.val.run, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-22).

Counts BPE tokens for one or more texts using OpenAI encodings (o200k_base and/or cl100k_base), with optional budget checking and truncation.

## Facts

- Endpoint: POST https://newbotlabor--254ecdfcc2de11f19b541607ee4eb77e.web.val.run/api/text/tokens?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-22
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/newbotlabor-token-counter-6598f9d1
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_tb_are7R3U_FvIH6Inz0B

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 newbotlabor-token-counter-6598f9d1 -d '<json body>'
```

Example prompt: Count the tokens in this text using both o200k_base and cl100k_base encodings, and check whether it fits within a budget of 500 tokens: 'Large language models require careful prompt design to stay within context window limits.'

## When to prefer this

Use this endpoint when an agent needs accurate BPE token counts (not approximations) before making LLM API calls, enforcing context window budgets, or truncating text to fit limits — especially when no local tiktoken library is available. It supports both GPT-4o (o200k_base) and GPT-3.5/4 (cl100k_base) encodings, handles batches of up to 100 texts, and requires no API key, only a $0.002 USDC micropayment per call.

## Known failure modes

- Text array exceeds 100 items — request rejected
- maxTokens exceeds 2,000,000 — request rejected
- Invalid encoding value — returns error
- Empty text or texts field — may return zero counts
- Payment not included or insufficient — 402 response requiring x402 USDC payment on Base

## How this service works

Pay-per-call utilities for autonomous agents, paid with x402 (USDC on Base; no account, no API key).

## Output

Returns a JSON object with byte count, character count, word count, token counts per requested encoding, approximate token count, and if a budget was specified: whether the text fits, how many tokens it's over by, which encoding was used for the budget check, and the truncated text with its own character and token count.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "text": {
   "type": "string",
   "description": "one text (or use texts)"
  },
  "texts": {
   "type": "array",
   "items": {
    "type": "string"
   },
   "maxItems": 100,
   "description": "1-100 texts, per-item and total counts"
  },
  "encoding": {
   "enum": [
    "both",
    "o200k_base",
    "cl100k_base"
   ],
   "type": "string",
   "description": "default both"
  },
  "maxTokens": {
   "type": "integer",
   "maximum": 2000000,
   "minimum": 1,
   "description": "budget, checked against the exact BPE count of truncateWith (not approxTokens); for texts[] it applies to the total. Returns fits/overBy/counted/basis, and truncated text for a single text"
  },
  "truncateWith": {
   "enum": [
    "o200k_base",
    "cl100k_base"
   ],
   "type": "string",
   "description": "encoding used for the budget (default first requested)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "bytes": 47,
  "chars": 39,
  "words": 9,
  "budget": {
   "fits": false,
   "overBy": 9,
   "encoding": "o200k_base",
   "maxTokens": 8,
   "truncated": {
    "text": "Pay 0.002 USDC per",
    "chars": 18,
    "tokens": 8
   }
  },
  "tokens": {
   "o200k_base": 17,
   "cl100k_base": 20
  },
  "encodings": [
   "o200k_base",
   "cl100k_base"
  ],
  "approxTokens": 10
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/newbotlabor-token-counter-6598f9d1/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from newbotlabor--254ecdfcc2de11f19b541607ee4eb77e.web.val.run](https://www.zero.xyz/host/newbotlabor--254ecdfcc2de11f19b541607ee4eb77e.web.val.run/llms.txt)
