Skip to main content

Python SDK for pay -- payment infrastructure for AI agents

Project description

pay-skill

Python SDK for pay -- payment infrastructure for AI agents. USDC on Base.

Install

pip install pay-skill

Optional keychain support (reads key stored by pay CLI):

pip install pay-skill[keychain]

Requires Python 3.10+.

Quick Start

from payskill import Wallet

wallet = Wallet()  # reads PAYSKILL_KEY env var

# Pay another agent $5
result = wallet.send("0xprovider...", 5.0, memo="task-42")
print(result.tx_hash)

# Open a metered tab
tab = wallet.open_tab("0xprovider...", 20.0, max_charge_per_call=0.50)

# x402 request (SDK handles payment automatically)
response = wallet.request("https://api.example.com/data")
print(response.json())

Wallet Initialization

# Zero-config (reads PAYSKILL_KEY env var)
wallet = Wallet()

# Explicit key
wallet = Wallet(private_key="0x...")

# OS keychain (reads key stored by `pay` CLI)
wallet = Wallet.create()

# Env var only
wallet = Wallet.from_env()

# Testnet
wallet = Wallet(testnet=True)
# or set PAYSKILL_TESTNET=1

Amounts

All amounts are in dollars by default. Use {"micro": int} for micro-USDC precision:

wallet.send("0x...", 5.0)                # $5.00
wallet.send("0x...", {"micro": 5000000}) # $5.00 (micro-USDC)
wallet.open_tab("0x...", 20.0, 0.10)     # $20 tab, $0.10/call max

All Methods

# Direct payment
result = wallet.send(to, amount, memo?)

# Tabs
tab = wallet.open_tab(provider, amount, max_charge_per_call)
tab = wallet.close_tab(tab_id)
tab = wallet.top_up_tab(tab_id, amount)
tabs = wallet.list_tabs()
tab = wallet.get_tab(tab_id)
charge = wallet.charge_tab(tab_id, amount)

# x402 paid HTTP
response = wallet.request(url, method=, body=, headers=)

# Wallet
bal = wallet.balance()    # Balance(total, locked, available)
st = wallet.status()      # Status(address, balance, open_tabs)

# Discovery (no auth needed)
services = wallet.discover("weather")
# or standalone:
from payskill import discover
services = discover("weather")

# Funding
url = wallet.create_fund_link(message="Need funds")
url = wallet.create_withdraw_link()

# Webhooks
wh = wallet.register_webhook(url, events=["payment.completed"])
webhooks = wallet.list_webhooks()
wallet.delete_webhook(webhook_id)

# Testnet
result = wallet.mint(100)  # mint $100 testnet USDC

Error Handling

from payskill import (
    PayError,
    PayValidationError,
    PayNetworkError,
    PayServerError,
    PayInsufficientFundsError,
)

try:
    wallet.send("0x...", 5.0)
except PayInsufficientFundsError as e:
    print(e.balance, e.required)
    url = wallet.create_fund_link(message="Need funds")
except PayValidationError as e:
    print(e.field)  # which field failed
except PayServerError as e:
    print(e.status_code)
except PayNetworkError:
    print("Server unreachable")

OWS (Open Wallet Standard)

pip install pay-skill[ows]

wallet = Wallet.from_ows(wallet_id="my-agent")

Links

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

pay_skill-0.1.13.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

pay_skill-0.1.13-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pay_skill-0.1.13.tar.gz.

File metadata

  • Download URL: pay_skill-0.1.13.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pay_skill-0.1.13.tar.gz
Algorithm Hash digest
SHA256 e836c90e6a7751e0dedd5a594f73a26dcd6a3b7cebb5d377f0402fce1a195045
MD5 57a63c7fa5b4d06939d435a870cc6f1d
BLAKE2b-256 068b1d97cf66f22d4b248795999f91f0077c12ecf1da3c20a4558893bdda4f67

See more details on using hashes here.

Provenance

The following attestation bundles were made for pay_skill-0.1.13.tar.gz:

Publisher: release.yml on pay-skill/pay-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pay_skill-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: pay_skill-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pay_skill-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 bbe4e73c3dff49718f539a33f8c7cf0dc7e971dbe1700a363d7e624939cc6a10
MD5 8c57cb9b97da23aee31f1ad709ded9ea
BLAKE2b-256 e023274e29c21bbf0c7b5f1fb72daa36300bdae6f5319e06bbdfa55f3c842bdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pay_skill-0.1.13-py3-none-any.whl:

Publisher: release.yml on pay-skill/pay-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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