{"uid":"cap_s-OgTdb9wMcSznRs8whQH","slug":"agentshelf-heuristic-token-counter-f685cb57","name":"Agentshelf Heuristic Token Counter","description":"Call when an agent needs a heuristic token count for text (not a model tokenizer). No LLM. Exact $0.001 USDC. Prefer unpaid POST /v1/sandbox/token-count first.","url":"https://agentshelf.syntexa.ch/v1/token-count?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","examples":["hello world"],"maxLength":100000,"minLength":1,"description":"Text to count. This is not a model tokenizer."},"method":{"enum":["chars4","words","regex"],"type":"string","examples":["words"],"description":"Count method: chars4 (ceil of characters/4), words (whitespace), or regex. Default chars4."}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_hCFiuR1nCGKdl2ft51zcx","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Estimates token count for text using heuristic methods (chars/4, word count, or regex) without invoking any LLM or tokenizer","exampleAgentPrompt":"Roughly how many tokens is this text using the chars4 heuristic: 'The quick brown fox jumps over the lazy dog and then sat down for a rest'?","exampleUseCases":[{"title":"Prompt length guard before LLM call","prompt":"Before I send this system prompt to GPT, estimate how many tokens it is using the chars4 method so I know if it fits in the context window."},{"title":"Word-based token estimate for document chunking","prompt":"I'm splitting a document into chunks — can you use the words heuristic to estimate the token count for each chunk's text so I can keep them under 512 tokens?"},{"title":"Regex-based token count for input validation","prompt":"Use the regex counting method to estimate how many tokens are in this user-submitted comment before I decide whether to accept it: 'I really loved the product, it changed my daily routine completely and I tell everyone about it.'"}],"resultDescription":"Returns a numeric token count estimate based on the selected heuristic method (chars4 divides character count by 4, words counts whitespace-delimited tokens, regex applies a pattern-based split). No LLM or external model is invoked.","failureModes":["Text exceeds 100,000 character limit — request rejected","Text field is empty or missing — validation error","Invalid method enum value supplied — request rejected","Payment of $0.001 USDC not completed — 402 Payment Required response"],"whenToPreferThis":"Choose this endpoint when you need a fast, cheap, model-agnostic token estimate without invoking an actual LLM tokenizer. Ideal for pre-flight checks before sending prompts to paid LLM APIs, or for lightweight agents that need rough token budgeting. Try the free POST /v1/sandbox/token-count endpoint first; only call this paid endpoint if the sandbox is unavailable or rate-limited.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-01T06:47:17.392Z","isFirstParty":false,"canonicalSlug":"agentshelf-heuristic-token-counter-f685cb57"}