# WritersLogic Token Bucket Rate Limiter

> WritersLogic Token Bucket Rate Limiter is a paid API for AI agents from agents.writerslogic.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-11-18).

Atomically consumes or inspects tokens from a named rate-limiting bucket shared across an entire agent fleet, with idempotent retry support.

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/token-bucket?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-18
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/writerslogic-token-bucket-rate-limiter-5234a421
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__uEptHzn6n47OaBjVTEkK

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 writerslogic-token-bucket-rate-limiter-5234a421 -d '<json body>'
```

Example prompt: Check if my agent fleet can make another OpenAI call right now — use the bucket 'openai:org-123:rpm' with capacity 60 and refill 1 token per second, deduct 1 token, and use request ID 'req-abc-001' so a retry won't double-charge.

## When to prefer this

Use this endpoint when you need a single, consistent rate limiter shared across multiple concurrent AI agents or workers that all hit the same downstream API or resource. It is especially valuable when agents run in parallel and a local in-memory counter would cause each to independently exceed quota. The idempotent requestId makes it safe for retry-heavy agent loops. Prefer this over local throttling whenever your fleet has more than one worker or when you need verifiable, auditable quota enforcement with atomic semantics.

## Known failure modes

- Bucket configuration conflict: if capacity or refillPerSecond differ from initial settings, the call is rejected to prevent fleet misconfiguration
- Duplicate request ID with different inputs: rejected to prevent ambiguous idempotency
- Token cost exceeds remaining capacity: returns allowed=false with retryAfterMs
- Invalid bucket name pattern: rejected if name contains disallowed characters
- Missing tenantId for API-key callers: required field absent causes rejection
- Cost below minimum (0.000001) or above maximum (1000000): schema validation failure

## How this service works

Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.

## Output

Returns an 'allowed' boolean indicating whether the requested tokens were successfully consumed, plus 'remaining' token count after the operation. If denied, returns 'retryAfterMs' indicating how long to wait before enough tokens refill. For peek operations, returns current state without modification. Duplicate request IDs within 24 hours return the stored response without re-applying.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "op": {
   "enum": [
    "take",
    "peek"
   ],
   "type": "string"
  },
  "cost": {
   "type": "number",
   "maximum": 1000000,
   "minimum": 0.000001,
   "description": "Tokens to spend; default 1."
  },
  "bucket": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.:/@+-]{1,200}$",
   "description": "Bucket name, e.g. openai:org-123:rpm."
  },
  "capacity": {
   "type": "number",
   "maximum": 1000000,
   "minimum": 1
  },
  "tenantId": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.-]{1,64}$",
   "description": "Required for API-key callers (namespaced as key:<tenantId>; keep it unguessable). Ignored when a wallet paid: the payer address is the tenant."
  },
  "requestId": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.:-]{1,128}$",
   "description": "Caller-chosen id for this mutation. A retry with the same id and same input returns the stored response (24 h) instead of applying twice; the same id with different input is rejected. Send one on every mutation you may retry: without it a retry is applied again (fleet-memory record appends a duplicate; a repeated spend-ledger commit or release answers NO_HOLD because the first call already took effect)."
  },
  "refillPerSecond": {
   "type": "number",
   "maximum": 1000000,
   "minimum": 0.000001
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-token-bucket-rate-limiter-5234a421/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.writerslogic.com](https://www.zero.xyz/host/agents.writerslogic.com/llms.txt)
