API · x402

Estimate the LLM token count of text with a low to high range, a breakdown by words, nu…

Estimate the LLM token count of text with a low to high range, a breakdown by words, numbers, symbols and CJK, and whether it fits a given context window

by Saylor Innovations Knowledge Base · verified provider · updated 2026-10-26

What it does

Estimate the LLM token count of text with a low to high range, a breakdown by words, numbers, symbols and CJK, and whether it fits a given context window

Tags: how many tokens is this text · estimate llm token count · will this prompt fit · token budget for a document · count tokens in code or prose

Use with an agent

  1. Discover. Agents find this listing with GET https://bazaar.saylorinnovations.com/discovery/search?query=…, the MCP tool search_resources, or /discovery/resources.
  2. Inspect. Fetch /resources/saylorinnovations-api-text-token-estimate.json for the price and payment options.
  3. Pay. Call GET https://saylorinnovations.com/api/text/token-estimate. The provider answers 402 with its payment requirements. An x402 client signs one of the options below and retries with PAYMENT-SIGNATURE.
  4. Execute. The provider returns 200 with the data. Agent Bazaar is not in the request path and never sees your payment.

For humans

You don't need an account or an API key; you need a wallet holding a small amount of USDC or USDT or SOL on Base, Polygon, Arbitrum One, Solana, and an x402-capable client (see the examples below). Call the endpoint unpaid first to see exactly what it asks for.

Pricing & payment

Price
$0.01 / request
Protocol
x402 v2
Auth
No account or API key. Pay per request.
Networks
Base, Polygon, Arbitrum One, Solana

x402 payment requirements

SchemeNetworkAssetAmountPay toTimeout
exactBase
eip155:8453
USDC$0.010xA2A8dF0f7CaaBEa4e120a2568118f141569fc8aa120s
exactPolygon
eip155:137
USDC$0.010xA2A8dF0f7CaaBEa4e120a2568118f141569fc8aa120s
exactArbitrum One
eip155:42161
USDC$0.010xA2A8dF0f7CaaBEa4e120a2568118f141569fc8aa120s
exactSolana
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
USDC$0.017LSjfrJf8fNsB8VA9u7N3WEn25smQLpob3SvyUvXacy7120s
exactSolana
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
USDT$0.017LSjfrJf8fNsB8VA9u7N3WEn25smQLpob3SvyUvXacy7120s
exactSolana
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
SOL$0.017LSjfrJf8fNsB8VA9u7N3WEn25smQLpob3SvyUvXacy7120s
accepts[] (raw JSON)
[
  {
    "scheme": "exact",
    "network": "eip155:8453",
    "payTo": "0xA2A8dF0f7CaaBEa4e120a2568118f141569fc8aa",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "amount": "10000",
    "amountUsd": 0.01,
    "maxTimeoutSeconds": 120
  },
  {
    "scheme": "exact",
    "network": "eip155:137",
    "payTo": "0xA2A8dF0f7CaaBEa4e120a2568118f141569fc8aa",
    "asset": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
    "amount": "10000",
    "amountUsd": 0.01,
    "maxTimeoutSeconds": 120
  },
  {
    "scheme": "exact",
    "network": "eip155:42161",
    "payTo": "0xA2A8dF0f7CaaBEa4e120a2568118f141569fc8aa",
    "asset": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    "amount": "10000",
    "amountUsd": 0.01,
    "maxTimeoutSeconds": 120
  },
  {
    "scheme": "exact",
    "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
    "payTo": "7LSjfrJf8fNsB8VA9u7N3WEn25smQLpob3SvyUvXacy7",
    "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "10000",
    "amountUsd": 0.01,
    "maxTimeoutSeconds": 120
  },
  {
    "scheme": "exact",
    "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
    "payTo": "7LSjfrJf8fNsB8VA9u7N3WEn25smQLpob3SvyUvXacy7",
    "asset": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
    "amount": "10000",
    "amountUsd": 0.01,
    "maxTimeoutSeconds": 120
  },
  {
    "scheme": "exact",
    "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
    "payTo": "7LSjfrJf8fNsB8VA9u7N3WEn25smQLpob3SvyUvXacy7",
    "asset": "So11111111111111111111111111111111111111112",
    "amount": "95830",
    "amountUsd": 0.01,
    "maxTimeoutSeconds": 120
  }
]

Schemas

Output schema (JSON Schema)
{
  "type": "object",
  "properties": {
    "characters": {
      "type": "number",
      "description": "Characters in the text"
    },
    "words": {
      "type": "number",
      "description": "Words"
    },
    "estimated_tokens": {
      "type": "number",
      "description": "Estimated tokens"
    },
    "range": {
      "type": "object",
      "description": "Range covered by the data"
    },
    "chars_per_token": {
      "type": "number",
      "description": "Chars per token"
    },
    "breakdown": {
      "type": "object",
      "description": "Estimated tokens by source: words, numbers, symbols, plus CJK characters, emoji and newlines counted",
      "properties": {
        "emoji": {
          "description": "Emoji counted",
          "type": [
            "number",
            "null"
          ]
        },
        "newlines": {
          "description": "Newlines counted",
          "type": [
            "number",
            "null"
          ]
        },
        "word_tokens": {
          "type": [
            "number",
            "null"
          ],
          "description": "Word tokens"
        },
        "number_tokens": {
          "type": [
            "number",
            "null"
          ],
          "description": "Number tokens"
        },
        "symbol_tokens": {
          "type": [
            "number",
            "null"
          ],
          "description": "Symbol tokens"
        },
        "cjk_characters": {
          "type": [
            "number",
            "null"
          ],
          "description": "Cjk characters"
        }
      }
    },
    "looks_like_code": {
      "type": "boolean",
      "description": "Looks like code"
    },
    "fits_context": {
      "type": [
        "object",
        "null"
      ],
      "description": "Fits context"
    },
    "note": {
      "type": "string",
      "description": "Caveat or context for reading the result"
    },
    "source": {
      "type": "string",
      "description": "Data source the values come from"
    }
  },
  "required": [
    "estimated_tokens",
    "range"
  ]
}
Example shape — generated from the schema, not a captured live response
{
  "characters": 0,
  "words": 0,
  "estimated_tokens": 0,
  "range": {},
  "chars_per_token": 0,
  "breakdown": {
    "emoji": 0,
    "newlines": 0,
    "word_tokens": 0,
    "number_tokens": 0,
    "symbol_tokens": 0,
    "cjk_characters": 0
  },
  "looks_like_code": true,
  "fits_context": {},
  "note": "string",
  "source": "string"
}

Examples

curl
curl "https://saylorinnovations.com/api/text/token-estimate"
# -> 402 Payment Required, accepts[] lists how to pay
# retry with a PAYMENT-SIGNATURE (or PAYMENT header) once paid
JavaScript
const res = await fetch("https://saylorinnovations.com/api/text/token-estimate");
if (res.status === 402) {
  const { accepts } = await res.json();
  // pay one of accepts[] via an x402 client, then retry with the payment header
}
Python
import httpx
res = httpx.get("https://saylorinnovations.com/api/text/token-estimate")
if res.status_code == 402:
    accepts = res.json()["accepts"]
    # pay one of accepts[] via an x402 client, then retry with the payment header

Details

Provider
Saylor Innovations Knowledge Base
Endpoint
https://saylorinnovations.com/api/text/token-estimate
Side effects
Paid calls settle the advertised payment; see the provider contract for execution behavior.
Machine-readable
/resources/saylorinnovations-api-text-token-estimate.json