# OpenVerbs Token Counter

> OpenVerbs Token Counter is a paid API for AI agents from tokens.openverbs.com, paid per call via x402, $0.004/call, status unknown (last checked 2026-09-14).

Counts the exact number of LLM tokens in a given text string for a specified model or encoding, supporting OpenAI, Llama, Mistral, Qwen, Gemma, DeepSeek, Command-R, Claude, and Gemini.

## Facts

- Endpoint: POST https://tokens.openverbs.com/v1/count
- Price: $0.004/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/openverbs-token-counter-5d960306
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_BEX2blfKydIGhnJ-RwEyK

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 openverbs-token-counter-5d960306 -d '<json body>'
```

Example prompt: How many tokens is this text using the gpt-4o tokenizer: 'Large language models process text by breaking it into tokens, and understanding token counts is essential for managing API costs and context window limits.'

## When to prefer this

Choose this endpoint when you need accurate, model-specific token counts before making LLM API calls — especially for cost estimation, context window validation, or prompt engineering. It supports the widest range of model families (OpenAI, Llama, Mistral, Qwen, Gemma, DeepSeek, Command-R, Claude, Gemini) in a single API, making it preferable to rolling your own tiktoken/sentencepiece integration or using model-provider estimations that may be inaccurate.

## Known failure modes

- Text exceeds 100,000 character limit — returns validation error
- Unknown or unsupported model name — falls back to default gpt-4o tokenizer or returns error
- Empty string input — returns 0 tokens successfully
- Invalid encoding enum value — returns schema validation error
- Payment failure via x402 protocol — returns 402 Payment Required before processing

## How this service works

Count the LLM tokens in text for a given model or encoding — exact for OpenAI and open models (Llama, Mistral, Qwen, Gemma, DeepSeek, Command-R); labelled-approximate for Claude & Gemini.

## Output

Returns the integer token count for the provided text under the specified model or encoding, along with the resolved tokenizer/encoding name. For OpenAI models and open-source models (Llama, Mistral, Qwen, Gemma, DeepSeek, Command-R), counts are exact; for Claude and Gemini, counts are labelled as approximate.

## Request schema (JSON Schema)

```json
{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "type": "object",
 "properties": {
  "input": {
   "type": "object",
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "type": "string",
     "enum": [
      "POST"
     ]
    },
    "bodyType": {
     "type": "string",
     "enum": [
      "json",
      "form-data",
      "text"
     ]
    },
    "body": {
     "type": "object",
     "properties": {
      "text": {
       "type": "string",
       "maxLength": 100000,
       "description": "The text to tokenize. Empty string counts as 0 tokens."
      },
      "model": {
       "type": "string",
       "minLength": 1,
       "maxLength": 100,
       "description": "LLM model name, e.g. \"gpt-4o\", \"llama-3.1-70b\", \"claude-3-5-sonnet\". Resolved to its tokenizer. Defaults to gpt-4o. Supported families: o200k_base, cl100k_base, p50k_base, r50k_base, llama3, llama2, mistral, qwen, gemma, deepseek, command-r, claude, gemini."
      },
      "encoding": {
       "type": "string",
       "enum": [
        "o200k_base",
        "cl100k_base",
        "p50k_base",
        "r50k_base"
       ],
       "description": "Explicit OpenAI BPE encoding. Overrides \"model\" and is always exact. Defaults to o200k_base."
      }
     },
     "required": [
      "text"
     ],
     "additionalProperties": false
    }
   },
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "additionalProperties": false
  }
 },
 "required": [
  "input"
 ]
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/openverbs-token-counter-5d960306/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from tokens.openverbs.com](https://www.zero.xyz/host/tokens.openverbs.com/llms.txt)
