AI agents

Agent payments (HTTP 402)

How AI agents pay for your API per request with HTTP 402 and x402 v2: the request flow, the solverr and exact schemes, and route minimums on small prices.

On this page

AI agents pay for your API per request, without an account or card, through x402 v2, a standard for HTTP 402 Payment Required. Solverr adds its own payment scheme, solverr: the agent pays with a coin it holds, and NEAR Intents delivers the coin you receive to your payout wallet. Your paywall can also offer the standard exact scheme for USDC on Base, Ethereum, Arbitrum, Polygon or Avalanche, as Paywall middleware explains.

How a paid request works

  1. The agent calls your endpoint, for example GET /premium, without paying.
  2. Your endpoint, protected by @solverr/x402, creates a Solverr invoice for the price and answers 402 with a PAYMENT-REQUIRED header. The header lists the invoice and the URLs to pay it.
  3. The agent checks the payment against its own spending limits.
  4. The agent asks for a deposit address for a coin it holds, sends the exact amount, and reports the transaction.
  5. NEAR Intents converts the payment and delivers the coin you receive to your payout wallet, and the invoice becomes paid.
  6. The agent calls your endpoint again with a PAYMENT-SIGNATURE header that names the paid invoice.
  7. Your endpoint checks with Solverr that the invoice is paid, matches this method, path and price, and was not used before, then claims it for this request and runs your handler. Only when your handler answers below 400 does it redeem the invoice and return your handler's response with a PAYMENT-RESPONSE header. When your handler throws or answers 400 or higher, the invoice stays unused and the agent can send it again.

Each payment pays for exactly one request. A second request needs a new payment or prepaid credits.

Small prices and route minimums

Per-request prices are usually a few cents, and a NEAR Intents route can have a temporary minimum above the price that changes without notice. The agent kit tries the coin you receive first, then the same coin on other chains, then other stablecoins, and moves on each time a route is refused.

When an agent makes many small calls, credits replace one on-chain payment per request with a single prepaid balance.

Next steps