Key Highlights
- pi402 uses Lightning Labs’ L402 protocol to let coding agents pay for AI inference automatically through HTTP 402 responses and Lightning invoices.
- Aperture, Lightmeter, and the Wavelength wallet handle access control, usage metering, and payments without requiring users to operate Lightning nodes or manage payment channels.
- The demonstration pricing is approximately $0.375 per million input tokens and $1.50 per million output tokens.
How pi402 Enables Automated AI Payments
pi402 is built on L402, a protocol that Lightning Labs has been developing to connect web-based access controls with Bitcoin payments over the Lightning Network. The system combines the HTTP 402 “Payment Required” response with a Lightning invoice requesting a specific amount of Bitcoin.
When a coding agent requests access to a paid endpoint, the server returns a 402 response with a Lightning invoice attached. The agent pays the invoice, and the payment settles instantly, allowing the request to proceed without manual intervention.
Authentication is handled through macaroons, a form of credential token. This structure enables pay-per-token billing rather than a monthly subscription or prepaid credit balance. Agents pay for the exact number of tokens they use, request by request, and can manage the purchase process independently once the system has been configured.
Lightning Labs Tools Support the Seller Side
Providers also need infrastructure to accept payments and control access to their services. Lightning Labs directs sellers to Aperture and Lightmeter, two tools designed to work together for this purpose.
Aperture functions as an L402 reverse proxy. It sits in front of a service and manages the “pay first, then get access” process before a request reaches the underlying backend.
Lightmeter operates alongside Aperture to measure usage and accept payments. Together, the tools allow a provider to charge for access to an OpenAI-compatible inference endpoint while connecting payment collection with service metering.
Wavelength Removes the Need to Manage Lightning Infrastructure
Neither buyers nor sellers need to run a Lightning node or manage payment channels. The Wavelength wallet handles the payment process, using the Ark network to move funds automatically between Ark and Lightning.
In the pi402 demonstration, pricing is approximately $0.375 per million input tokens and $1.50 per million output tokens. The model gives agents a direct way to purchase inference based on actual usage rather than relying on a conventional account plan or manually funded balance.
How Lightning Labs Built Toward pi402
pi402 represents the latest stage in a series of Lightning Labs releases during 2026 focused on enabling software agents to transact independently. In February, Lightning Labs launched agent tooling designed to help software interact with Lightning payments. In October, Wavelength went live on mainnet.
Each release addressed a different part of the payment workflow. The agent tools gave software a way to conduct transactions, Wavelength reduced the operational burden of managing Lightning infrastructure, and pi402 combined those capabilities into a system that coding agents can use to buy inference.
Why This Matters
pi402 shows how HTTP payment requests, Lightning settlement, usage metering, and automated wallets can be combined into a single machine-to-machine purchasing flow. Instead of requiring a person to approve each transaction or maintain a prepaid account, an agent can request a paid service, complete the payment, and receive access as part of its normal operation.
The approach also gives inference providers a mechanism for charging according to consumption. Aperture and Lightmeter handle the access and measurement layers, while Wavelength addresses the payment infrastructure, creating a workflow in which both sides can participate without directly operating Lightning nodes or payment channels.
Frequently Asked Questions
What is pi402?
pi402 is a system built on Lightning Labs’ L402 protocol that allows coding agents to pay automatically for access to services such as OpenAI-compatible inference endpoints.
How does a pi402 payment work?
A paid endpoint returns an HTTP 402 “Payment Required” response containing a Lightning invoice. The agent pays the invoice, and access is provided after the payment settles.
How much does the demonstration inference service cost?
The demo pricing is approximately $0.375 per million input tokens and $1.50 per million output tokens.




