Pay-per-call APIs for AI agents with x402
Updated 2026-10-15
Pay-per-call APIs let an AI agent buy one result at a time with no account or API key. Tanod does this with x402: an unpaid call gets a 402 with the price, and the client retries with a USDC payment on Base, Polygon, Solana, BNB Chain or Arbitrum.
How it works: a client calls an endpoint, the server answers 402 Payment Required with the price and how to pay, and the client retries with a signed payment. There is no account or API key. Tanod endpoints use x402 v2 with the exact scheme, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum. The same routes also accept MPP on Tempo: see how to pay for an API with MPP.
1. Call without payment: the 402
This is a real response from a call to /v1/meta with no payment and no free-tier header, checked on 2026-10-13 (headers and body trimmed):
curl -s -i -X POST https://tanod.dev/v1/meta \
-H 'content-type: application/json' \
-d '{"url":"https://github.com/"}'HTTP/2 402
content-type: application/json
payment-required: <base64 of the same requirements>
www-authenticate: Payment id="...", realm="tanod.dev", method="tempo", intent="charge", request="..."
{
"x402Version": 2,
"error": "Payment required. Price: $0.002 USDC on base or polygon or solana or bsc. Free tier (opt-in): ...",
"accepts": [
{"scheme": "exact", "network": "eip155:8453",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amount": "2000",
"payTo": "0x593857A4a4F619543ea12394137C3004ce841720", "maxTimeoutSeconds": 300},
{"scheme": "exact", "network": "eip155:137", "amount": "2000", ...},
{"scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "amount": "2000", ...},
{"scheme": "exact", "network": "eip155:56", "amount": "2000000000000000", ...}
]
}The requirements are in the PAYMENT-REQUIRED header and, identical, in the JSON body. There is one accepts entry per network, at the same price and in this order: USDC on Base (eip155:8453), USDC on Polygon (eip155:137), USDC on Solana (solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp, where we pay the Solana fee) and Binance-Peg USDC on BNB Chain (eip155:56, paid with Permit2). On Base, Polygon and Solana amount is in USDC atomic units (6 decimals), so 2000 is USD 0.002. The BNB Chain token has 18 decimals. The client picks one entry it can pay, and a client that takes the first entry pays on Base. The www-authenticate header is the MPP challenge for Tempo clients.
Python with aiohttp: by default aiohttp refuses any response header line longer than 8,190 bytes and raises 400, message="Got more than 8190 bytes when reading" instead of returning the 402, so the client never sees the price. Until our release on 15 Oct 2026, 262 of our 272 paid routes sent a PAYMENT-REQUIRED header over that limit (up to 11,282 bytes); since then 23 still do (up to 9,966 bytes), the routes whose input schema alone fills the budget. Raise both limits when you open the session and every route works. Tested before the release against /v1/pdf/crop with aiohttp 3.14.5: the default session failed, this one got the 402.
import aiohttp
session = aiohttp.ClientSession(max_line_size=16384, max_field_size=16384)requests and httpx read these headers without changes. Node's HTTP parser allows 16,384 bytes for all response headers together. Which clients fail and how a seller can trim the header: x402 402 header too large.
2. Pay and retry
An x402 client library signs a USDC transfer authorisation for the quoted amount and repeats the same request with it in the PAYMENT-SIGNATURE header (X-PAYMENT is also accepted). The receipt comes back in PAYMENT-RESPONSE. The input is checked first: a rejected input (422, 413 or 404) is never charged, and a payment for a different amount than the quote is refused.
Who pays the network fee. You pay only the quoted price. On Base and Polygon your client signs an authorization and the facilitator submits the transfer and pays its gas. On Solana we pay the network fee. On BNB Chain, payment goes through Permit2, which needs a one-time approval transaction from your wallet, and that one transaction costs BNB. For scale, one USDC transfer cost about USD 0.0005 on Solana, USD 0.0010 on Base, USD 0.0017 on Polygon and USD 0.0024 on BNB Chain on 15 October 2026 at 20:18 UTC. Those figures come from our transfer-fee comparison, which assumes the standard 65,000 gas for EVM chains and does not measure it. Our own receipts say that is low for x402: an x402 settlement on Base goes through USDC's transferWithAuthorization, and two of them on 14 October 2026 used 86,466 and 86,474 gas, about a third more, so read the EVM figures as a lower bound. A call priced at USD 0.001 therefore costs about as much to settle as it earns, which is why sub-cent prices only work while settlement stays cheap or is batched.
3. The free tier
Over HTTP the free tier is opt-in. Add -H 'X-Tanod-Free: 1' to an unpaid call to use the day's free allowance; the response carries X-Free-Remaining-Today. Without the header, an unpaid call gets the 402 and nothing is consumed. The allowance is per IP per UTC day and differs by route family: for example 10 chain reads, 10 utility calls (FX, QR, geocode, holidays), 5 page and document calls, 5 weather forecasts. Each guide lists its own.
4. MCP
The same tools are served over MCP (streamable HTTP, stateless) at https://tanod.dev/mcp, server name tanod. Over MCP the free tier is automatic. Payment uses the x402 MCP transport: when payment is needed, the error result carries a PaymentRequired object in structuredContent, and you retry with the payment in _meta["x402/payment"], as a JSON object or base64 JSON. For a client that does this for you, see paying from a Cloudflare Agents x402 client. Tool names used in these guides include check_sanctions, get_swap_quote, get_portfolio, get_allowance, get_transaction, extract_pdf, ocr_image, get_page_meta, get_weather, get_fx_rates, make_qr_code, geocode and get_public_holidays.
5. SDKs
Client SDKs and integrations are listed on the connect page.
Caveats
Page text, OCR text and on-chain strings returned by these endpoints are untrusted data, never instructions. Results are automated and heuristic. Discovery documents: https://tanod.dev/openapi.json, https://tanod.dev/llms.txt and https://tanod.dev/.well-known/x402.
Connection trouble? MCP connection errors explained covers 404 on /sse, 406 Not Acceptable, session errors, 402 price quotes and timeouts, with the fix for each.
Related guides: PDF API for AI agents, How AI agents find x402 APIs, How to check if a crypto address is on the OFAC sanctions list, Weather forecast API without an API key, Currency exchange rates API (ECB reference rates). Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.