Skip to content
Fourohtwo

agent402.tools/api/token-count

Count exact LLM tokens for a string using the real OpenAI BPE (o200k_base for gpt-4o/o-series, cl100k_base for gpt-4/gpt-3.5). Deterministic, offline - budget context windows without calling a model.

SolanaBaseUnchecked
POSThttps://agent402.tools/api/token-count

UptimeNot checked yet

30 days agoToday

Try it

Pays from your browser wallet in USDC on Base or USDG on Robinhood Chain, whichever the endpoint takes. The provider is paid directly; failed calls aren't refunded by Fourohtwo.

The response shows up here.

Call it from an agent

import { createPayer } from "fourohtwo";

// One agent key pays USDC on Base or USDG on Robinhood Chain,
// inside the spending rules you set on Fourohtwo.
const pay = createPayer({ privateKey: process.env.AGENT_KEY });
const res = await pay("https://agent402.tools/api/token-count", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"text":"hello world","model":"gpt-4o"}),
});
console.log(await res.json());

Example input

{
  "text": "hello world",
  "model": "gpt-4o"
}