# DeFi Intel Agent Gateway – Token Counter & Trimmer

> DeFi Intel Agent Gateway – Token Counter & Trimmer is a paid API for AI agents from defi-intel-agent-gateway.gg-neo15.workers.dev, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Counts tokens in text (tiktoken-style) and trims text to a specified token budget, returning exact counts and truncated output.

## Facts

- Endpoint: POST https://defi-intel-agent-gateway.gg-neo15.workers.dev/v1/text/token-counter-trimmer
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/defi-intel-agent-gateway-token-counter-trimmer-6cbcbb71
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Fxu4VVmuoIrUpHLx2kKiC

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 defi-intel-agent-gateway-token-counter-trimmer-6cbcbb71 -d '<json body>'
```

Example prompt: Count the exact number of tokens in this text and trim it down to 3000 tokens if it exceeds that: 'The quick brown fox... [long document]'. Use tiktoken-style counting.

## When to prefer this

Choose this endpoint when you need precise tiktoken-compatible token counting or trimming without setting up an API key or account — ideal for pay-per-call agent workflows on Base that need to enforce LLM context window limits before making expensive model calls. Prefer over client-side tokenizers when you need server-side determinism or are operating in a sandboxed environment without tiktoken installed.

## Known failure modes

- Empty or missing input text returns a 400 validation error
- Token budget set to zero or negative value may return error or empty string
- Very large inputs may time out at edge runtime
- Malformed JSON body returns 422 unprocessable entity
- Payment failure (insufficient USDC balance) returns 402 Payment Required

## How this service works

Estimate exact token count (tiktoken-style) and trim text to a budget — $0.001 USDC/call on eip155:8453. Pay-per-call via x402 — no API key, no account. Free samples daily.

## Output

Returns the exact token count of the input text (tiktoken-compatible) and, if a trim budget is specified, returns the text truncated to fit within that token budget along with the resulting token count.

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/defi-intel-agent-gateway-token-counter-trimmer-6cbcbb71/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from defi-intel-agent-gateway.gg-neo15.workers.dev](https://www.zero.xyz/host/defi-intel-agent-gateway.gg-neo15.workers.dev/llms.txt)
