Skip to main content

AgentPay Python SDK — Lightning Network payments for AI agents

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentpay_python-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentpay_python-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file agentpay_python-0.1.2.tar.gz.

File metadata

  • Download URL: agentpay_python-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for agentpay_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ef971b53aa81c52e9472f7bd29c899df905af105945158bd4e76d2abba22f915
MD5 2e6481fbb95a3408fc49739d2ac03fb6
BLAKE2b-256 1a804fce1f6ef0f41ec3f2eee24b1a9a604a83900c3049c2e07efdb9e6507fe6

See more details on using hashes here.

File details

Details for the file agentpay_python-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agentpay_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 440932ec51e277e717c6dbd4189676daa6923c60901d80837e8f6dbfad1baf33
MD5 161d54db6811475d9317118f2b17d690
BLAKE2b-256 73a552f6e658a90bea12f088c47123fc6dcbeeab7fab6fcf12a1ff026e1f877e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page