{"uid":"cap_tb_are7R3U_FvIH6Inz0B","slug":"newbotlabor-token-counter-6598f9d1","name":"NewBotLabor Token Counter","description":"Pay-per-call utilities for autonomous agents, paid with x402 (USDC on Base; no account, no API key).","url":"https://newbotlabor--254ecdfcc2de11f19b541607ee4eb77e.web.val.run/api/text/tokens?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","description":"one text (or use texts)"},"texts":{"type":"array","items":{"type":"string"},"maxItems":100,"description":"1-100 texts, per-item and total counts"},"encoding":{"enum":["both","o200k_base","cl100k_base"],"type":"string","description":"default both"},"maxTokens":{"type":"integer","maximum":2000000,"minimum":1,"description":"budget, checked against the exact BPE count of truncateWith (not approxTokens); for texts[] it applies to the total. Returns fits/overBy/counted/basis, and truncated text for a single text"},"truncateWith":{"enum":["o200k_base","cl100k_base"],"type":"string","description":"encoding used for the budget (default first requested)"}}},"responseSchema":{"type":"json","example":{"bytes":47,"chars":39,"words":9,"budget":{"fits":false,"overBy":9,"encoding":"o200k_base","maxTokens":8,"truncated":{"text":"Pay 0.002 USDC per","chars":18,"tokens":8}},"tokens":{"o200k_base":17,"cl100k_base":20},"encodings":["o200k_base","cl100k_base"],"approxTokens":10}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Xzu-nF30hzC9d395mjsgM","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Counts BPE tokens for one or more texts using OpenAI encodings (o200k_base and/or cl100k_base), with optional budget checking and truncation.","exampleAgentPrompt":"Count the tokens in this text using both o200k_base and cl100k_base encodings, and check whether it fits within a budget of 500 tokens: 'Large language models require careful prompt design to stay within context window limits.'","exampleUseCases":[{"title":"Pre-flight prompt token check","prompt":"Before I send this system prompt to GPT-4o, can you count how many tokens it uses with o200k_base and tell me if it fits within a 4096-token budget? Here's the prompt: 'You are a helpful assistant. Always respond in JSON. Be concise and accurate.'"},{"title":"Batch token counting for a dataset","prompt":"I have a list of 50 product descriptions and I need to know the total token count across all of them using cl100k_base — can you count them all and give me a grand total?"},{"title":"Truncate text to fit context window","prompt":"Truncate this article to fit within 1000 tokens using o200k_base and give me the shortened text: 'Artificial intelligence is transforming industries worldwide. From healthcare to finance, machine learning models are being deployed at scale to automate decisions, detect patterns, and generate content at speeds no human team could match...'"}],"resultDescription":"Returns a JSON object with byte count, character count, word count, token counts per requested encoding, approximate token count, and if a budget was specified: whether the text fits, how many tokens it's over by, which encoding was used for the budget check, and the truncated text with its own character and token count.","failureModes":["Text array exceeds 100 items — request rejected","maxTokens exceeds 2,000,000 — request rejected","Invalid encoding value — returns error","Empty text or texts field — may return zero counts","Payment not included or insufficient — 402 response requiring x402 USDC payment on Base"],"whenToPreferThis":"Use this endpoint when an agent needs accurate BPE token counts (not approximations) before making LLM API calls, enforcing context window budgets, or truncating text to fit limits — especially when no local tiktoken library is available. It supports both GPT-4o (o200k_base) and GPT-3.5/4 (cl100k_base) encodings, handles batches of up to 100 texts, and requires no API key, only a $0.002 USDC micropayment per call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-22T12:40:58.776Z","isFirstParty":false,"canonicalSlug":"newbotlabor-token-counter-6598f9d1"}