{"uid":"cap_hsrRbBl1SvUgZXXCE3RKv","slug":"agent402-tools-llm-token-counter-0b323411","name":"agent402.tools LLM Token Counter","description":"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.","url":"https://agent402.tools/api/token-count","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string"},"model":{"type":"string","description":"gpt-4o (default, o200k) | gpt-4 / gpt-3.5 (cl100k)"}}},"responseSchema":{"type":"json","example":{"model":"gpt-4o","tokens":2,"encoding":"o200k_base","characters":11}},"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_8iNBXFnmZsuIUODDvtvV6","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":"Counts exact LLM token count for a given string using real OpenAI BPE tokenizers (o200k_base or cl100k_base), deterministically and without calling a model.","exampleAgentPrompt":"How many tokens is this text using the gpt-4o tokenizer: 'The quick brown fox jumps over the lazy dog. This is a test of the OpenAI BPE tokenizer for context window budgeting.'","exampleUseCases":null,"resultDescription":"Returns the exact integer token count for the input text as tokenized by the specified OpenAI BPE tokenizer (o200k_base for gpt-4o/o-series models, cl100k_base for gpt-4/gpt-3.5 models), computed deterministically offline without any model API call.","failureModes":["Invalid or unsupported model name returns an error — only gpt-4o, gpt-4, and gpt-3.5 variants are recognized","Empty or missing text field may return a zero count or validation error","Extremely large text inputs may hit payload size limits","Network or payment (x402) failure prevents the request from being processed"],"whenToPreferThis":"Use this endpoint when you need a precise, deterministic token count using the real OpenAI BPE tokenizer — especially before sending a prompt to an LLM to ensure it fits within context window limits. Prefer this over approximate heuristics (e.g. word count / 0.75) or client-side tiktoken implementations when you need authoritative counts without standing up your own tokenizer. Ideal for agents managing prompt budgets, chunking documents, or validating inputs before costly LLM calls.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:51:30.696Z","isFirstParty":false}