Pay-per-use AI inference via the x402 payment protocol. No signup, no API key — your wallet is your identity, your balance, and your session.

Why Durable Objects

Most payment-gated APIs bolt a database onto a stateless server — Postgres for balances, Redis for rate-limiting, a separate auth layer for identity. Durable Objects collapse all of that into a single primitive.

Each wallet is routed to its own DO instance via idFromName. That instance owns its µUSDC balance exclusively — no shared state, no contention, no double-spend. Replay prevention uses storage.transaction() to atomically check a seen:{txHash} key and top up the balance in one operation, at the edge, with no external infrastructure.

Conversation memory

Each wallet's DO instance stores the conversation as a history key. On every request, the full message array is sent to the model — so follow-up questions and multi-turn reasoning work without the client managing any state. The reply is captured and saved via ctx.waitUntil() after the stream, adding zero latency. History is capped at 20 messages and tied to the wallet, not the browser.

Request flow
sequenceDiagram participant C as Client participant W as Worker participant DO as Durable Object participant S as Storage participant AI as Workers AI C->>W: POST /infer {prompt, wallet} W->>DO: idFromName(wallet) DO->>S: get balance + history DO->>AI: messages[...history, prompt] AI-->>C: SSE stream DO-->>S: waitUntil → save reply
Endpoints
POST   /infer     run inference (post-billed by token usage)
GET    /balance   { balance, totalDepositedMicroUSDC, totalSpentMicroUSDC, totalRequests }
GET    /history   [ { role, content }, … ]
DELETE /history   clear conversation
Payment flow
  1. POST /infer402 + PAYMENT-REQUIRED header (base64 JSON)
  2. Send 0.001 USDC on Base Mainnet, get a txHash
  3. Retry with PAYMENT-SIGNATURE: btoa(proof)200 SSE stream + balance topped up
Pricing
0.001 USDC → 1,000 µUSDC balance
Billed at actual token usage · 1 neuron = 11 µUSDC
  Llama 3.1 8B   ~200–500 credits typical
  Llama 3.3 70B  ~500–2000 credits typical
  (typical request)
Stack
cloudflare-workers durable-objects workers-ai x402 base-mainnet usdc
Try it
Add Credits
1,000
$0.001
5,000
$0.005
10,000
$0.01
50,000
$0.05
or enter custom amount
Wallet
or enter address manually
💸 Payment required
Send 0.001 USDC on Base Mainnet to:

Paid from a different wallet? Enter txHash manually
Prompt (Ctrl+Enter to send)
Model
Conversation History
No messages yet. Ask anything to begin.