Live demo · L402 over Lightning

An AI agent that pays its own way

No API key, no account, no credit card. The agent asks an API for data, gets 402 Payment Required with a Lightning invoice, pays a few sats, shows the proof, and gets the answer. Machine to machine.

①Request
②402 + invoice
③Pay ⚡
④Proof
⑤Retry with L402
⑥Paid data

How it works · step 1 of 6

THE BUYER THE SELLER THE DATA 🤖The agentprogram on this page 🏪Seller APIcodeorange.dev/api/l402 📊mempool.spacelive Bitcoin data 📱Your phoneWallet of Satoshi ⚡Seller's walletMinibits (ecash) 🎟️ Ticket (macaroon)locked5 calls
①

The agent asks for data

Say it like this:

1 · The agent's wallet

Spent 0 / 100 sats0 payments
  agent@codeorange ~ l402
Pick a wallet and press “Run the agent”.

⚡ Fund the agent: sats

Scan with any Lightning wallet. The agent is waiting for the payment, then it carries on by itself.

Open in wallet

The agent's briefing

Try it yourself

curl -i 'https://codeorange.dev/api/l402?tool=price' # → HTTP/1.1 402 Payment Required # → WWW-Authenticate: L402 macaroon="…", invoice="lnbc100n1…" # pay the invoice, keep the preimage, then: curl -H 'Authorization: L402 <macaroon>:<preimage>' 'https://codeorange.dev/api/l402?tool=price'

The same pattern powers Lightning Labs' Aperture and pi-402, which let a coding agent pay for its own AI model calls. Data from mempool.space. Payments go to Code Orange's Lightning wallet.