x402 API for AI models: pay per request in USDC
RunAPI accepts x402 payments on its per-call endpoints. An agent sends a normal request, receives a 402 quote, signs it with its wallet, and gets the result. No account, no API key, no prepaid credits.
curl -i -X POST "https://runapi.ai/api/v1/z_image/text_to_image" \ -H 'Content-Type: application/json' \ --data @request.json # HTTP/2 402# PAYMENT-REQUIRED: <base64 JSON with accepts: scheme, network, asset, amount, payTo>
- 155 resources payable with x402
- Base settlement network
- USDC payment asset
- 0 API keys required
Four steps from request to result
-
Send the request without a key
POST the same JSON body you would send with an API key, but leave out the Authorization header.
-
Read the 402 quote
RunAPI answers 402 with a PAYMENT-REQUIRED header that lists the exact amount, asset, network, and recipient. The quote is valid for 300 seconds.
-
Sign and retry
Your x402 v2 client signs an EIP-3009 authorization with the agent wallet and replays the request with a PAYMENT-SIGNATURE header.
-
Poll the task
RunAPI settles the payment, starts the task, and returns 200 with a PAYMENT-RESPONSE receipt and a poll_url for the result.
What to know before you pay
No signup, no API key
The paying wallet is the only identity. There is no account to create, key to store, or balance to top up.
Gas-free USDC payments
The payer signs an EIP-3009 authorization and the Coinbase CDP facilitator submits the transfer, so the wallet needs USDC but no ETH.
Getting the result
Most media tasks finish asynchronously. The 200 response includes a poll_url with a read-only task access token. The token opens that one task and nothing else, and it stays valid for 30 days after the task finishes.
If a task fails
x402 has no built-in refunds. When a paid task ends in a failed state, RunAPI records a refund obligation for the full amount it received. An operator then sends that amount back to the paying wallet in a separate USDC transfer; the refund is not automatic.
Which endpoints qualify
x402 works on REST endpoints with a fixed per-call price. Models billed by tokens, seconds, or characters, including the LLM endpoints, still need an API key and credits. The MCP server does not take x402 payments.
API keys still work
x402 is an extra way to pay. Requests that send a valid API key keep using account credits exactly as before, and a request with an invalid key gets a 401 instead of a payment quote.
What the exchange looks like
Hand the response to any x402 v2 client connected to the agent wallet. The client handles signing and the retry:
request = {method: "POST", url: task_url, json: payload}response = x402_client.send(request, wallet: agent_wallet)# The x402 v2 client reads PAYMENT-REQUIRED, signs an EIP-3009# authorization, and replays the request with PAYMENT-SIGNATURE.response.status # => 200response.headers["PAYMENT-RESPONSE"] # settlement receiptresponse.json["poll_url"] # read-only task result URL
Example prices
The lowest per-call price for a few models that accept x402 today. Prices come from the live catalog, and every 402 quote states the exact amount for that request.
| Model | Endpoint | Price per call |
|---|---|---|
| Z Image Text to image z-image | POST /api/v1/z_image/text_to_image | $0.01 |
| Flux Text to image flux-2-klein | POST /api/v1/flux/text_to_image | $0.03 |
| Suno Stitch audio suno-v4 | POST /api/v1/suno/stitch_audio | $0.01 |
| Suno Stitch audio suno-v4.5 | POST /api/v1/suno/stitch_audio | $0.01 |
| Recraft Upscale image recraft-crisp-upscale | POST /api/v1/recraft/upscale_image | $0.01 |
| Recraft Remove background recraft-remove-background | POST /api/v1/recraft/remove_background | $0.01 |
Payment details
RunAPI follows the x402 v2 exact scheme and only accepts the values below. Anything else is rejected before RunAPI asks the facilitator to settle.
| Network | Base mainnet (eip155:8453) |
|---|---|
| Asset | USDC, contract 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, 6 decimals |
| Facilitator | Coinbase CDP |
| Authorization | EIP-3009, so the payer needs USDC but no ETH for gas |
| Limit | up to 10 USDC per request; quotes expire after 300 seconds |
x402 FAQ
What is x402?
x402 is an open payment protocol built on the HTTP 402 Payment Required status code. A server replies 402 with payment requirements, the client pays with a signed stablecoin authorization, and the request is retried. It is maintained by the x402 Foundation.
Do I need a RunAPI account to pay with x402?
No. The wallet that pays is the identity. RunAPI creates an internal wallet profile only after the first successful settlement and never asks for an email or API key.
What does the x402 facilitator do?
The facilitator verifies the signed payment and submits the USDC transfer on Base. RunAPI uses the Coinbase CDP facilitator, so the payer does not need to pay gas.
How much does a request cost?
Each endpoint has a fixed per-call price. The 402 quote shows the exact USDC amount before you sign, and the model catalog lists current prices.
Can agents discover RunAPI through the x402 Bazaar?
Each 402 quote includes a Bazaar discovery declaration with the input schema and an example, so x402 clients and directories can list the endpoint.
What happens if I pay and the request fails before a task starts?
A request that fails validation is rejected before payment is settled, so nothing is charged. Once payment settles, a task that later fails gets a full refund obligation.
Related pages
Let your agent pay for its own API calls
Browse the models, pick a per-call endpoint, and send your first request without a key.