402 with the price and payment requirements, the buyer authorizes payment, and your server uses a facilitator to verify and settle it before delivering the resource.
PayAI lets you start accepting ordinary exact payments on Mainnet without creating a portal account or obtaining an API key. You supply a receiving wallet and the route you want to charge for. The free allowance gets the integration started; an agent can later buy credits and a key programmatically, without sending a human through signup.
Choose the shortest path to a working payment
For a first integration, choose one network, one asset and one route. The Base example charges
0.01 USDC (10000 atomic units); the Solana example charges 0.001 USDC (1000 atomic units). Keep the buyer’s explicit cap equal to the intended price. Do not raise it silently.
x402, Stripe, or both?
Use x402 when an agent needs to buy a bounded API call, tool action, data result or other HTTP resource. Keep your existing commerce stack for carts, subscriptions, tax, refunds, fulfillment and customer billing. They can coexist: continue using Stripe or another processor for human and customer commerce, and add x402 only to machine-facing routes that benefit from per-request payment. Stripe describes support for both MPP and x402 in its machine-payments overview. PayAI’s route in this guide is x402; this page does not claim that PayAI implements MPP.What you need—and what you do not
- A receiving wallet address. Keep its private key out of the API server unless a specific feature requires signing.
- The framework integration for your service, and a price for each paid operation.
- A disposable, funded buyer wallet to verify the complete flow. A
402response alone does not prove a payment settled. - On Solana, the merchant’s USDC associated token account (ATA) must exist. Creating it requires a setup fee payer with SOL. PayAI sponsors settlement gas; account setup and later recovery transfers are separate operations.
/supported response. Testnets are free.
Add payments without rebuilding your application
- Choose a bounded operation: a report, lookup, inference request or premium API response.
- Apply x402 middleware to that route. Leave health checks and public documentation free.
- Configure the receiving address, network, asset and price. Connect the standard x402 facilitator client to PayAI using the
@payai/facilitatorpackage, or the equivalent configuration in your language. - Keep existing API keys and subscriptions for existing customers. Offer x402 as another access path; do not remove authorization from private data or user-specific operations.
- Deploy the service over HTTPS and run the paid-path checks below.
Prove the paid path, not just the implementation
The runnable Base and Solana examples include guarded smoke buyers and reconciliation commands. Before calling an integration complete, retain evidence of:- An unpaid request returning
402with the expected recipient, asset, network and price. - A buyer authorization within an explicit spending cap.
- A successful paid HTTP response and the matching finalized on-chain settlement with the exact asset, payer, recipient and amount. Balance-delta reporting is additional evidence when the chain and RPC can provide it accurately.
- Recovery of disposable test funds, where you control both wallets. Recovery has its own network fee; a merchant refund is not automatic.

