Lightning Labs Launches Pi402, Letting AI Coding Agents Pay for Inference With Bitcoin
Key Takeaways
- •pi402, released on November 12, 2026, is an open-source extension that lets AI coding agents autonomously purchase inference with Bitcoin over the Lightning Network without any signup, API key, or credit card.
- •The system is powered by Lightning Labs' L402 protocol, which attaches Lightning invoices to the HTTP 402 'Payment Required' status code and uses macaroon tokens for authentication, with payments settling instantly.
- •Billing follows a pay-per-token model in which agents pay exactly for the tokens consumed on each request rather than through monthly plans or prepaid balances.
- •On the seller side, Lightning Labs directs providers to Aperture, an L402 reverse proxy, and Lightmeter, a metering and payment tool, for charging access to OpenAI-compatible inference endpoints.
- •Neither buyers nor sellers need to run a Lightning node, since the Wavelength wallet — built on the Ark offchain Bitcoin protocol and launched on mainnet in October 2026 — automatically moves funds between Ark and Lightning.

Lightning Labs has released pi402, an open-source extension that allows AI coding agents to pay for their own inference in Bitcoin over the Lightning Network. The tool was unveiled on November 12, 2026, and is built for the Pi coding agent.
It requires no account signup, no API key, and no credit card. The agent sees a price, pays the invoice, and returns to its task.
The release targets a specific and growing problem: software agents increasingly need to buy compute, yet nearly every compute vendor still assumes a human is holding the wallet. Because pi402 is open source, the payment loop it implements can be inspected and adapted by other agent developers.
How pi402 works
The engine underneath pi402 is L402, a protocol Lightning Labs has been developing for some time. It pairs two pieces of infrastructure that were not originally designed to work together: the HTTP 402 "Payment Required" response and a Lightning invoice, which is a request for a specific amount of Bitcoin payable over the Lightning Network.
The 402 status code has sat in the HTTP specification for decades, reserved for future use, with no standard mechanism for actually moving money. L402 fills that slot by attaching a Lightning invoice to the response.
When an agent hits a paid endpoint, the server answers with a 402 status and an invoice attached. The agent pays the invoice, and the payment settles instantly — which is what allows the purchase to happen mid-task, with the agent paying, receiving access, and continuing without waiting for funds to clear.
Authentication runs through macaroons, a type of credential token. The result is pay-per-token billing: rather than a monthly plan or a prepaid credit balance, the agent pays for exactly the tokens it consumes, request by request.
Once the setup is configured, no human needs to intervene. The agent handles the entire purchase loop on its own.
The seller side and the wallet question
Payments require a counterparty to accept them. For that, Lightning Labs is directing sellers to two of its own tools.
Aperture is an L402 reverse proxy. It sits in front of a service and handles the "pay first, then get access" logic before requests reach the backend. Lightmeter works alongside Aperture to meter usage and accept payments. Together, the two tools let a provider charge for access to an OpenAI-compatible inference endpoint, a request format that many inference services already expose.
Neither buyers nor sellers need to run a Lightning node or manage payment channels. Instead, the Wavelength wallet takes care of payments. Wavelength is built on Ark, a Bitcoin protocol for offchain transfers, and automatically moves funds between Ark and Lightning.
On cost, the demo pricing is approximately $0.375 per million input tokens and $1.50 per million output tokens.
A year of building toward this
pi402 did not appear out of nowhere. It caps a run of releases from Lightning Labs across 2026 that all point in the same direction.
In February, the company launched agent tooling aimed at letting software interact with Lightning payments. In October, Wavelength went live on mainnet.
Each step filled a gap. The agent tools gave machines a way to transact, Wavelength removed the node-management burden, and pi402 now packages all of it into something a coding agent can use for a concrete purchase: inference.
The client is open source, the seller stack is documented, and the demo pricing is published. The next visible signal is whether inference providers put Aperture and Lightmeter in front of their own endpoints — the seller path Lightning Labs has laid out.
Disclosure: The original report was edited by Vivian Nguyen.