agent-payment-sdk
Python SDK for AgentPayment Network — the only hybrid crypto + fiat payment infrastructure built for autonomous AI agent-to-agent transactions.
Installation
pip install agent-payment-sdk
Quick Start
from agent_payment_sdk import AgentPaymentClient
client = AgentPaymentClient(
api_key="your_api_key",
base_url="https://agentpayment.network"
)
# Send a payment
payment = client.send_payment(
from_agent_id="your_agent_id",
to_agent_id="receiver_agent_id",
amount=10.00,
payment_method="crypto" # "crypto", "stripe_card", or "ach"
)
print(payment)
Get your API key by signing up at agentpayment.network.
Payment Rails
Crypto (ETH on Base Mainnet)
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=5.00,
payment_method="crypto"
)
Stripe Card
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=25.00,
payment_method="stripe_card",
payment_method_id="pm_your_stripe_pm_id"
)
ACH Bank Transfer
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=100.00,
payment_method="ach",
payment_method_id="your_plaid_payment_method_id"
)
Agent-to-Agent Billing
Provider agents can autonomously invoice consumer agents. Consumer agents can set auto-approval rules so payments execute instantly with no human required.
Create an Invoice (Provider Agent)
invoice = client.create_invoice(
from_agent_id="provider_agent",
to_agent_id="consumer_agent",
amount=15.00,
currency="USD",
payment_rail="crypto",
description="API usage fee - 1000 requests"
)
print(f"Invoice ID: {invoice['invoice_id']}")
print(f"Status: {invoice['status']}")
Set Auto-Approval Rule (Consumer Agent)
rule = client.set_billing_rule(
agent_id="consumer_agent",
approved_provider_id="provider_agent",
max_amount=50.00,
payment_rail="crypto"
)
# Now any invoice from provider_agent under $50 will auto-pay instantly
Pay an Invoice Manually
result = client.approve_invoice(
invoice_id="invoice_uuid",
agent_id="consumer_agent"
)
print(f"Paid: {result['status']}")
List Invoices
invoices = client.list_invoices(agent_id="your_agent_id")
for inv in invoices:
print(f"{inv['invoice_id']} — ${inv['amount']} — {inv['status']}")
Webhooks
Subscribe to payment events so your agent gets notified instantly.
# Register a webhook endpoint
webhook = client.create_webhook(
url="https://your-agent.com/webhooks",
events=["payment.completed", "payment.failed", "invoice.paid"]
)
print(f"Webhook secret: {webhook['secret']}")
Verify incoming webhooks with HMAC-SHA256:
import hmac, hashlib
def verify_webhook(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
Error Handling
from agent_payment_sdk import PaymentError, NetworkError
try:
payment = client.send_payment(
from_agent_id="agent_123",
to_agent_id="agent_456",
amount=10.00,
payment_method="crypto"
)
except PaymentError as e:
print(f"Payment failed: {e}")
except NetworkError as e:
print(f"Network error: {e}")
Resources
- Docs: agentpayment.network/docs
- Live Demo: agentpayment.network/demo
- PyPI: pypi.org/project/agent-payment-sdk
- Support: support@agentpayment.network
License
MIT
Sandbox vs Live
Every account gets a sandbox twin agent automatically on signup. Use it for testing — no real money moves.
# Test with sandbox (from your welcome email)
client = AgentPaymentClient(api_key="your_sandbox_api_key")
payment = client.send_payment(
from_agent_id="sandbox_youragentid", # sandbox_ prefix
to_agent_id="sandbox_receiveragentid",
amount=10.00,
payment_method="crypto"
)
# Simulated transaction — no real ETH spent
# Switch to live when ready
client = AgentPaymentClient(api_key="your_live_api_key")
Sandbox agents start with $1,000 simulated balance. Sandbox and live agents cannot interact — mixing them returns a sandbox_live_mismatch error.
Fees
AgentPayment charges only our margin — third-party fees (Stripe, gas) are separate.
| Plan | Crypto | Card | ACH |
|---|---|---|---|
| Free | 0.5% | 0.5% | 0.5% |
| Pro | 0.3% | 0.3% | 0.3% |
| Business | 0.2% | 0.2% | 0.2% |
| Enterprise | Custom | Custom | Custom |
Stripe processing fees (2.9% + $0.30 card, 0.8% ACH) and gas fees (~$0.01) are charged separately.
Hosted Setup Pages
No frontend? Use our hosted pages to set up payment methods:
Card setup:
https://agentpayment.network/setup-card.html?agent_id=YOUR_AGENT_ID&api_key=YOUR_API_KEY&callback_url=YOUR_CALLBACK
Bank account setup:
https://agentpayment.network/setup-bank.html?agent_id=YOUR_AGENT_ID&api_key=YOUR_API_KEY&callback_url=YOUR_CALLBACK
After completion, your callback_url receives ?status=success&payment_method_id=xxx&agent_id=xxx.
Metadata
Release files for agent-payment-sdk 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_payment_sdk-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for agent_payment_sdk-0.5.2-py3-none-any.whl |
Release files / agent_payment_sdk-0.5.2-py3-none-any.whl
| Download URL | agent_payment_sdk-0.5.2-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
205f55cb813fa65366de6a2ab41eed21671fd66e0cf8af62340b59cf37e9c8a0
|
|
BLAKE2b-256 checksum How to use checksums |
86b9efa1b9b3997149f4bd234d464e433b15b8f95478d259c3a8127c315aae4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for agent-payment-sdk 0.5.2
Provenance
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.
No provenance found
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.