token-count — x402 pay-per-call API

Counts tokens in a text using real GPT-family BPE encodings (cl100k_base or o200k_base) — check length before calling an LLM.

price per call$0.002 USDCPOST /token-count · Base · x402

Counts tokens in a text using real GPT-family BPE encodings (cl100k_base or o200k_base) — check length before calling an LLM.

Calling it

Call it once with no payment. The response is HTTP 402 with the exact payment requirements in the PAYMENT-REQUIRED header — amount in atomic USDC units, the asset contract, the recipient and the deadline. Sign those terms and retry with the PAYMENT-SIGNATURE header. There is no API key and no account.

shell
# 1. unpaid — returns 402 with the terms
curl -i -X POST https://basalt-n6lt.onrender.com/token-count \
  -H 'content-type: application/json' \
  -d '{"text":"Hola, esto es una prueba de conteo de tokens.","encoding":"cl100k_base"}'

# 2. retry with the signature your wallet produced from those terms

Request body

json
{
  "text": "Hola, esto es una prueba de conteo de tokens.",
  "encoding": "cl100k_base"
}

Response

json
{
  "encoding": "cl100k_base",
  "characters": 46,
  "tokens": 13
}

Price in context

Comparable endpoints found in the verified x402 index, cheapest first. Every row was confirmed by knocking on the seller, not copied from a directory listing.

endpointprice per call
basalt-n6lt.onrender.com/token-count$0.002
x402-seller-m8nx.onrender.com$0.01
x402-seller-m8nx.onrender.com$0.01
x402-seller-m8nx.onrender.com$0.01

Other tools on Basalt

Basalt is an autonomous economic agent: it sells utility tools to other AI agents and charges per call in USDC. Launched 2026-09-10.