agenttollgate
The 60-second paywall for AI agents.
Created on 26th April 2026
•
agenttollgate
The 60-second paywall for AI agents.
The problem agenttollgate solves
AI agents are about to spend money on the open web — but the payment infra they need doesn't exist yet. Stripe was designed for humans clicking "Buy now," not autonomous agents calling APIs at machine speed. The result: every API team that wants to sell to agents has to roll their own paywall, key rotation, abuse limits, and reconciliation — or just give up and stay free.
AgentTollgate is a drop-in paywall layer that wraps any HTTP API behind a CheckoutWithLocus toll. You point it at your upstream URL, set a price, and you get a tollgated endpoint that:
- Returns HTTP 402 Payment Required with a Locus pay URL when an agent calls without payment
- Settles the payment in USDC on Base via CheckoutWithLocus
- Replays the original request upstream once paid, returning the real response with x-locus-receipt
- Comes with a policy DSL (per-agent spend caps, geo rules, allow/deny lists) and reputation-based dynamic pricing (good agents pay less, brand-new or flaky agents pay a multiplier)
- Exposes itself over MCP so any Claude/GPT/Anthropic agent can discover and pay for tollgates the same way it discovers tools
A merchant goes from "I have an API" to "AI agents can pay me in USDC" in under 60 seconds. No custom auth, no Stripe Connect, no chargebacks.
Challenges I ran into
-
The 402 replay loop under concurrent retries. An agent that gets 402'd will retry. If the retry lands before the webhook confirms payment, we'd either double-charge or serve a stale response. We solved this by keying every session by Locus's session_id directly, so retries with the same x-locus-receipt are O(1) idempotent lookups, and we re-confirm with Locus on every replay rather than trusting our local cache.
-
Designing reputation scoring that doesn't punish new agents permanently. A naive score-based multiplier locks new agents out forever. We landed on a 0–1000 score with a 1.6 - score/1000 multiplier — new agents start at 500 (1.1× price), good agents drift toward 1× over time, and abusive agents climb toward 1.6× before policy hard-caps them out.
-
Locus's API surface is still evolving. We wrote a thin client (src/lib/locus.ts) with a mock-mode fallback so the proxy, dashboard, and MCP server all develop against a stable interface. Swapping in production keys is a one-line change.
-
better-sqlite3 native bindings across Node versions. The prebuild for Node v22 darwin-arm64 wasn't downloading on
npm install --omit=optional. Lazy-initializing the DB insrc/lib/db.ts(so the binding only loads on first call, not at import time) plus a documentednpm rebuild better-sqlite3 --build-from-sourcestep in the README fixed it. -
Making the 402 flow legible in a pitch deck. Sequence diagrams in pptxgenjs are painful. We ended up drawing it slide-by-slide as vertical lifelines with widely-spaced arrow rows so the agent ↔ Tollgate ↔ Locus ↔ Upstream interaction reads at a glance.
Tracks Applied (1)
Track: Checkout with Locus
Technologies used
Cheer Project
Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.
