AgentPay Python SDK
Lightning Network payment infrastructure for AI agents. L402 paywall, credit management, and idempotent spending — in one clean SDK.
Installation
pip install agentpay-python
Quickstart
from agentpay import AgentPayClient
# Get an API key (50 free credits on signup)
client = AgentPayClient(api_key="sg_...")
bal = client.get_balance()
print(f"Balance: {bal.credits_remaining} credits")
# Spend credits (idempotent — safe to retry)
result = client.spend(amount=5.0, description="AI call")
print(f"Spent: {result.credits_used}, Remaining: {result.credits_remaining}")
# Usage forecast
forecast = client.forecast(estimated_cost_per_call=0.05)
if forecast.will_exhaust:
print("Credits running low!")
print(f"Estimated calls remaining: {forecast.estimated_calls_remaining}")
# L402 Paywall — generate Lightning invoice
pw = client.generate_paywall(amount=10.0, description="Premium content")
print(f"Invoice: {pw.invoice}")
# Topup — purchase more credits
top = client.topup(usd_amount=5.0)
print(f"Topup invoice: {top.invoice}")
API Reference
Full API documentation: api.aipp.dev/docs
Features
- L402 Paywall — Lightning-native paywall with macaroon tokens
- Credit System — Prepaid credits with spending limits
- Idempotent Spending — Safe retry, no double-charges
- Usage Forecasting — Predict when credits will run out
- Rate Limiting — IP + API key rate limits
- LNURL Auth — Login with your Lightning wallet
License
MIT — use it, ship it, build on it.
Metadata
Release files for agentpay-python 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentpay_python-0.1.2.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentpay_python-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / agentpay_python-0.1.2.tar.gz
| Download URL | agentpay_python-0.1.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef971b53aa81c52e9472f7bd29c899df905af105945158bd4e76d2abba22f915
|
|
BLAKE2b-256 checksum How to use checksums |
1a804fce1f6ef0f41ec3f2eee24b1a9a604a83900c3049c2e07efdb9e6507fe6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / agentpay_python-0.1.2-py3-none-any.whl
| Download URL | agentpay_python-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
440932ec51e277e717c6dbd4189676daa6923c60901d80837e8f6dbfad1baf33
|
|
BLAKE2b-256 checksum How to use checksums |
73a552f6e658a90bea12f088c47123fc6dcbeeab7fab6fcf12a1ff026e1f877e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|