Pay with x402
Call any endpoint without an account or API key, and pay per request in USDC on Base with x402, the open HTTP payment protocol for agents.
Base URL: https://x402.apidirect.io
How it works
- Call an endpoint with no auth. You get HTTP
402 Payment Requiredand aPAYMENT-REQUIREDheader (base64 JSON, x402 version 2) with the exact price. - Sign a USDC payment for that amount and send the identical request again with it in the
PAYMENT-SIGNATUREheader. - You get the data, plus a
PAYMENT-RESPONSEheader with the receipt.
An x402 client library does all three steps for you.
curl -i "https://x402.apidirect.io/v1/reddit/posts?query=AI"
# HTTP/2 402
# payment-required: eyJ4NDAyVmVyc2lvbiI6Mi...
# pip install "x402[evm,requests,extensions]"
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm.exact.register import register_exact_evm_client
from x402.mechanisms.evm.signers import EthAccountSigner
from x402.mechanisms.evm.upto import UptoEvmClientScheme
wallet = Account.from_key("0x<your wallet's private key>")
client = x402ClientSync()
register_exact_evm_client(client, wallet) # single-page calls
client.register("eip155:*", UptoEvmClientScheme(EthAccountSigner(wallet))) # multi-page calls
session = x402_requests(client)
response = session.get("https://x402.apidirect.io/v1/reddit/posts", params={"query": "AI"})
print(response.json())
Pricing
Each call costs the endpoint’s price plus $0.001, which covers settling the payment on-chain. You are charged exactly what the same call costs with an API key:
- Multi-page calls (
pages=5) authorize the price of every page, and are charged only for the pages returned. They use theuptoscheme, which pays through Permit2: your wallet needs a one-time Permit2 approval for USDC, or a client that signs the gasless approval the 402 offers. - Failed calls are not charged. If your payment cannot be collected, the response is withheld and nothing is charged.
- A lookup that found nothing (a not-found, a private account) is charged one unit, as with an API key, because the data source was queried.
There is no free tier over x402. For a monthly free tier and volume use, sign up for an API key, which also works on x402.apidirect.io.
Discovery
Agents can find and price every endpoint without calling it:
https://x402.apidirect.io/llms.txt: how to pay, and every endpoint with its pricehttps://x402.apidirect.io/openapi.json: the OpenAPI spec, with each operation’s price inx-payment-infohttps://x402.apidirect.io/.well-known/x402: the list of paid resources
Limits
- Concurrency limits apply per paying wallet.
- Batch requests are not available over x402.
- Official x402 clients refuse any single payment above $1 by default. Most calls cost a fraction of a cent, but one asking for many pages can cost more. Raise the limit in your client:
client.set_spend_controls({"max_amount_per_payment": "$10"}).