Show HN: BoltzPay – fetch() that pays for AI agents (x402 and L402)

github.com · leventilo · 6 hours ago · view on HN
0 net
I built an open-source SDK that lets AI agents pay for API data automatically.

The problem: a growing number of APIs return HTTP 402 Payment Required. Coinbase reports $50M+ in x402 transactions over the last 30 days. Stripe and Cloudflare joined the x402 Foundation last month. The payment layer of the internet is being built right now, but existing HTTP clients just fail on 402 responses.

BoltzPay makes it one line:

  const agent = new BoltzPay({ budget: { daily: "$5.00" } });
  const data = await agent.fetch("https://x402.twit.sh/tweets/search?words=AI+agents");
The SDK detects which payment protocol the endpoint uses (x402 or L402), signs the payment with the developer's own keys, and returns the data. No dashboard, no API keys to manage per provider. Just fetch().

What's under the hood:

* Multi-protocol: x402 (EIP-712 signed USDC on Base/Solana) + L402 (Lightning invoices via NWC/Alby)

* Parallel protocol detection: ProtocolRouter probes 402 headers with Promise.allSettled(), auto-fallback between adapters

* Budget engine: daily/monthly/per-transaction caps with persistent state. 90% threshold warnings. Agents never touch your wallet directly

* Built-in endpoint discovery: the SDK indexes live paid APIs across the x402 ecosystem and probes them in real-time (health, pricing, protocol support)

* Delivery diagnostics: when payment succeeds but the server errors, the SDK returns structured diagnosis (DNS, latency, protocol format, server health)

Ships as 9 packages: TypeScript SDK, MCP server (7 tools for Claude/Cursor), CLI, Vercel AI SDK, LangChain, CrewAI, n8n, and OpenClaw. npm + PyPI. 1200+ tests. MIT licensed. Your keys, no vendor lock-in.

What I didn't expect: within two weeks, autonomous AI agents started opening issues on the repo, proposing trust scoring and payment verification integrations. The people behind them turned out to be serious builders (Microsoft Principal Engineer, PhD researchers in the Bitcoin/Lightning space). The agent economy isn't coming. It's already here and looking for plumbing.