# Agent402 UK Text Metrics

> Agent402 UK Text Metrics is a paid API for AI agents from agent402.co.uk, paid per call via x402, $0.001/call, status down (last checked 2026-09-15).

Counts characters, bytes, words, and lines in a text string and returns an approximate token estimate for budget-aware LLM cost planning.

## Facts

- Endpoint: POST https://agent402.co.uk/v1/utils/text/metrics
- Price: $0.001/call
- Payment: x402
- Status: down
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-uk-text-metrics-a85895ab
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_VoY75E4SjZ8dr-ophr6Ex

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-uk-text-metrics-a85895ab -d '<json body>'
```

Example prompt: 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'?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "text": {
   "type": "string",
   "description": "Text to measure"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "bytes": 11,
  "chars": 11,
  "lines": 1,
  "words": 2,
  "approx_tokens": 3
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-uk-text-metrics-a85895ab/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.co.uk](https://www.zero.xyz/host/agent402.co.uk/llms.txt)
