Open AgentPay Python SDK (`open-agentpay`)
The Open-Source Financial Firewall & Micro-Payment Infrastructure for Autonomous AI Agents
📚 Documentation • 💻 GitHub Repository • 🐦 Follow on X (@OpenAgentPay) • 🐛 Report Issue
💡 What is AgentPay?
AgentPay equips autonomous AI agents with micro-payments (Circle USDC on Arbitrum Sepolia & Base) governed by an in-process, non-custodial Financial Firewall. It transparently intercepts HTTP 402 Payment Required responses, validates policy limits, and signs off-chain authorizations—protecting agent wallets against runaway loops and LLM hallucinations.
📦 Package Name Note: The canonical PyPI distribution is
open-agentpay(official aliases:agentpay-core,agentpay-firewall). Regardless of which package you install, you importagentpayin Python code.
⚡ Quickstart
1. Installation
pip install open-agentpay
(Optional LangChain support):
pip install "open-agentpay[langchain]"
2. Basic Usage: On-Chain Mode with Financial Firewall
Transparently intercepts HTTP 402 challenges, enforces local policy limits, and signs off-chain EIP-712/EIP-3009 authorizations:
from agentpay import AgentPayClient, LocalSigner
from agentpay.policy import SQLitePolicyEngine, PolicyConfig
# 1. Initialize local signer (non-custodial private key, 0 gas required)
signer = LocalSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
# 2. Configure local financial firewall
policy = SQLitePolicyEngine.create_in_memory(
PolicyConfig(
id="agent_firewall",
wallet_address=signer.address,
max_per_tx_base_units=100_000, # Max $0.10 per call
rolling_budget_24h_base_units=1_000_000, # Daily cap $1.00
circuit_max_rpm=5, # Trip circuit breaker if > 5 calls/min
)
)
# 3. Create client with automatic x402 challenge negotiation
client = AgentPayClient(signer=signer, policy=policy)
# 4. Transparent call (auto-pays 402 challenge via EIP-712 off-chain signature)
response = client.get("https://api.seller.com/v1/market-data?ticker=NVDA")
print(response.json())
3. Virtual Wallet Mode (API Key Path)
For sub-millisecond execution using a pre-funded virtual ledger:
from agentpay import AgentPayClient, LocalSigner
from agentpay.policy import SQLitePolicyEngine, PolicyConfig
client = AgentPayClient(
signer=LocalSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"),
policy=SQLitePolicyEngine.create_in_memory(PolicyConfig(...)),
headers={"Authorization": "Bearer agp_live_your_api_key"},
)
response = client.get("https://gateway.seller.com/v1/compute")
4. LangChain Tool Integration (@paid_tool)
Convert any Python function into a paid LangChain tool protected by the financial firewall:
from agentpay.integrations.langchain import paid_tool
@paid_tool(name="fetch_stock_quote", description="Fetch real-time stock prices", client=client)
def fetch_stock_quote(ticker: str) -> dict:
resp = client.get(f"https://api.seller.com/v1/market-data?ticker={ticker}")
return resp.json()
# Invoked seamlessly by LangChain agents
result = fetch_stock_quote.invoke({"ticker": "NVDA"})
5. Async Client (AsyncAgentPayClient)
For high-concurrency agent workflows:
import asyncio
from agentpay import AsyncAgentPayClient, LocalSigner
from agentpay.policy import SQLitePolicyEngine, PolicyConfig
async def main():
async with AsyncAgentPayClient(signer=signer, policy=policy) as client:
response = await client.get("https://api.seller.com/v1/market-data?ticker=NVDA")
print(response.json())
asyncio.run(main())
🛡️ Core Capabilities
| Pillar | Description |
|---|---|
| Zero-Trust Financial Firewall | Enforces per-transaction caps, 24-hour rolling budgets, lifetime limits, and payee whitelists outside the LLM prompt. |
| Autonomous Circuit Breaker | Automatically halts agent loops and freezes spending when request frequency exceeds safety thresholds (circuit_max_rpm). |
| Gasless Off-Chain Settlements | AI Agents hold only Circle USDC; gas is sponsored on Arbitrum Sepolia & Base via EIP-3009 off-chain authorizations. |
| Agent Session & Audit Observability | Automatic tracking headers (X-Agent-Session-ID, X-Agent-Task-ID) connect tool spending to tasks in the AgentPay Console. |
| Fail-Closed Guarantees | Any policy violation, budget overrun, or upstream failure aborts safely with zero funds deducted. |
📖 Documentation & Community
- Official Documentation: https://open-agentpay.github.io/AgentPay/
- GitHub Repository: https://github.com/open-agentpay/AgentPay
- Twitter / X: @OpenAgentPay
- Issue Tracker: GitHub Issues
📄 License
Apache-2.0 License. See LICENSE for details.
Metadata
Release files for open-agentpay 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| open_agentpay-0.2.4.tar.gz | 66.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| open_agentpay-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 154.0 kB
Release files / open_agentpay-0.2.4.tar.gz
| Download URL | open_agentpay-0.2.4.tar.gz |
|---|---|
| Size | 66.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b82cd9878c40151a42a6a6de0d5ec0652ac1c05d34438af2046cbb724788f03
|
|
BLAKE2b-256 checksum How to use checksums |
0ff110a8c3a652f7c2d03f3f5909e4716fd6a4830db6d2eb37a70527d046e9d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Release files / open_agentpay-0.2.4-py3-none-any.whl
| Download URL | open_agentpay-0.2.4-py3-none-any.whl |
|---|---|
| Size | 87.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
757fb7ee4057e547f22494511768fa9db9116c8944c2ab1854ba2ee45ad87588
|
|
BLAKE2b-256 checksum How to use checksums |
4bfc27cf138eb2bff798cce1b807bd7191889735f9232e93d5526940931923fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Security for open-agentpay 0.2.4
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.