resources/x402-tools/772c994cc1e63ed8bd47651d
POSTorigin reachablediscovery only

x402-tools: POST /count-tokens

Count the number of tokens a string uses for an LLM, using the same BPE encodings the major models use (o200k_base for GPT-4o/o1, cl100k_base for GPT-4/3.5 and embeddings). Optionally pass a USD price per million tokens to get an estimated cost. Lets an agent budget context and spend before a call.

https://x402.nichospt.net/count-tokens
USE THIS RESOURCE

Start with a quote-only recipe. Payment signing stays in your project.

CODE
AI CODING TOOLS
quote-check.ts
const response = await fetch("https://x402.nichospt.net/count-tokens", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
  "type": "http",
  "method": "POST",
  "bodyType": "json",
  "bodyFieldNames": [
    "encoding",
    "price_per_1m",
    "text"
  ],
  "pathParamNames": [],
  "queryParamNames": []
}),
});

console.log(response.status);
console.log(Object.fromEntries(response.headers));
console.log((await response.text()).slice(0, 1000));

// A valid 402 is a quote, not a completed paid call.

Review the provider input schema before running this non-read-only method. No payment code is included.

STATUS HISTORY

  1. Exact route checked

    not safely testable · potentially-mutating-method:POST

  2. Origin reachable

    HEAD https://x402.nichospt.net/ returned 200.

  3. Observed in cdp-bazaar

    The registry record was observed and retained with provenance.

EVIDENCE

cdp-bazaarobserved 2026-07-10 · https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources
origin checkHEAD https://x402.nichospt.net/ → 200 on 2026-07-10
route quotenot invoked automatically · potentially-mutating-method:POST · 2026-07-10

Each record has an exact-route quote outcome. Unresolved templates and potentially mutating methods are labeled instead of being invoked without provider-specific test input. A quote is still separate from a settled paid call.

PAYMENT OPTIONS

solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpexact10000 atomic · EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
eip155:8453exact10000 atomic · 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
eip155:137exact10000 atomic · 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359
x402-tools: POST /count-tokens · TOLL·402