What this does
l402-kit ships a built-in client that lets any AI agent — or any script — call L402-protected APIs without writing the payment loop yourself.Node.js / TypeScript
1. Install
2. Pick a wallet
- Blink
- Alby
Get credentials at dashboard.blink.sv → API Keys.
Python
1. Install
2. Call the API
- Blink
- Alby
What happens step by step
client.fetch/client.getsends the request without any auth header- If the API returns
402, the client reads theinvoiceandmacaroonfrom the response body (orWWW-Authenticateheader) - It checks your budget — throws
BudgetExceededErrorif the price would exceed the limit - It calls
wallet.payInvoice(bolt11)and waits for the preimage - It retries the request with
Authorization: L402 <macaroon>:<preimage> - Returns the final
Response/httpx.Responseto your code
Spending report
Next steps
Wallets
Blink, Alby — full setup and options
Budget control
Per-domain limits, callbacks, reports
MCP Server
Claude Desktop integration in 2 minutes
LangChain
Drop-in tool for LangChain agents