{"uid":"cap_p876qZufWlf7k4ot1QJYu","slug":"x402-tools-token-counter-a729bfea","name":"x402-tools Token Counter","description":"Pay-per-call utility APIs for AI agents, settled in USDC via the x402 protocol.","url":"https://x402.nichospt.net/count-tokens?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","maxLength":1000000,"description":"Text to tokenize"},"encoding":{"enum":["cl100k_base","o200k_base"],"type":"string","default":"o200k_base","description":"BPE encoding. o200k_base = GPT-4o/o1; cl100k_base = GPT-4/3.5/embeddings."},"price_per_1m":{"type":"number","minimum":0,"description":"Optional USD price per 1M tokens; if set, estimated_cost is returned."}}},"responseSchema":{"type":"json","example":{"encoding":"o200k_base","token_count":5,"estimated_cost":0.0000125,"character_count":20}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","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.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_UrS0lK4eqgg1-3T9bic81","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Counts the number of BPE tokens in a text string using GPT-4o or GPT-4 encodings, optionally estimating cost at a given price per million tokens.","exampleAgentPrompt":"How many tokens is this text using the o200k_base encoding, and what would it cost at $5 per million tokens: 'The quick brown fox jumps over the lazy dog'?","exampleUseCases":null,"resultDescription":"A JSON object with the encoding used, total token count, character count of the input, and optionally an estimated cost in USD if price_per_1m was provided.","failureModes":["Text exceeds 1,000,000 character limit — request rejected","Invalid encoding value (not cl100k_base or o200k_base) — validation error","Missing text field — required parameter error","Payment not settled via x402 protocol — 402 Payment Required response"],"whenToPreferThis":"Use this endpoint when you need a fast, pay-per-call token count for GPT-4o (o200k_base) or GPT-4/3.5/embeddings (cl100k_base) text without running a local tokenizer. Ideal for agents that need to check prompt size, estimate API costs, or validate context window fit before making an LLM call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-11T00:39:45.751Z","isFirstParty":false,"canonicalSlug":"x402-tools-token-counter-a729bfea"}