bolthub
PricingBlogDocs
bolthub

Lightning pay-per-call for MCP tools and APIs. Agents pay per call and you keep custody, straight to your wallet. Built for tool builders and AI teams.

contact@bolthub.ai

Product

All productsbolthub Pay SDKHosted platformToolClientAPI HubNode LauncherPricingFor tool buildersFor agent buildersCharge for your toolsDocs

Legal

Terms of ServicePrivacy PolicySecurityAcceptable Use

Resources

API HubBlogWhat is L402?L402 vs x402RSS feed

Packages

npm

@bolthub/​payPayments SDK@bolthub/​mcpMCP server@bolthub/​cliCLI@bolthub/​verifyOrigin verifier

PyPI

bolthubPython SDKbolthub-verifyPython verifier
bolthub

© 2026 Signal Tech Pty Ltd. All rights reserved.

All posts
March 17, 2026
TutorialAI AgentsPython

Building AI Agents That Pay for Their Own Data

The autonomous data problem

You're building an AI agent. It needs data from external APIs: market prices, weather, legal documents, satellite imagery. Each API has its own signup process, API key format, and billing model.

Managing 20 different API accounts is annoying for a human developer. For an autonomous agent, it's a showstopper.

L402 as the universal payment layer

With L402, your agent needs exactly one thing: a Lightning wallet. Every L402-enabled API works the same way:

  1. Request data
  2. Receive 402 + Lightning invoice
  3. Pay invoice
  4. Retry with proof of payment
  5. Receive data

No signups. No API keys. No billing accounts.

Setting up your agent

Install the bolthub Python client:

pip install bolthub

Initialize the client with a Lightning wallet and a budget:

from bolthub import L402Client, LndWallet
wallet = LndWallet(host="https://your-node:8080", macaroon="...")
client = L402Client(wallet, budget_sats=50_000)

The budget_sats parameter prevents runaway spending. The client will refuse to pay once the budget is exhausted.

Fetching paid data

Use the client exactly like requests:

resp = client.get(
"https://btc-intel.gw.bolthub.ai/v1/market/snapshot",
params={"exchange": "binance"}
)
data = resp.json()
print(f"BTC price: {data['price']}")
# Budget remaining: client.budget_remaining_sats

The client automatically:

- Detects 402 responses

- Parses the Lightning invoice from the WWW-Authenticate header

- Pays the invoice via your wallet

- Retries the request with the L402 token

- Tracks spending against your budget

Multi-source aggregation

The real power emerges when your agent needs data from multiple sources:

sources = [
"https://btc-intel.gw.bolthub.ai/v1/market/snapshot?exchange=binance",
"https://btc-intel.gw.bolthub.ai/v1/derivatives/overview",
"https://btc-intel.gw.bolthub.ai/v1/sentiment/overview",
]
results = []
for url in sources:
resp = client.get(url)
results.append(resp.json())

One wallet. Three paid endpoints. Zero signups.

Session-based access

For APIs using token buckets or time passes, the client manages sessions automatically:

# First request pays and creates a session
resp = client.get("https://btc-intel.gw.bolthub.ai/v1/derivatives/liquidations/stream")
# Subsequent requests reuse the session token
for i in range(49):
resp = client.get("https://btc-intel.gw.bolthub.ai/v1/derivatives/liquidations/stream")
# Session token is sent via X-Session-Token header automatically

Integration with LangChain

Use L402 as a tool in your LangChain agent:

from langchain.tools import Tool
from bolthub import L402Client, LndWallet
wallet = LndWallet(host="https://your-node:8080", macaroon="...")
client = L402Client(wallet, budget_sats=10_000)
market_data_tool = Tool(
name="market_data",
description="Fetch a Bitcoin market snapshot for a given exchange",
func=lambda exchange: client.get(
f"https://btc-intel.gw.bolthub.ai/v1/market/snapshot?exchange={exchange}"
).json()
)

Your LangChain agent can now autonomously fetch and pay for market data as part of its reasoning chain.

What's next

- Browse the API Hub to discover available L402 endpoints

- Read the SDK documentation for advanced configuration

- Start your free trial to list your own API

Start charging

Charge for your toolsCharge per call. Payments settle straight to your wallet, non-custodially.For AI agentsGive your agent a budget and let it pay for any API in the hub, with no keys or signups.
What is L402?PricingBrowse the API Hub