BTC/USD:

68,977

24H Change:

-3.66%

Lightning Nodes:

0

TVL:

0.0 BTC

Lightning Channels:

0

Current Fees:

7 Sats/vb

BTC/USD:

68,977

24H Change:

-3.66%

Lightning Nodes:

0

TVL:

0.0 BTC

Lightning Channels:

0

Current Fees:

7 Sats/vb

Lightning Labs pi402: The Coding Agent That Pays for Its Own Inference

media generation pi402 lightning news thumbnail 0 2529a55a 228b 4663 8b25 12d425d3b779
Share

The problem

AI agents spend money. Inference is metered by the token, yet the payment rails behind it are account-based: a human opens an account, stores a card, copies an API key, and tops up a balance. An autonomous coding agent holds none of those. It cannot pass a card check, it should never hold the seller’s API key, and prepaid balances strand capital in accounts the agent may never use again. The agent economy has a billing model built for its operators, not for the agents. At PSP Dex, where we track the platforms and protocols that let agents pay, this is the gap the whole field is racing to close.

The product

Lightning Labs, the team behind LND and the L402 protocol, has released pi402: an open-source extension for the Pi coding agent that lets the agent pay for its own inference, per token, over the Lightning Network. No accounts, no buyer-side API keys, no cards. The seller runs the gateway and keeps the model key, the pricing and the infrastructure. There is no hosted endpoint and nothing to sign up for.

Strengths

  • Payment is the credential. The seller’s gateway answers an unpaid request with HTTP 402, a Lightning invoice and a macaroon tied to that invoice. Paying the invoice reveals the preimage, and the macaroon plus preimage is the access token. The request retries and streams. No key ever reaches the buyer; the proxy holds the model credential and injects it server-side.
  • Two protocols in one challenge. A single 402 response can offer L402 and the newer Payment scheme (MPP, the Stripe and Tempo HTTP authentication draft). pi402 takes a Payment offer when one is made and falls back to L402, so sellers are not locked into one standard while the agentic payments field settles.
  • No node on either side. Wavelength, Lightning Labs’ Ark-based wallet, pays invoices through a swap server. Buyers fund from a phone wallet in seconds; sellers mint invoices from Wavelength instead of running LND. The two heaviest pieces of Lightning infrastructure disappear.
  • Budgets are built in, not bolted on. Every quote is checked against a per-request ceiling and a daily cap before the wallet moves. The published defaults cap a request at 5,000 sats and a day at 12,000 sats, so an agent’s spend is bounded by policy the operator sets once.
  • Metering is exact. The Aperture gateway and the Lightmeter pricing service quote a bundle, reserve an estimate, then debit the actual usage the model reports, rounding up and releasing the rest. Sellers price in millisatoshis per token and keep a margin; the pi402 page shows a 25 percent margin turning a Kimi-K3 rate of 3 and 15 msat per token into a quoted 4 and 19.

Weaknesses

  • One agent today. pi402 is an extension for Pi. Other agent frameworks watch the same protocol work from the outside until equivalent extensions land.
  • Sellers self-host. Aperture, the meter and the wallet are the seller’s to run. That is the design (the seller keeps the key and the margin), and it prices out sellers who want a hosted checkout instead.
  • Pricing is still demonstration-grade. The rates on pi402.tech are demo values with BTC pinned at $100,000 in the simulator: a 1,000,000-token Kimi-K3 bundle at 11,500 sats, GLM-4.7 at 2,000 sats, GLM-5.2 at 4,000 sats. Live seller pricing will set its own numbers.

The solution it proves

pi402 is a working answer to the question every agent platform is now asking: how does software buy a metered service from software, instantly, at a cost per call too small for card rails? Its answer: HTTP 402 as the paywall, Lightning as the settlement, a token bundle as the unit, and budget policy as the control. Installation is one command (pi install npm:@lightninglabs/pi-402), a wallet funding step, and a model switch.

The opportunity

For inference sellers, this is a new checkout: price per token, get paid per bundle, hold no card data and chase no invoices. For agent builders, inference becomes a variable cost the agent manages itself inside hard caps. And for the wider market, L402 just moved from protocol specification to a shipping product from the team that wrote it. PSP Dex tracks L402 alongside x402, AP2, ACP and MPP in the Agentic Payments Index, and covers the Lightning rails behind it in the Bitcoin and Lightning directory.

Advertisement

Project: pi402.tech · Code: github.com/lightninglabs/pi-402 · L402: docs.lightning.engineering

Share

Keep Up to Date with the Most Important Lightning Network News

Advertisement