PayAgentic Python SDK — Agent payments for AI agents
Project description
payagentic
Official Python SDK for PayAgentic — programmable USDC wallets for AI agents that pay external APIs over x402.
Install
pip install payagentic
# or
uv add payagentic
poetry add payagentic
Requires Python 3.13+.
Usage
Sync
from payagentic import PayAgentic
client = PayAgentic(api_key="pa_test_…")
# Or from env: PAYAGENTIC_API_KEY, PAYAGENTIC_AGENT_ID, PAYAGENTIC_BASE_URL
wallets = client.wallets.list_wallets()
payment = client.payments.propose_payment(body={...})
status = client.payments.get_payment(id=payment.id)
# x402 paywall walker
response = client.x402.fetch("https://api.vendor.com/paid-endpoint")
Async
from payagentic import AsyncPayAgentic
async with AsyncPayAgentic(api_key="pa_test_…") as client:
wallets = await client.wallets.list_wallets()
response = await client.x402.fetch("https://api.vendor.com/paid-endpoint")
Typed errors
Non-2xx responses raise typed exceptions you can catch by type:
from payagentic import PayAgentic, UnauthorizedError, RateLimitError, ValidationError
try:
client.wallets.list_wallets()
except UnauthorizedError:
...
except RateLimitError:
...
Full hierarchy: PayAgenticError → {Conflict, Forbidden, Internal, Network, NotFound, RateLimit, ServiceUnavailable, Unauthorized, Validation}Error. Use payagentic.is_retryable(err) for retry classification.
Mandate signer
from payagentic import LocalMandateSigner
signer = LocalMandateSigner.from_pem("path/to/key.pem")
mandate = signer.sign({...})
Pydantic models
All request/response shapes are Pydantic v2 models, re-exported under payagentic.models:
from payagentic.models import Wallet, PaymentResponse, MandateListItem
Generated transport
The HTTP transport in src/payagentic/_generated/ is generated by openapi-python-client from the gateway's OpenAPI spec at ../../api/openapi.json. Regenerate with the monorepo's just gen-sdk-py.
src/payagentic/_generated/ is marked linguist-generated=true. Don't edit those files directly — modify the gateway's #[utoipa::path] annotations + regenerate.
Development (from the monorepo)
just gen-sdk-py # regenerate from api/openapi.json
cd sdks/python
uv run pytest
uv run mypy src/payagentic
uv run ruff check src tests
uv build
Publishing
just release-py 0.1.0 # bumps version, builds, uv publish, tags
Needs PyPI API token in ~/.config/uv/credentials.toml or UV_PUBLISH_TOKEN env.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file payagentic-0.1.0.tar.gz.
File metadata
- Download URL: payagentic-0.1.0.tar.gz
- Upload date:
- Size: 117.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73a9f0c44f852aa87297c91c7a7102c5f412989979f3821e66f51afb0c30d513
|
|
| MD5 |
e91ade527331976ed65f1ee1d87b1d29
|
|
| BLAKE2b-256 |
ea21f7a8fa47ca9a4361f802d451e346785a0c183cbe3fe75b8343febf7bc2db
|
File details
Details for the file payagentic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: payagentic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 231.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
141cd5d888ef9d2795afb19ba26ec1c03fa1572b551b5e58f2cfe7bd0d42bda0
|
|
| MD5 |
4b6aab4eab46312907316cc819efa0ef
|
|
| BLAKE2b-256 |
928b86952da856e7e416c7cbacc162aa4a333a1c7ee3a3d14e32c731c7dbb48a
|