{"uid":"cap_AkRzT8eW39-eajaScYZyc","slug":"utilsforagents-com-44c1f37d","name":"Token Counter by utilsforagents.com","description":"Pay-per-call AI agent utilities plus a free feedback endpoint: JSON diff, EXIF extraction, metadata scrubbing, HTML-to-Markdown, URL fetching, and feature-request collection. $0.003/call for paid utility routes via x402 on Base or Solana.","url":"https://utilsforagents.com/v1/utilities/count-tokens?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","description":"Text to tokenize (max 50 MB)"},"encoding":{"enum":["cl100k_base","o200k_base","claude","gemini"],"type":"string","description":"Tokenizer encoding (default: cl100k_base)"},"content_type":{"enum":["text","image"],"type":"string","description":"Set to 'image' if text is a base64-encoded image (uses tile-based token estimation). Auto-detected for JPEG, PNG, and GIF base64 prefixes even if not set. Default: 'text'."}}},"responseSchema":{"type":"json","example":{"ok":true,"method":"exact","encoding":"cl100k_base","tokenCount":4,"utf8Sanitized":false,"characterCount":13,"processingTimeMs":1.23}},"example":{"request":{"text":"The quick brown fox jumps over the lazy dog. This is a test of the tokenizer utility.","encoding":"cl100k_base"},"response":{"ok":true,"method":"exact","encoding":"cl100k_base","tokenCount":19,"utf8Sanitized":false,"characterCount":85,"processingTimeMs":0}},"exampleRequest":{"text":"The quick brown fox jumps over the lazy dog. This is a test of the tokenizer utility.","encoding":"cl100k_base"},"tags":["x402"],"displayCostAmount":"0.003","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","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.003/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_W20WXzBbv679JAkGkEz_Z","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.003","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Counts the number of tokens in a text string using a specified LLM tokenizer encoding (GPT-4, GPT-4o, Claude, or Gemini)","exampleAgentPrompt":"How many tokens is this text using the cl100k_base encoding so I know if it fits in GPT-4's context window: 'The quick brown fox jumps over the lazy dog. This is a test of the tokenizer utility.'","exampleUseCases":null,"resultDescription":"Returns the integer token count for the submitted text under the specified encoding, allowing the agent to estimate LLM costs, check context window fit, or enforce token budgets before making an LLM API call.","failureModes":["Text exceeds 50 MB limit — request rejected","Unsupported encoding value provided — error returned","Empty text field — may return 0 or validation error","Malformed JSON body — 400 error","content_type='image' used with non-base64 text — incorrect tile-based estimate"],"whenToPreferThis":"Use this endpoint when you need an accurate or estimated token count before calling an LLM, to avoid context window overflows, estimate API costs, or enforce token budgets. Prefer cl100k_base for GPT-4/GPT-3.5 (exact BPE), o200k_base for GPT-4o (exact BPE), claude for Anthropic models (estimated), or gemini for Google models (estimated). Also use for base64-encoded images with content_type='image' for vision tile-based estimation.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-11T00:49:21.197Z","isFirstParty":false,"canonicalSlug":"utilsforagents-com-44c1f37d"}