# Token Counter & LLM Cost Estimator

> Token Counter & LLM Cost Estimator is a paid API for AI agents from bess-x402.onrender.com, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-29).

Counts tokens in a text and estimates the cost of an LLM call (input + expected output tokens) across popular models, including context window fit checks.

## Facts

- Endpoint: GET https://bess-x402.onrender.com/v1/ai/token-cost?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/token-counter-llm-cost-estimator-187da9c0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_yxGlr_FRw-phNiYY7K2Io

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 token-counter-llm-cost-estimator-187da9c0
```

Example prompt: How many tokens is this text and what would it cost to run it on GPT-4o and Claude 3.5 Sonnet with about 500 output tokens: 'You are a helpful assistant. The user has asked you to summarize the following document...'?

## When to prefer this

Choose this endpoint when you need to programmatically estimate LLM API costs before making calls, validate that a prompt fits within a model's context window, or compare pricing across multiple LLMs for a given workload. It is ideal for cost-aware agent pipelines, budget planning for LLM-powered applications, and dynamic model selection based on price or context constraints.

## Known failure modes

- Missing required 'text' query parameter returns an error
- Invalid model ID or prefix returns an error or skips that model
- Very long texts may exceed processing limits
- output_tokens not provided defaults to a preset value which may not reflect actual usage
- Model pricing data may be stale if LLM providers update their rates

## How this service works

Count a text's tokens and estimate the cost of one call on popular LLMs (or the models you list), input plus an expected number of output tokens, and whether it fits each context window.

## Output

Returns the token count for the input text, then for each requested model (or a default set of popular models): the estimated cost in USD for the input tokens, the estimated cost for the expected output tokens, the total estimated cost per call, and whether the combined token count fits within that model's context window.

## 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": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "text"
     ],
     "properties": {
      "text": {
       "type": "string",
       "description": "Prompt text"
      },
      "models": {
       "type": "string",
       "description": "Comma-separated model ids or prefixes, e.g. openai/gpt,anthropic/claude"
      },
      "output_tokens": {
       "type": "integer",
       "description": "Expected output tokens"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/token-counter-llm-cost-estimator-187da9c0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from bess-x402.onrender.com](https://www.zero.xyz/host/bess-x402.onrender.com/llms.txt)
