What you will do
Pay an AI agent in USDC on Base, either to use a service it sells or to send it funds directly. No card, no checkout page, no account with the agent. If you are calling a paid service, the payment happens inside a normal request. If you are sending money directly, it is a USDC transfer to the agent's wallet. Both settle on chain in seconds.
This is the payer's side of the story. The agent's side, receiving and charging, is in how-to-receive-payments-as-ai-agent. The payment API product page is the broader reference.
Two ways to pay an agent
Separate these, because they suit different situations.
The first is paying to use a service. The agent exposes a paid endpoint that answers 402 Payment Required with a price. You call it, pay the quoted amount, and get the result. This is the common case when your system or your own agent consumes what another agent sells, and it is the one to reach for by default, because the price and the proof of payment are handled for you.
The second is paying directly. You send USDC to the agent's wallet address with no request involved: a tip, a payout, a transfer you decided to make for your own reasons. Use this when the decision to pay was made outside any service call, not when you are buying a per-call result.
Most integrations use the first. Direct transfers are for the cases that are not a purchase.
Prerequisites
- The agent's identifier: either the URL of its paid endpoint, or its public profile at
wallet.blockchain0x.com/a/{slug}where you find its wallet address. - To pay through the x402 client: a Blockchain0x account and a funded wallet of your own, plus a
sk_test_key for testing. - Node 18 or newer. The SDK targets
>=18.
export B0X_API_KEY=sk_test_... # your own funded agent or wallet, sk_test_ -> Base SepoliaPay by calling its service
When the agent sells a per-call service, pay it by calling the endpoint through the x402 client. The client turns the agent's 402 into a settled payment and a retried request.
import { createClient } from "@blockchain0x/node";
import { createX402Client } from "@blockchain0x/x402/client";
const sdk = createClient({ apiKey: process.env.B0X_API_KEY! });
const fetchWithPay = createX402Client({ sdk });
// The agent quotes its price in the 402. The client settles in USDC and retries.
const res = await fetchWithPay("https://that-agent.example.com/agent/research", {
method: "POST",
body: JSON.stringify({ question: "..." }),
});
const answer = await res.text();You did not hardcode a price; the agent quoted it in the 402 and the client paid exactly that, bounded by your own wallet's spend limit. If the quoted amount is over your per-transaction cap, your wallet refuses it before paying, which is the protection working as intended.
Pay it directly
For a transfer that is not tied to a service call, send USDC to the agent's wallet address on Base. Get the address from the agent's public profile, confirm the network (Base mainnet for real value, Base Sepolia for testing), and send the USDC from your wallet of choice. There is no special API for this; it is a standard USDC transfer to the address.
Because a direct transfer has no 402 to quote the amount and no service to return a result, you own getting the details right: the correct address, the correct network, and the correct amount. Double-check all three before you send, because an on-chain transfer to the wrong address or network does not bounce back.
Check who you are paying
Before you pay an agent you do not already trust, look at its public profile. Paying an agent is paying an address, and an address alone tells you nothing about who controls it.
The profile at wallet.blockchain0x.com/a/{slug} shows the agent's wallet address and the identities its operator has verified: email, GitHub, and domain. A profile with domain verification tied to a company you recognize is a very different counterparty from a bare address with no badges. Match the address you are about to pay against the one on the verified profile. This is the agent-payment version of confirming a payee before a wire transfer, and it takes seconds. Skipping it is how money goes to the wrong place.
Your spend limit protects you
Paying through the x402 client is not a blank cheque, because your own wallet's spend limit applies to what you pay, not just to what you receive. The same per-transaction cap and period allowance that bound an agent's outbound spending bound yours when you are the payer.
This matters when you call an agent whose price you have not pinned. The agent quotes the amount in its 402, and if that amount is over your per-transaction cap, your wallet refuses to settle it before any USDC moves. So a misconfigured or hostile endpoint that quotes a huge price cannot drain you; it just gets a refused payment, and your call comes back as a non-2xx you can handle. Set a per-transaction cap that reflects the most you would willingly pay for a single call, and the limit turns "pay whatever it quotes" into "pay whatever it quotes, up to my ceiling". That one number is the difference between trusting every endpoint you call and trusting none of them more than you have to.
Confirm the payment landed
When you pay through the x402 client, the successful retried response is itself the confirmation: you got the result, so the payment cleared. That is usually all you need.
When you want an explicit record, for a direct transfer or for your own books, look the payment up by its transaction id:
const tx = await client.transactions.get("txn_...");
// the canonical record: status, amount, and identifiersFor a direct on-chain transfer, the transaction hash from your wallet is the receipt, viewable on a Base block explorer. Keep whichever identifier you get, the response, the transaction id, or the hash, so a payment is always traceable after the fact rather than something you have to trust happened.
Common pitfalls
Three traps on the payer side.
Paying a bare address with no identity check. An address is not a counterparty. Check the verified profile before paying an agent you do not control, every time.
Wrong network on a direct transfer. USDC sent on the wrong chain does not arrive and does not bounce. Confirm Base mainnet versus Base Sepolia before you send.
Assuming a 402 means something is broken. A 402 from an agent is not an error; it is the price tag. The x402 client is meant to answer it. If you are calling an agent's paid service with plain fetch and treating the 402 as a failure, switch to fetchWithPay.
What to ship today
If you are consuming an agent's service, wire fetchWithPay and make one paid call on testnet to watch the 402 settle. If you are sending a direct transfer, confirm the address, network, and amount against the agent's verified profile, then send a small test amount first. Either way, keep the receipt. Production pricing for your own wallet is on the pricing page.