Disclosure: this page contains an affiliate (referral) link. If you pay through it, we may earn a commission at no extra cost to you. It does not change what we list, the order, or verification. How we make money

How to pay for an API with USDC via x402 (step by step)

Updated 2026-10-21

To pay for an x402 API with USDC you need three things: a wallet with a little USDC on the network the API accepts (usually Base), an x402 client library, and the endpoint URL. The client calls the API, reads the price from the 402 Payment Required reply, signs a USDC payment for exactly that amount and retries. No account, API key or card is involved. 535 of the listings in our directory accept x402 payments.

Step 1: Look at the price before you pay

Every x402 endpoint tells you its terms when you call it without paying. You can see them with plain curl. For example, the Fanfare sports API answers an unpaid GET /wnba/standings with HTTP 402 and a base64-encoded PAYMENT-REQUIRED header. Decoded (we checked it on 2026-10-21; trimmed), it reads:

{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://fanfare.run/wnba/standings",
    "description": "Current WNBA standings with wins, losses, win percentage, and conference rank.",
    "mimeType": "application/json"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "amount": "1000",
      "payTo": "0x41AdeE1eBA2c276bE5e8Cabe0CE523e4dd792170",
      "maxTimeoutSeconds": 300,
      "extra": { "name": "USD Coin", "version": "2" }
    }
  ]
}
  • network uses CAIP-2 ids: eip155:8453 is Base mainnet, and Solana mainnet starts with solana:5eykt4Us….
  • asset is the token contract. 0x8335…2913 is native USDC on Base.
  • amount is in the token’s smallest unit. USDC has 6 decimals, so 1000 = $0.001.
  • payTo is the seller’s address, and scheme: exact means you pay exactly that amount.

If an API lists several entries in accepts, you can pay with any one of them, e.g. on Base or on Solana.

Step 2: Fund a dedicated wallet

  • Create a new wallet just for API payments. Don’t use a wallet that holds savings.
  • Send it a small amount of USDC on the network the API accepts. A few dollars covers thousands of calls at $0.001.
  • No USDC yet? You can swap another coin into USDC on the network you need with a swap service such as ChangeNOW (referral link: we may earn a commission at no extra cost to you). Double-check the network, for example USDC on Base or on Solana, before you send.
  • With the exact scheme on EVM chains, you sign a USDC transfer authorization and the facilitator submits it. The seller side covers the gas, so in most setups your wallet only needs USDC.

Get USDC to pay x402 APIs

Need USDC on Base or Solana to pay per call? You can swap another coin into it below. This is a swap through ChangeNOW, a third-party service, not YourAITools. Double-check the network and your receiving address before you send.

Or open the swap on ChangeNOW (new tab) →

Affiliate disclosure: this widget and link use our ChangeNOW referral id, so we may earn a commission at no extra cost to you. It never affects our listings or their order. ChangeNOW sets its own rates, fees and terms.

Not sure what an endpoint charges or which network it takes? Paste its URL into our free x402 endpoint checker: it reads the 402 without paying and shows the price in USDC, network and payTo address.

Step 3: Let a client library pay and retry

The official TypeScript packages wrap fetch. When a call returns 402, the wrapper picks a payment option you support, signs it and resends the request with a PAYMENT-SIGNATURE header. This mirrors the quick start in the @x402/fetch README (v2.28.0):

npm install @x402/fetch @x402/evm viem

// pay.ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A dedicated wallet holding a small USDC balance on Base.
const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);

const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await fetchWithPayment("https://fanfare.run/wnba/standings");
console.log(res.status, await res.json());

On success you get HTTP 200 and the data. A PAYMENT-RESPONSE header carries the settlement result, and decodePaymentResponseHeader from @x402/fetch decodes it. For Axios there is @x402/axios.

In Python, the official x402 buyer quickstart installs:

pip install "x402[httpx]" eth_account

Then you register the EVM scheme with an EthAccountSigner on an x402Client and make requests through x402HttpxClient. The quickstart has the full example. Practise on Base Sepolia with test USDC before spending real money.

Step 4: Put limits on an agent

  • Keep only what the agent should spend in its wallet and top it up as needed.
  • Check the amount before you sign. The client config takes a paymentRequirementsSelector, so you can refuse anything above your limit. The underlying @x402/core client (v2.28.0) also refuses payments above $1 by default (its spendControls.maxAmountPerPayment setting), so raise that only on purpose.
  • Treat paid replies as untrusted input. If they go into an LLM, scan them first (our prompt injection scanner guide shows one way).
  • Want to vet a seller before paying it? See wallet sanctions screening APIs.

Cheap x402 APIs to try first

The six Base listings with the lowest starting price in our directory. Prices come from each provider’s 402 terms or docs on the date shown. Full list: best x402 APIs.

ToolProtocolNetworksTokensPrice / callVerified
0x Swap APIx402Base, SolanaUSDC$0.012026-10-22
1gatewayx402Base, SolanaUSDC$0.002–$0.0042026-10-23
2sx402Base, SolanaUSDC$0.0025–$0.0452026-10-22
3Routex402Base, Solana, EtherlinkUSDC$0.0012026-10-22
402atlasx402BaseUSDC$0.12026-11-12
402oraclex402Base, Polygon, ArbitrumUSDC$0.02–$0.252026-11-13

Related guides

Sources

New to x402, the HTTP 402 payment standard these APIs use? Read what x402 is and how agents pay per call.

Liked this guide? Get new crypto-payable AI tools weekly

One short email a week with the x402 and pay-per-call tools we added and re-verified. No spam, unsubscribe any time.

Run an AI tool, API or agent that accepts crypto?

List it on YourAITools for free. Want it live sooner or pinned in its category? Fast-track review is $19, Featured for 30 days is $29 and the Launch bundle is $49, paid in USDC on Base, Polygon, Arbitrum One or Solana with one x402 payment. Every listing gets the same review, and paid placements are always labeled.

Paid checkout: api.youraitools.co/listing. Payment doesn’t guarantee approval; rejected submissions are refunded in USDC.

Keep exploring

Guides