There is no true pay-per-use option for LLMs today.
Subscription plans lock flagship models behind expensive tiers or impose hourly rate limits. Services that brand themselves as "pay as you go" — like OpenRouter — are actually prepaid: you deposit money upfront, they hold it, and deduct from your balance. Your funds leave your control the moment you top up.
Every existing payment model asks users to trust a third party with their money before receiving any value. Whether it's a $20/month subscription or a $5 prepaid deposit, you're always paying ahead for usage that hasn't happened yet.
Router402 is an OpenRouter-compatible AI gateway with real microtransaction-based billing. Every API call settles the cost of your previous request as a USDC micropayment on Base via the x402 protocol. Your money stays in your smart account until a completed request is being paid for — you never pay for something that hasn't happened yet.
No prepaid balances. No subscriptions. No custody. True pay-per-use.
sequenceDiagram
participant Client
participant Gateway as Router402 Gateway
participant Base as Base Network (USDC)
participant LLM as Claude / Gemini
Client->>Gateway: Request N + x402 payment header
Gateway->>Base: Settle cost of Request N-1 (~0.2s via Flashblocks)
Base-->>Gateway: Settlement confirmed ✓
Gateway->>LLM: Forward Request N
LLM-->>Gateway: Stream response
Gateway-->>Client: Stream response
Note over Client,Base: Each request pays for the previous one.<br/>Settlement must confirm before the LLM call is forwarded.
- Client sends a chat completion request with an x402 payment header.
- Gateway settles the cost of your previous request as a USDC micropayment on Base via Flashblocks (~0.2s).
- LLM provider (Claude or Gemini) processes the current request.
- Response streams back. The cost of this request will be settled with your next call.
The payment model is simple: every request pays for the one before it. This means the gateway always knows the exact token cost before settling — no estimates, no overcharges. Your first request is free to settle (there's no previous cost), and your funds never leave your smart account until a completed request is being paid for.
💸 True Micropayments — Not prepaid. Not subscription. Every API call settles an individual USDC microtransaction on Base via x402. Your money stays yours until the moment you use it.
⚡ 0.2s Settlement via Flashblocks — We modified the OpenFacilitator to leverage Base Flashblocks for ~200ms settlement finality. The previous request's cost settles on-chain before the next LLM call is forwarded — fast enough to feel seamless.
🔌 One API, Multiple Models — Access Claude and Gemini through a single OpenRouter-compatible endpoint. Switch models by changing one string — no new accounts, no new billing.
🔑 Smart Accounts — Pimlico-powered account abstraction with session keys. Gasless transactions, no wallet popups mid-conversation, and no seed phrases to manage.
🎯 Exact-Cost Settlement — Every request pays for the previous one, so the gateway always settles the real token cost — never an estimate. No overcharges, no disputes, no refund requests.
🔧 Drop-in Compatible — Already using OpenRouter? Point your existing tools at Router402. Same API shape, same model strings — new payment rail where you keep control of your money.
🌉 Li.Fi MCP Integration — Built-in MCP server that returns typed transaction data from Li.Fi. Users can bridge and swap assets directly from their own wallet — no private key handoff, no custody risk. The gateway returns the unsigned transaction; you sign it yourself.
| Subscriptions (ChatGPT, Claude Pro) | Prepaid (OpenRouter) | Router402 | |
|---|---|---|---|
| When you pay | Before use (monthly) | Before use (deposit) | After use (previous request) |
| Who holds your money | Provider | Provider | You (smart account) |
| Settlement speed | N/A (monthly billing) | Internal ledger | ~0.2s on-chain (Flashblocks) |
| Minimum commitment | $20/month | $5+ top-up | $0 — any amount |
| If service goes down | Money lost for the month | Balance stuck with provider | Nothing to lose |
| Flagship model access | High tiers only | Available | Available |
| Rate limits | Hourly caps | Token-based | None — pay more, use more |
| Refund if unused | No | Manual request | Automatic — you never overpay |
# Visit the demo app
open https://router402.xyz
# 1. Create a smart account (one click, powered by Pimlico)
# 2. Deposit USDC into YOUR smart account (you retain full custody)
# 3. Start chatting — each message pays for the previous one
# 4. Access your API key to use Router402 from any clientnpm install @router402/sdkimport { Router402Sdk } from '@router402/sdk';
const sdk = new Router402Sdk({ token: 'your-jwt-token' });
const response = await sdk.chat('Explain x402 in one sentence.', {
model: 'anthropic/claude-sonnet-4.5',
});
console.log(response);
// This request's cost will be settled via Flashblocks (~0.2s) with your next call
// Your funds stay in your smart account until then1. Install "Router402" from the VS Code Marketplace -> https://marketplace.visualstudio.com/items?itemName=router402xyz.router402-vscode
2. Add your API key in Settings → Router402
3. Cmd+Shift+P → "Router402: Chat" — prompt from your editor
curl -X POST https://api.router402.xyz/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3-flash",
"messages": [{"role": "user", "content": "Hello from cURL!"}]
}'graph TD
subgraph Clients
A[Demo Web App]
B[TypeScript SDK]
C[VS Code Extension]
D[cURL / Any HTTP]
end
subgraph Gateway["Router402 Gateway"]
E[Express · TypeScript · Prisma]
F[Anthropic — Claude]
G[Google — Gemini]
K[Li.Fi MCP Server]
end
subgraph Infrastructure
H[Pimlico — Account Abstraction]
I[Base Network — USDC]
J[OpenFacilitator — Flashblocks ⚡ 0.2s]
L[Li.Fi — Bridge & Swap]
end
A --> E
B --> E
C --> E
D --> E
E --> F
E --> G
E --> H
E --> I
E --> J
K --> L
| Layer | Technology |
|---|---|
| Gateway | Express, TypeScript, Prisma, Neon (Postgres) |
| Blockchain | Base L2 (Flashblocks), Viem, USDC |
| Account Abstraction | Pimlico, Smart Accounts, Session Keys |
| Payments | x402 Protocol, Modified OpenFacilitator (Base Flashblocks, ~0.2s settlement) |
| LLM Providers | Anthropic (Claude), Google (Gemini) |
| Auth | JWT with session-key-based identity |
| MCP | Li.Fi MCP Server (bridge & swap, returns typed tx data) |
| Clients | React / Next.js (demo), VS Code Extension API, TypeScript SDK |
hackmoney-router402/
├── apps/
│ ├── contracts/ # Solidity smart contracts (Foundry)
│ ├── extension/ # VS Code extension
│ ├── facilitator/ # Modified OpenFacilitator (Base Flashblocks)
│ ├── mcp/ # Li.Fi MCP Server (Cloudflare Workers)
│ ├── server/ # Backend API server (Express + Prisma)
│ └── web/ # Frontend web app (Next.js)
├── packages/
│ ├── sdk/ # TypeScript SDK — @router402/sdk
│ ├── types/ # Shared types — @router402/types
│ └── utils/ # Shared utilities — @router402/utils
├── docs/ # GitBook documentation
├── turbo.json # Turborepo config
└── package.json # Bun workspaces monorepo root
git clone https://github.com/itublockchain/hackmoney-router402.git
cd hackmoney-router402
# Install all workspace dependencies from root
bun installcd apps/server
cp .env.example .envFill in your .env:
# Required
DATABASE_URL=postgresql://user:pass@host.neon.tech/neondb
JWT_SECRET=at-least-32-characters-long-secret
PIMLICO_API_KEY=your_pimlico_key
# Optional (defaults provided)
PORT=8080
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000
RPC_URL=https://mainnet.base.org/
PAY_TO=0x...
FACILITATOR_URL=https://x402.org/facilitatorcd apps/server
bunx prisma migrate devCreate apps/web/.env.local:
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_walletconnect_id
# Optional (defaults provided)
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:8080
NEXT_PUBLIC_PIMLICO_API_KEY=your_pimlico_key
NEXT_PUBLIC_ZERODEV_PROJECT_ID=your_zerodev_id# From root — Turborepo starts both server and web
bun run devThis spins up:
- Server (API):
http://localhost:8080 - Web (Frontend):
http://localhost:3000
bun run build # Build all workspaces
bun run lint # Lint with Biome
bun run typecheck # TypeScript type checking
bun run test # Run tests
bun run format # Format code
bun run build:server # Build server only (includes sdk, types, utils)
# Prisma Studio (database GUI)
cd apps/server && bunx prisma studio- Gateway API with OpenRouter-compatible interface
- x402 micropayment integration on Base
- Modified OpenFacilitator with Base Flashblocks (~0.2s settlement)
- Smart account creation with Pimlico
- Claude and Gemini support
- TypeScript SDK
- VS Code Extension
- Demo web client
- Li.Fi MCP server (bridge & swap with typed transaction data)
- Usage analytics dashboard
- More LLM providers (Llama, Mistral, GPT)
- Multi-chain support (Optimism, Arbitrum, Solana)
- Staking rewards for frequent users
- Web App
- Docs
- Facilitator Dashboard
- Facilitator Server
- Facilitator Tx's Base Sepolia
- Facilitator Tx's Base Mainnet
- VS Code Extension
- LI.FI MCP
- Stake Contract
Built by ITU Blockchain at HackMoney 2026.

