Skip to main content Switch to mobile version l402sdk 0.2.1 L402 client SDK for AI agent frameworks — pay for APIs with Lightning
pip install l402sdk==0.2.1 Copy PIP instructions
L402 client SDK for Python — pay for APIs with Lightning
Built in Rust via PyO3. Supports LND, CLN, and SwissKnife Lightning backends.
pip install l402 Quick Start
from l402 import L402Client, Budget # Create a client backed by LND REST client = L402Client.with_lnd_rest( "https://localhost:8080", "hex-encoded-admin-macaroon", budget=Budget(per_request_max=1000, daily_max=50_000), ) # L402 negotiation happens automatically response = client.get("https://api.example.com/paid-resource") print(response.status) # 200 print(response.paid) # True # Payment receipt receipt = response.receipt print(receipt.amount_sats) # 100 print(receipt.payment_hash) # hex string # Budget tracking print(client.total_spent()) # 100 print(client.receipts()) # [Receipt(...)] Lightning Backends
from l402 import LndRestBackend, ClnRestBackend, SwissKnifeBackend, L402Client # LND REST client = L402Client.with_lnd_rest("https://localhost:8080", "macaroon_hex") # Core Lightning (CLN) REST client = L402Client.with_cln_rest("https://localhost:3010", "rune_token") # SwissKnife client = L402Client.with_swissknife("https://app.numeraire.tech", "sk-...") Budget Control
from l402 import Budget budget = Budget( per_request_max=100, # Max sats per request hourly_max=1000, # Max sats per hour daily_max=5000, # Max sats per day total_max=50000, # Max sats total ) # Or no limits budget = Budget.unlimited() API Reference
response.status # HTTP status code (int) response.body # Response body (str) response.paid # Whether a payment was made (bool) response.cached_token # Whether a cached token was used (bool) response.receipt # Payment receipt or None response.json() # Response body parsed as JSON Receipt
receipt.timestamp # Unix timestamp (seconds) receipt.endpoint # URL accessed receipt.amount_sats # Amount paid (sats) receipt.fee_sats # Routing fee (sats) receipt.payment_hash # Payment hash (hex) receipt.preimage # Preimage (hex) receipt.response_status # HTTP status after payment receipt.total_cost_sats # amount + fee License
Released: Dec 1, 2026
Author: Dario Anongba Varela
MIT OR Apache-2.0 View SPDX License List
l402 lightning bitcoin payments ai-agents
Development Status 3 - Alpha
Intended Audience Developers
License OSI Approved :: Apache Software License
OSI Approved :: MIT License
Programming Language Python :: 3
Topic Software Development :: Libraries
Release files for l402sdk 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distributions (wheels)
Total release size: 109.1 MB
Release files / l402sdk-0.2.1.tar.gz
Release files / l402sdk-0.2.1-pp312-pypy312_pp80-manylinux_2_28_aarch64.whl
Release files / l402sdk-0.2.1-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl
Release files / l402sdk-0.2.1-cp315-cp315t-manylinux_2_28_aarch64.whl
Release files / l402sdk-0.2.1-cp314-cp314t-manylinux_2_28_aarch64.whl
Release files / l402sdk-0.2.1-cp313-cp313-win_amd64.whl
Release files / l402sdk-0.2.1-cp312-cp312-win_amd64.whl
Release files / l402sdk-0.2.1-cp311-cp311-win_amd64.whl
Release files / l402sdk-0.2.1-cp310-cp310-manylinux_2_28_aarch64.whl
Release files / l402sdk-0.2.1-cp39-cp39-manylinux_2_28_aarch64.whl
Security for l402sdk 0.2.1
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 1, 2026 39 release files No provenance
Oct 29, 2026 36 release files No provenance
Apr 15, 2026 30 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from a8e35ed











