# 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

```python
from solana_pay_kit import Signer
from solana_pay_kit.protocols.x402.client import SolanaRpc, x402_async_client
```

<Snippet lang="python" name="charge.client" url="https://api.example.com/quote" />

## Low-level building blocks

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

```python
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`](/docs/toolchain) CLI is the simplest client — it handles the wallet, signing, and the 402 retry against any pay-kit server:

```bash
pay curl http://127.0.0.1:8000/quote
```
