x402 Payments for AI Agents: How They Work

How x402 lets an AI agent pay for an API call in USDC on Base: the HTTP 402 flow, safe retries, payer wallets and spending limits.

Published Jul 6, 2026Updated 7 min read

Then €19/month$20/month. Card required. Cancel before your trial ends to avoid charges.

Short answer

x402 is an open standard for paying for a web request. The server answers with HTTP 402 Payment Required and a price. The AI agent pays in USDC and sends the same request again with proof of payment. Stakao, which automates Bittensor staking, uses x402 for one product: an allocation analysis that an agent can buy for 3 USDC on Base, with no card, no account and no checkout page.

What x402 is and why agents use it

x402 puts payment inside an ordinary web request. It reuses HTTP 402 Payment Required, a status code the web set aside for exactly this job.

The idea fits in four moves. The agent asks for something. The server answers 402 and names the price. The agent pays and asks again, this time with proof of payment. The server delivers the result.

An AI agent works through code, not a browser. It cannot fill in a card form or sign up for an account, so x402 lets it pay inside the request it already makes. The payment is in USDC, a token pegged to the US dollar, so the price stays steady.

How an agent pays Stakao with x402

The agent pays after it knows what it is buying, and before Stakao does the work. Everything it needs to decide is free to read.

There are two paid calls. A wallet-specific analysis needs a free preflight first. A general snapshot of the latest reference analysis is a single call, with no wallet and no preflight. These are the steps for the wallet-specific analysis:

  1. 01Read the free catalog and choose the strategy to analyze.
  2. 02Check the free reference status. It reports how fresh the latest reference analysis is.
  3. 03Run the free preflight for the wallet. Stakao checks the wallet and returns a client_request_id that it generated.
  4. 04Send the paid request with that id. Stakao answers HTTP 402 and states the payment requirements: 3 USDC on Base.
  5. 05Pay from the payer wallet.
  6. 06Send the exact same request again, with the proof of payment attached.
  7. 07Stakao verifies the payment, stores the request and returns the analysis as compact JSON.

Safe retries: one payment, one result

Agents retry. Networks fail. A paid API has to answer a repeated request the same way every time, or the agent pays for the confusion.

What the agent doesWhat Stakao answers
Repeats the same request with the same client_request_idThe same result, without running a second analysis.
Reuses a client_request_id with a different requestHTTP 409. The id already belongs to another request.
Skips the preflight, or sends an id Stakao does not knowHTTP 428. No payment is requested. Run the preflight first.
Calls while the latest reference analysis is out of dateHTTP 503 (reference_unavailable). Stakao checks freshness before it asks for payment, so retry later.

Why 3 USDC on Base

USDC on Base is the simplest rail for an agent today: a dollar-priced token on a low-fee network, with no bank and no card.

Stakao charges 3 USDC for each paid analysis. Payments in TAO or in subnet tokens could be added later, but they need more work on liquidity, settlement and accounting, so Stakao started with the stablecoin.

People who do not pay with x402 can buy a one-time TAO wallet analysis for EUR 2.90 through a normal checkout. The wallet must hold at least 3 TAO.

Who owns the wallet that pays

In a clean setup, a person or a company owns the payer wallet. The agent can spend only under the rules you set.

The payer wallet is a normal EVM wallet that holds USDC on Base. Stakao receives the payment at its own wallet and never needs your payer key.

Treat an agent wallet like an API key with money attached: a small balance, clear limits and a plan to replace it.

WalletWho controls itWhat it does
Payer walletYou, your team or your agent platformPays the 3 USDC x402 requirement for one analysis.
Merchant walletStakaoReceives the USDC payment.
Bittensor walletYouThe wallet being analyzed. It does not pay x402, and a paid call gives Stakao no access to it.

Keep agent spending small and logged

Autonomous does not mean unlimited. The safest setup is a small funded wallet with a cap on each call and on each day.

  • Fund the payer wallet with only what the agent needs for a short stretch.
  • Cap what the agent can spend per call and per day, in your agent code or in your wallet policy.
  • Use one wallet for production and separate wallets for tests.
  • Never commit a private key. Keep it where your agent runs, in a secrets store or in a local file that git ignores.
  • Log the request id, the endpoint, the amount and the result of every paid call. The client_request_id that Stakao issues makes retries easy to audit.

What Stakao sees and what it returns

Stakao sees the paid request and the proof of payment. It never holds the payer wallet and gets no control over the wallet being analyzed.

The request carries the Bittensor wallet address to analyze and the catalog item. Stakao verifies the payment and stores the request, so a retry gets the same answer.

The result is information. It is not a transaction, a staking permission or a strategy activation, and Stakao never stakes, unstakes or transfers TAO because of a paid call. It is not financial advice, and staking and subnet tokens carry risk.

To act on an analysis, a person connects a wallet in the Stakao app and signs a staking-only permission. That permission lets Stakao stake and unstake but never transfer TAO, and it can be revoked at any time.

FAQ

What is x402?

x402 is an open standard for paying for web requests. A server answers with HTTP 402 Payment Required and a price, the client pays, and the client repeats the request with proof of payment. Stakao uses it so an AI agent can buy an analysis without a card or a checkout page.

How much does a paid call cost, and in which token?

Each paid analysis costs 3 USDC, paid on Base. Reading the catalog, the docs, the reference status and the preflight is free.

Does the agent know what it gets before it pays?

Yes. The catalog, the OpenAPI file, the pricing and the safety documentation are free to read, and the 402 response states the price. The paid unit is one analysis for a valid request.

What happens if the agent retries a paid request?

Stakao ties each paid request to a client_request_id that it generates, plus a fingerprint of the request. An identical retry returns the same result instead of running a second analysis. A retry that changes the request gets a 409 error.

Do I need to give Stakao my payer private key?

No. Stakao never receives it. The key stays where your agent runs: in a secrets store, or in a local file that git ignores while you test.

Can the payer wallet be the same as my TAO staking wallet?

Usually not. x402 payments come from an EVM wallet that holds USDC on Base. The wallet that is analyzed is a Bittensor wallet address.

Does Stakao take custody of the agent wallet?

No. The payer wallet belongs to you or to your agent platform. Stakao receives the payment at its own wallet and returns the analysis.

Does a paid call stake or move my TAO?

No. A paid call returns information only. It never activates a strategy, signs a transaction or touches your TAO. To act on an analysis, you connect a wallet in the Stakao app and sign a staking-only permission yourself, which you can revoke at any time.

Try the x402 flow

The catalog, the reference status and the preflight are free. Your agent pays 3 USDC only when it asks for the analysis.

Read the x402 docs

Want Stakao to run a staking strategy for your own wallet instead? See the strategies · How Stakao works · Pricing

Related pages

Sources

Agent entrypoints

These endpoints are free to read. Only the analysis call is paid: 3 USDC through x402 on Base. It returns information only and never stakes, unstakes or transfers TAO.

Put your staking routine on autopilot.

  • Automated staking with built-in risk management.
  • Your TAO stays in your wallet.
  • One permission you can revoke.

Then €19/month$20/month. Card required. Cancel before your trial ends to avoid charges.

Staking TAO can lose value. Built-in risk management is designed to limit losses but cannot remove them. Past results do not predict future results.

Activate AI Agent
  1. Strategy
  2. Wallet
  3. Permission
Strategy Configuration
SelectionAI ranking
Risk managementBuilt-in risk management on every position
Wallet accessStaking-only permission
Read-only preview
Can do

Stakao can stake and unstake for you

  • Stake for the strategy you choose.
  • Unstake positions when the strategy calls for it.
  • Keep idle TAO earning on Root.
Cannot do

Stakao cannot transfer your TAO

  • Transfer funds out of your wallet.
  • Read or hold your private keys.
  • Keep access after you revoke the permission.

Preview of the activation screen. No wallet data.