Purpose
l402-kit aims to let developers charge for APIs in the simplest way possible, priced in bitcoin satoshis (sats), using the L402 protocol on the Bitcoin Lightning Network under the hood. It is officially described as adding pay-per-call capability to any API with "3 lines of code." It is also positioned as the "payment layer for autonomous agents," enabling AI agents to pay for API calls without human intervention.
Main capabilities
- Multi-language SDKs: SDKs for TypeScript, Python, Go, and Rust.
- Server-side middleware: for implementing L402 payment verification on the API server side.
- Agent client with automatic payment: agents can complete the payment flow automatically.
- MCP server: for Claude Desktop, Cursor, and any MCP-compatible agent.
- LangChain integration and budget control.
- Protocol support: L402 (Bitcoin Lightning Network), and compatible with x402 (USDC/Coinbase).
- Compatible ecosystem: LangChain, OpenAI Agents, CrewAI, Vercel AI SDK, AutoGPT, any MCP client.
- Security and reliability design: based on the SHA256 one-way function, the preimage cannot be forged; encrypted settlement, no chargebacks; provides MemoryReplayAdapter (development) and RedisReplayAdapter (production, multi-instance) for replay protection; officially claims 600+ automated tests across 5 runtimes (TS, Python, Go, Rust, Cloudflare Workers).
- Bring your own node: connect your own Lightning node by implementing the LightningProvider interface (officially said to be 5 lines).
- VS Code extension: monitor payments in real time within the editor, including a real-time payment stream by endpoint, bar charts (1D/7D free, 30D/1Y/ALL are Pro), built-in support for 11 languages, light/dark/auto themes, zero configuration (only need to set a Lightning Address).
- Readable instructions for AI agents: provides llms.txt, as well as /.well-known/agent.json and /.well-known/l402.json for agent discovery.
How to use
Officially, the core flow is: install → 402 → pay → 200 OK, and an end-to-end demo video is provided. The documentation is available in multiple languages (including Chinese). For AI agents, the official offering includes a system prompt snippet that can be added to any agent to enable L402 payments, along with an Agent SDK quick start and MCP server configuration instructions. When using the VS Code extension, you only need to set a Lightning Address, with no other configuration required. How to get a Lightning Address: register for free at dashboard.blink.sv (no credit card required, instant activation), with an address in the form yourname@yourdomain.com; other wallets include Wallet of Satoshi, Phoenix, Zeus, and Alby.
Use cases
- Developers who want to charge for APIs by number of calls.
- Autonomous agent workflows that need AI agents to automatically pay for APIs.
- Projects using LangChain, OpenAI Agents, CrewAI, Vercel AI SDK, AutoGPT, or MCP clients.
- Scenarios requiring replay protection, auditability, and encrypted settlement without chargebacks.
Limitations and notes
- Charging and settlement are based on the Bitcoin Lightning Network, requiring a Lightning Network wallet or a self-hosted node.
- The official material emphasizes "why not Stripe," highlighting the unforgeable, chargeback-free, and auditable characteristics of encrypted settlement, but does not provide specific fee rates, prices, or performance data.
- The project uses the MIT license and is open source.
- Complete API details, installation commands, and specific code examples for the SDKs in each language are not fully provided in the materials and are not yet available.