pay.sh docs
SDKPython

Client

Pay x402-gated APIs from Python with x402_async_client — an httpx.AsyncClient that settles a 402 in one retry — plus the low-level building blocks.

Python ships the paying side for x402. The auto-pay transport mirrors the Go NewClient ergonomics: hand it a signer and an RPC and you get back an httpx.AsyncClient that replays any 402 with a signed PAYMENT-SIGNATURE, then returns the paid response.

Auto-pay client

from solana_pay_kit import Signer
from solana_pay_kit.protocols.x402.client import SolanaRpc, x402_async_client
# x402_async_client returns an httpx.AsyncClient that turns any 402 into a# signed PAYMENT-SIGNATURE payment and replays the request — transparently.async with x402_async_client(signer, rpc) as http:    resp = await http.get("https://api.example.com/quote")    print(resp.status_code, resp.headers.get("payment-response"))

Low-level building blocks

For callers that drive their own HTTP, the pieces are exposed too (mirroring the Rust/Go client):

from solana_pay_kit.protocols.x402.client import build_payment_header, parse_x402_challenge

offer = parse_x402_challenge(headers, body, selection)        # select an offer
header = await build_payment_header(signer, rpc, offer)        # base64 PAYMENT-SIGNATURE

Or just use the CLI

For most cases the pay CLI is the simplest client — it handles the wallet, signing, and the 402 retry against any pay-kit server:

pay curl http://127.0.0.1:8000/quote

On this page