Ax402Docs
GETTING STARTED

Buyer clients

Pay gateway URLs from TypeScript, Go, Python, CLI, or MCP

Buyer clients pay gateway hostnames — seller API URLs wrapped by Ax402 — from scripts, agents, CI, or backends with an x402-capable EVM wallet. They do not call the control plane. For in-browser humans, use the React paywall .

How it works

  • Request a gateway URL (e.g. https://myapi.example.com/v1/data)
    • Gateway returns HTTP 402 with payment requirements
    • Buyer client signs with your EVM wallet and retries with PAYMENT-SIGNATURE
    • Gateway verifies via the facilitator and returns the upstream response You do not configure a facilitator URL in buyer code — the gateway handles verify/settle.

Environment

  • AX402_EVM_PRIVATE_KEY — signing key funded with USDC on the gateway network (legacy: EVM_PRIVATE_KEY)
    • Gateway URL — seller hostname, not AX402_BASE_URL Staging smoke test: https://echo.staging.ax402.io/echo/get?test=1 (Base Sepolia USDC).

Language parity

  • TypeScriptexact + batch-settlement, browser wallet signer
    • Goexact only; settlement via SettleResponseFrom
    • Pythonexact sync + AsyncBuyerClient

TypeScript

pnpm add @axlabs/ax402-sdk @x402/fetch @x402/evm viem
const client = await buyerClientFromEnv();
const { response, payment } = await client.pay({
  url: "https://echo.staging.ax402.io/echo/get?test=1",
});
const body = await response.text();

Also: payAndFetch(signer, {"{ url }"}), createPaymentFetch(signer), createEvmSignerFromBrowserProvider().

Batch-settlement gateways

const client = await buyerClientFromEnv({
  batch: { depositMultiplier: 5 },
});

TypeScript is the only SDK with batch-settlement buyer support today.

Go

import "github.com/AxLabs/ax402-sdk/go/buyer"
c, err := buyer.NewFromPrivateKey(os.Getenv("AX402_EVM_PRIVATE_KEY"))
resp, err := c.Get(ctx, "https://echo.staging.ax402.io/echo/get?test=1")
defer resp.Body.Close()
settle, _ := c.SettleResponseFrom(resp)

Also: PayURL(ctx, method, url, body), HTTPClient(). See Go SDK .

Python

pip install "ax402-sdk[buyer]"
from ax402_sdk.buyer import BuyerClient
result = BuyerClient.from_env().get("https://echo.staging.ax402.io/echo/get?test=1")
print(result.status_code, result.settlement)
# Async
from ax402_sdk.buyer import AsyncBuyerClient, evm_signer_from_private_key

CLI and MCP

export AX402_EVM_PRIVATE_KEY=0x...
ax402 inspect url --url https://echo.staging.ax402.io/echo/get?test=1 --json
ax402 pay url --url https://echo.staging.ax402.io/echo/get?test=1 --json

MCP ax402_pay_url uses the same env var. See MCP server and CLI reference .

When to use what

  • Node / TS backend or agent → @axlabs/ax402-sdk/buyer
    • Go service or CI → go/buyer
    • Python script or async service → ax402_sdk.buyer
    • Browser SPA with wallet UI → React paywall

Protocol reference

Signing and facilitator interaction: x402-foundation/x402 . Ax402 testnet facilitator: https://ax402.testnet.app.mf.axlabs.net.

On this page