Python SDK for pay — payment infrastructure for AI agents
Project description
pay-sdk
Python SDK for pay — payment infrastructure for AI agents. USDC on Base.
Three primitives: direct payments, tabs (pre-funded metered accounts), and x402 HTTP paywalls.
Install
pip install pay-sdk
Requires Python 3.10+.
Quick Start
from payskill import PayClient
client = PayClient(signer="cli") # uses `pay sign` subprocess
# Pay another agent $5
result = client.pay_direct("0xprovider...", 5_000_000, memo="task-42")
print(result.tx_hash)
# Open a metered tab
tab = client.open_tab("0xprovider...", 20_000_000, max_charge_per_call=500_000)
# x402 request (SDK handles payment automatically)
response = client.request("https://api.example.com/data")
All amounts are in USDC micro-units (6 decimals). $1.00 = 1_000_000.
API Reference
PayClient
from payskill import PayClient
client = PayClient(
api_url="https://pay-skill.com/api/v1", # default
signer="cli", # "cli", "raw", "custom", or a Signer instance
)
Direct Payment
One-shot USDC transfer. $1.00 minimum.
result = client.pay_direct(to, amount, memo="")
# Returns: DirectPaymentResult(tx_hash, status, amount, fee)
Tab Management
Pre-funded metered account. $5.00 minimum to open.
# Open
tab = client.open_tab(provider, amount, max_charge_per_call)
# Query
tabs = client.list_tabs()
tab = client.get_tab(tab_id)
# Top up (no extra activation fee)
tab = client.top_up_tab(tab_id, amount)
# Close (either party, unilateral)
tab = client.close_tab(tab_id)
Returns Tab(tab_id, provider, amount, balance_remaining, total_charged, charge_count, max_charge_per_call, status).
x402 Requests
Transparent HTTP 402 handling. The SDK detects 402 Payment Required, pays (via direct or tab), and retries.
response = client.request(url, method="GET", body=None, headers=None)
# Returns: httpx.Response
If the provider requires tab settlement, the SDK auto-opens a tab at 10x the per-call price (minimum $5).
Wallet
status = client.get_status()
# Returns: StatusResponse(address, balance, open_tabs)
Webhooks
wh = client.register_webhook(url, events=["tab.opened"], secret="whsec_...")
webhooks = client.list_webhooks()
client.delete_webhook(webhook_id)
Funding
link = client.create_fund_link(amount=10_000_000) # Coinbase Onramp
link = client.create_withdraw_link(amount=5_000_000)
Signer Modes
| Mode | Usage | When |
|---|---|---|
"cli" |
Subprocess call to pay sign |
Default. Key in OS keychain. |
"raw" |
PAYSKILL_KEY env var |
Dev/testing only. |
"custom" |
Your own callback | Custom key management. |
# CLI signer (default)
client = PayClient(signer="cli")
# Raw key (dev only)
client = PayClient(signer="raw", key="0xdead...")
# Custom callback
from payskill.signer import CallbackSigner
signer = CallbackSigner(callback=lambda hash_bytes: my_sign(hash_bytes))
client = PayClient(signer=signer)
Error Handling
from payskill.errors import (
PayError, # Base class
PayValidationError, # Bad input (has .field)
PayNetworkError, # Connection failed
PayServerError, # Server returned error (has .status_code)
PayInsufficientFundsError, # Not enough USDC
)
Configuration
| Env Var | Purpose |
|---|---|
PAYSKILL_KEY |
Private key for raw signer mode |
The API URL is configurable via the api_url parameter. Default: https://pay-skill.com/api/v1.
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 pay_skill-0.1.3.tar.gz.
File metadata
- Download URL: pay_skill-0.1.3.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1af5ef8725d70e6cac7e149558d6f45ef830541ab18a9b0b91da56544a2bad2
|
|
| MD5 |
a8416eb1201e42b7f0c942220d0ad979
|
|
| BLAKE2b-256 |
f4cdbbc23d19ddedf5ee49d4db824dbe153f06f987e1e9df36082dc1fe3b685f
|
Provenance
The following attestation bundles were made for pay_skill-0.1.3.tar.gz:
Publisher:
release.yml on pay-skill/pay-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pay_skill-0.1.3.tar.gz -
Subject digest:
e1af5ef8725d70e6cac7e149558d6f45ef830541ab18a9b0b91da56544a2bad2 - Sigstore transparency entry: 1269915557
- Sigstore integration time:
-
Permalink:
pay-skill/pay-sdk@a37eac01f9b7d13257991f825248e24eec64a985 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/pay-skill
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a37eac01f9b7d13257991f825248e24eec64a985 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pay_skill-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pay_skill-0.1.3-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfd1ec0e827f5aeb67a68a8a5580688ea32f6b2fe2c851885bab4382e1c97194
|
|
| MD5 |
0b375b68cb175a01bbb52f88a77db38d
|
|
| BLAKE2b-256 |
5f91b260c412f17a9f64c1b4f9bc8c9d2f732f66251365c656457c002b64980a
|
Provenance
The following attestation bundles were made for pay_skill-0.1.3-py3-none-any.whl:
Publisher:
release.yml on pay-skill/pay-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pay_skill-0.1.3-py3-none-any.whl -
Subject digest:
dfd1ec0e827f5aeb67a68a8a5580688ea32f6b2fe2c851885bab4382e1c97194 - Sigstore transparency entry: 1269915800
- Sigstore integration time:
-
Permalink:
pay-skill/pay-sdk@a37eac01f9b7d13257991f825248e24eec64a985 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/pay-skill
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a37eac01f9b7d13257991f825248e24eec64a985 -
Trigger Event:
push
-
Statement type: