Why AI agents need L402
AI agents call APIs constantly. Today they can’t pay for them — they need a human to set up a credit card, billing account, and subscription. That breaks autonomy. L402 solves this natively:- Agent calls your API
- Gets a
402 Payment Requiredwith a Lightning invoice - Pays it from its own wallet (e.g. Blink, Phoenix, Alby)
- Retries with proof of payment (
Authorization: L402 <macaroon>:<preimage>) - Gets the data — no human, no card, settles in under 1 second
Setting up your paid API
Agent client implementation
This is what the agent-side code looks like — the pattern that any AI framework can implement:LangChain tool example
Wrap any L402 API as a LangChain tool so your agent can call it mid-chain:OpenAI function calling example
Flow diagram
Go and Rust for high-performance agents
For AI agent infrastructure built in Go or Rust, l402-kit provides native SDKs:Supported wallets for agents
This is the future of AI × Bitcoin
Every AI agent will need to pay for:- Premium data APIs
- GPU compute
- Storage
- Other AI services
Quickstart
Ship your first paid API in 5 minutes
npm package
TypeScript / Node.js
PyPI
Python / FastAPI / Flask
Go SDK
Go / net/http