> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payai.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Accept payments from AI agents in your API or SaaS

> Add x402 payments to an API or SaaS with PayAI. Start on Mainnet without portal signup, test a real payment, and add credits programmatically when you need them.

Want an AI agent to pay for an API call? Protect a route with **x402**: your server returns an HTTP `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

| What you are building | Start here |
| - | - |
| An API that accepts payments from AI agents | [Solana Mainnet Express example](/x402/solana-mainnet-express): complete merchant, guarded buyer and receipt checks |
| An existing Express, Hono, Next.js, Python or Go service | [Merchant guides](/x402/servers/introduction): add middleware to the routes you want to monetize |
| A SaaS with an agent-facing API | Keep existing login and subscriptions; add a paid route for a bounded unit of work, then follow the merchant guide for your framework |
| An agent that needs to buy API access | [Client guides](/x402/clients/introduction): respond to a `402` using a funded wallet |
| High-frequency metered usage | [Solana batch settlement](/x402/servers/batch-settlement) or [Base batch settlement](/x402/servers/evm-batch-settlement): review the channel lifecycle before integrating |

For a first integration, choose one network, one asset and one route. The Mainnet Express example uses Solana USDC and charges `0.001 USDC` per request. To charge **one cent**, use `0.01 USDC` (`10000` atomic units for USDC) and update the buyer's explicit cap to match. Do not raise a buyer's limit silently.

## 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 `402` response 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.

You **do not need a PayAI portal signup or facilitator API key** for the ordinary exact starter flow. Do not add a signup step just because an SDK supports credentials.

The current starter allowance is **1,000 lifetime free credits per new receiving wallet**, subject to shared host/IP limits. This is a credit allowance, not a promise of 1,000 settlements. Rates depend on settlement gas plus 30%; see [pricing](/x402/facilitators/pricing) and the live [`/supported`](https://facilitator.payai.network/supported) response. Testnets are free.

## Add payments without rebuilding your application

1. Choose a bounded operation: a report, lookup, inference request or premium API response.
2. Apply x402 middleware to that route. Leave health checks and public documentation free.
3. Configure the receiving address, network, asset and price. Connect the standard x402 facilitator client to PayAI using the [`@payai/facilitator`](https://www.npmjs.com/package/@payai/facilitator) package, or the equivalent configuration in your language.
4. 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.
5. Deploy the service over HTTPS and run the paid-path checks below.

Payment proves payment, not permission to access another customer's data. For long-running jobs or requests with side effects, make job creation and delivery idempotent. Do not blindly authorize another payment after a timeout.

## Prove the paid path, not just the implementation

The [runnable Mainnet example](/x402/solana-mainnet-express) includes a guarded smoke buyer and reconciliation command. Before calling an integration complete, retain evidence of:

* An unpaid request returning `402` with 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 exact balance changes.
* Recovery of disposable test funds, where you control both wallets. Recovery has its own network fee; a merchant refund is not automatic.

If the HTTP response is lost, reconcile the original authorization before trying again. Follow [capacity and settlement recovery](/x402/facilitators/capacity-and-limits); do not treat an ambiguous response as a failed payment.

## Scale without a signup handoff

When the starter allowance is no longer enough, an agent can [buy a facilitator key and credits over x402](/x402/facilitators/agent-api-keys). The paying wallet becomes the account identity: **no pre-created portal account is required**, although a wallet-owned account is created by vending. Store the returned secret immediately and configure [server authentication](/x402/facilitators/authentication).

Vending starts at \$1 and purchased credits are non-refundable. A wallet already linked to a human portal account receives credits only; manage its keys in that portal. The [portal](https://merchant.payai.network) remains an optional interface for people who want it.

## Make your paid API discoverable

Publish clear route descriptions, input/output schemas, pricing and a working example. Add the [Bazaar discovery extension](/x402/facilitators/bazaar) so compatible agents can discover the resource. This helps an agent understand what it can buy; it does not guarantee search placement or traffic.

If a coding agent is implementing the integration, give it this guide and the [Build with AI](/x402/build-with-ai) entry point. They lead to framework-specific instructions and machine-readable documentation without changing the application's requirements.
