{"uid":"cap_VoY75E4SjZ8dr-ophr6Ex","slug":"agent402-uk-text-metrics-a85895ab","name":"Agent402 UK Text Metrics","description":"Don't burn tokens on deterministic work. Go/no-go jobs first: payout preflight, text firewall (PII/secrets), budget check — then rails, calendars, finmath. x402 USDC on Base. UK + global. agent402.co.uk — not agent402.tools. $0.001–$0.002 USDC on Base. No API keys.","url":"https://agent402.co.uk/v1/utils/text/metrics","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","description":"Text to measure"}}},"responseSchema":{"type":"json","example":{"bytes":11,"chars":11,"lines":1,"words":2,"approx_tokens":3}},"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":"down","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_LiNksfeJhVymXh9762Awl","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 characters, bytes, words, and lines in a text string and returns an approximate token estimate for budget-aware LLM cost planning.","exampleAgentPrompt":"Before I send this to the LLM, can you measure this text and give me the character count, word count, and approximate token estimate: 'The quick brown fox jumps over the lazy dog'?","exampleUseCases":[{"title":"Pre-prompt token budget check","prompt":"I'm about to send a long system prompt to GPT-4. Can you count the words, characters, and approximate tokens in this text so I know if I'll exceed the context limit: 'You are a helpful assistant who specializes in financial analysis. Your job is to review quarterly earnings reports and summarize key insights for busy executives...'?"},{"title":"Cost estimation before billable LLM step","prompt":"Before I run this article through the summarization model, tell me how many tokens it is so I can estimate the API cost — here's the text: 'Global markets rallied on Thursday after the Federal Reserve signaled a pause in interest rate hikes, with the S&P 500 gaining 1.4%...'"},{"title":"Document length validation for agent pipeline","prompt":"Check the size of this user-submitted input for me — I need the character count, byte count, word count, and token estimate to decide whether to truncate it before passing it downstream: 'Dear support team, I have been experiencing issues with my account for the past three weeks and have tried multiple times to resolve this...'"}],"resultDescription":"A JSON object containing exact counts for bytes, characters, lines, and words, plus an approximate token estimate (e.g. {\"bytes\":11,\"chars\":11,\"lines\":1,\"words\":2,\"approx_tokens\":3}). All counts are deterministic; the token estimate is approximate and suitable for budget planning.","failureModes":["Missing or empty 'text' field returns an error","Extremely large text payloads may time out or be rejected","Token estimate is approximate and may not match specific tokenizer implementations (e.g. cl100k_base vs p50k)","Non-UTF-8 encoded input may produce unexpected byte counts"],"whenToPreferThis":"Use this endpoint when an AI agent needs to measure text size before making a billable LLM API call or when enforcing context window limits. It is deterministic and cheap ($0.001 per call), making it ideal for pre-flight checks in automated pipelines. Prefer this over LLM self-estimation, which is unreliable for token counts, or client-side tokenizer libraries when you need a fast, network-callable utility without managing dependencies.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T11:26:10.233Z","isFirstParty":false}