Lightning Labs Releases Developer Tools for Powering APIs and Large Language Models
Today, we’re excited to announce the release of a new set of developer tools to enable the Lightning and AI developer communities to build global, inclusive, and out-of-the-box cost effective LLM (Large Language Model) tooling which seamlessly incorporates Lightning and bitcoin. These tools are built on the L402 protocol, a Lightning native authentication mechanism, and Langchain, a popular library to simplify working with AI agents by adding external data to allow for more advanced functionality:
- LangChainBitcoin: a suite of tools that enables Langchain agents to directly interact with Bitcoin and also the Lightning Network, including two main features:
- LLM Agent BitcoinTools: a series of tools that leverages the newly released OpenAI GPT function calls to enable developers to create agents that can hold a Bitcoin balance (on-chain and Lightning), send/receive Bitcoin on Lightning, and also directly drive with a LND node.
- L402 HTTP API Traversal: a Python wrapper for a LangChain LLM chain (APIChain) that enables agents to transparently access L402 payment-metered APIs.
- Aperture: the latest release of Aperture, a drop-in reverse proxy server implementation of the L402 protocol which can transform any API into a pay per use resource gated via L402 functionality and sats on the Lightning Network.
- Now with Lightning Node Connect Support: Aperture supports any Lightning Node running litd, a binary that bundles Lightning Labs’ services alongside LND, (e.g Voltage, Umbrel, Start9, Raspiblitz, BTCPayServer) through the Lightning Node Connect protocol, an end-to-end encrypted mechanism for connecting a Lightning node to a web browser.
- Rich Dynamic API Endpoint Pricing: Aperture now supports the ability to optionally provide full HTTP request context to the proxied backend to enable dynamic per-call pricing. In contrast to the existing static pricing configuration, dynamic pricing allows a backend to implement custom endpoint pricing logic.
- L402 bLIP: a Bitcoin Lightning Improvement Proposal (bLIP) specification for the L402 protocol standard to openly share the primitives for building these components with the community.
- L402 is a protocol standard for payment-metered APIs explicitly designed to fit neatly into the existing HTTP 402 Payment Required status response code, which was optimistically included by the creators of the Web to enable native payments. A combination of Bitcoin, the Internet's native currency and the Lightning Network enables globally accessible rapid, scalable micropayments for paid APIs via L402.
L402 ⚡ + AI 🤖
The Lightning Network (via the L402 protocol) can help overcome a number of challenges currently facing LLM development:
- Gating access to highly trained LLMs can be much more granular and cost effective with per-use Lightning paywalls. Credit cards force merchants to push higher costs onto consumers to overcome chargebacks and fraud fees. Bitcoin is a digital bearer asset and Lightning payments settle instantly. That means the cost of each LLM query can be offloaded directly to the consumer in realtime, and prices can be adjusted dynamically to respond to ongoing LLM maintenance/scaling costs.
- The L402 protocol can be used to create payment-metered APIs that are accessible to billions of people worldwide who do not have credit cards. The L402 protocol is a payment-metered API standard that uses the HTTP 402 Payment Required status response code to enable global Lightning micropayments for paid APIs. This means that any developer can create APIs that are only accessible to users who have already paid for them - without having to rely on credit cards (so no chargeback/fraud risk or complicated fiat payment infrastructure). L402 makes any paid online resource immediately accessible to a global audience of bitcoin users - whether that be humans or AI agents. Typical fiat payment infrastructure isn't accessible to autonomous agents, so a digital bearer asset like Bitcoin is required instead.
- AI agents can manage bitcoin wallets and make micropayments to collect resources and complete goals. AI agents are software programs that can learn and perform tasks autonomously. After equipping these agents with bitcoin wallets, they can make micropayments to external L402-enabled APIs to query information or initiate subtasks. This will allow AI agents to operate more effectively and independently across the web.
The L402 protocol is a promising tool for enabling machine-to-machine web interactions, which is why it complements LLM development so well. More generally, L402 helps decentralize the market for all online services by enabling anyone to set up a content/data paywall with instantly global reach.
Aperture
The L402 protocol is a protocol standard for the authentication of paid APIs (using the internet’s preferred currency: sats!). The L402 protocol finally presents a use for the internet’s forgotten HTTP error code: 402 Payment Required. You’ve probably seen error codes such as 200 OK, 404 NOT FOUND, and 500 INTERNAL SERVER ERROR. Alongside these error codes, the early authors of the HTTP protocol also inserted provision to enable internet-native payments. However, at the time, Bitcoin hadn’t yet been created, so a decentralized currency for the internet didn’t yet exist. The L402 protocol bridges the gap, by creating a protocol standard that enables programmatic micropayments for API, login, and digital resource access.
Aperture is the first L402-aware reverse proxy that enables seamless L402 integration for any existing API. Aperture serves as a bridge between an incoming request and a payment metered backend. Aperture handles the L402 protocol negotiation, pricing, authentication, and API key creation for the backend. As a result, any existing API backend can easily be upgraded to add L402 awareness.
The latest version of Aperture now enables dynamic pricing. This dynamic pricing feature means that an Aperture-aware API backend can dynamically inform the proxy what the new pricing should be for a given endpoint. In the context of LLMs, this means that a backend could modify the price as a function of the type of model, query length, context window, and other parameters directly related to the operational cost of a model. Aperture also now supports SQLite and Postgres database backends, which should be a very familiar construct for developers.
The combination of the L402 protocol and open source models enables a number of impactful innovations. As an example, a user can sell a prompt by gating access to an API capable of responding to queries against the prompt itself. Potential buyers can then ask their own local agent to evaluate the response given a set of criteria. If the agent approves of the response, then further responses can be purchased. This interaction effectively creates a new tit-for-tat evaluation model to ensure that purchased data and information meets quality guidelines.
Conclusion
We’re extremely excited about the new wave of innovation brought about with the latest wave of LLM models. With the L402 protocol and LangChainBitcoin, we’re able to ensure the open models can be accessed using an open payment system, connected to the world’s set of open APIs. In the end, open source will win, and we’re working to provide the tooling to enable greater accessibility to AI for humans and agents alike.
To get started using these developer tools to build your own AI and Lightning-powered products, check out the L402 bLIP, download Aperture, and read the Aperture developer documentation. If you need access to a Lightning node with LNC integration, you can spin one up in a variety of ways from running your own custom setup to using a node OS like Umbrel, Start9, or Raspiblitz to using a hosting provider like Voltage. As long as the node also runs litd, then you have access to Lightning Node Connect and can connect it directly to your Aperture instance.