Sell your API per call.

Give your API one AIPayGen address. AI agents pay a few thousandths of a dollar per call, in USDC, straight to your wallet. No payment code, no monthly fee, and we never hold the money.

  1. Register it. Your API's address, a price and your wallet on Base. One request.
  2. Prove the domain is yours. One DNS record or one small file. Nothing is sold before this.
  3. Share your gateway address. Each paid call reaches your API; the USDC reaches your wallet.

Put your API behind the gateway

Register once and get a pay-per-call address. Until you prove the domain is yours (step 3) nothing is sold through it: calls to it answer 403 and nobody is charged. After that we quote unpaid calls, check each payment, forward the request, and settle only when your API answers 2xx. A failed call costs the buyer nothing.

1. Create your key

The key (it starts with apg_) is your login for everything below. Save it: it is shown once.

curl -X POST https://aipaygen.com/v1/keys

Then export AIPAYGEN_KEY=apg_.... Free, no card. A key holds up to 10 routes.

2. Register your API

Code6 lines
curl -X POST https://aipaygen.com/v1/gateway \
  -H "Authorization: Bearer $AIPAYGEN_KEY" -H "content-type: application/json" \
  -d '{"name":"Weather API","upstream":"https://api.example.com/v1","price_usd":0.002,"pay_to":"0xYourWallet"}'

# -> {"id":"3f9a1c0b7d2e","url":"https://aipaygen.com/g/3f9a1c0b7d2e","gateway_secret":"...","verify":{...},...}
# After you prove the domain (step 3), buyers call https://aipaygen.com/g/3f9a1c0b7d2e/forecast?city=Austin and pay per call.

upstream is your API's HTTPS address (redirects are not followed); whatever follows the route address is appended to it. pay_to is your wallet on Base. Add "method":"GET" or "POST" to take only that method (the default takes any).

3. Prove the domain is yours

The answer to step 2 has a verify block with your token. Do any one of these, then ask us to check:

Code2 lines
curl -X POST https://aipaygen.com/v1/gateway/3f9a1c0b7d2e/verify -H "Authorization: Bearer $AIPAYGEN_KEY"
# -> 200 once a check passes; otherwise 409 SITE_NOT_VERIFIED, listing every way to verify.

Use your API's own host in place of api.example.com. Sites running one of our snippets or plugins verify themselves; an API normally uses one of the two lines above.

4. Make the first paid call

Call your gateway address the way a buyer would. An unpaid call answers 402 with your price and the wallet it pays; any x402 client pays it and your API answers.

Code3 lines
curl -i "https://aipaygen.com/g/3f9a1c0b7d2e/forecast?city=Austin"
# -> 402 Payment Required, with your price (for example 2000 = $0.002 USDC) and your wallet.
# Before step 3 it answers 403 SITE_NOT_VERIFIED instead, and nobody is charged.

Once the domain is verified and your address answers 2xx, the route is listed in the marketplace, so agents can find it.

Let only paid calls through

Every forwarded request carries x-aipaygen-gateway-secret. Wrap each paid function so calls without it are turned away and pointed to your gateway URL.

CodePython or Node
import hmac, os
from functools import wraps
from fastapi import FastAPI, HTTPException, Request

SECRET = os.environ["AIPAYGEN_SECRET"]          # gateway_secret from registering
PAY_URL = "https://aipaygen.com/g/" + os.environ["AIPAYGEN_ROUTE"]

def paid(fn):
    """Only calls that came through the AIPayGen gateway, and were paid, reach fn."""
    @wraps(fn)
    async def wrapper(request: Request, *args, **kwargs):
        given = request.headers.get("x-aipaygen-gateway-secret", "")
        if not hmac.compare_digest(given.encode(), SECRET.encode()):
            raise HTTPException(402, f"Pay per call at {PAY_URL}{request.url.path}")
        return await fn(request, *args, **kwargs)
    return wrapper

app = FastAPI()

@app.get("/forecast")
@paid
async def forecast(request: Request, city: str):
    return {"city": city, "forecast": "sunny"}

Set AIPAYGEN_SECRET to the gateway_secret from registering and AIPAYGEN_ROUTE to your route id. List routes and earnings with GET https://aipaygen.com/v1/gateway; free, up to 10 routes per key.

Signed up on pay-per-crawl already?

You don't move anything. A pay-per-crawl signup is a gateway route: the same /g/<id> address, gateway secret and key as above. To sell calls through it:

  1. Start charging. A route set to "Nobody yet: report only" sells nothing: a buyer's call is refused. On your private report page, open Settings, choose Every AI crawler, add your wallet on Base and a price (it applies per call), and type your gateway secret. Or with your key: PATCH https://aipaygen.com/v1/gateway/<id> and {"charge_mode":"all","pay_to":"0x...","price_usd":0.002}.
  2. Prove the domain is yours. Step 3 above. Your report page lists the same options and checks for you.
  3. Make the first paid call at https://aipaygen.com/g/<id>/<path>: step 4 above. What follows the id is appended to the address you signed up.

What can't change on that route

Pay-per-crawl routes take GET only, and only your site's origin (no /v1 base path). A route's method can't be edited, and its address can only move between example.com and www.example.com. If your API needs POST or a base path, register a new route with step 2 ("method":"POST", or leave it out for any), and delete the old one with DELETE https://aipaygen.com/v1/gateway/<id> if you already hold 10. The report page talks about pages and crawlers; for an API read those as calls.

Already use x402? Use our facilitator

A free, gasless facilitator for USDC on Base Sepolia (testnet) and Base. Point your server at one URL.

Get a key

Settling costs us gas, so it needs a key. That's also how we count your volume. Testnet (Base Sepolia) settles with any AIPayGen key. Mainnet (Base) settles only for keys that bought credit or own a site-verified gateway route, up to 500 settlements a day across all merchants and 50 per key; past that, use another facilitator until 00:00 UTC.

curl -X POST https://aipaygen.com/v1/keys

Use the facilitator URL

Code9 lines
import { HTTPFacilitatorClient } from "@x402/core/server";

// Verify is open; settle needs your AIPayGen key (mainnet: one that bought credit or owns a verified site).
const auth = { Authorization: `Bearer ${process.env.AIPAYGEN_KEY}` };
const facilitator = new HTTPFacilitatorClient({
  url: "https://aipaygen.com/facilitator",
  createAuthHeaders: async () => ({ verify: auth, settle: auth, supported: {} }),
});
// Pass `facilitator` to x402ResourceServer (or your framework's paymentMiddleware) as usual.

Check what we support: curl https://aipaygen.com/facilitator/supported, or the live status.

How it works

Gasless and freeWe submit the payer's signed transfer and pay the network fee. No cut, no monthly fee.
Non-custodialUSDC moves from the payer straight to your wallet in one transaction. We only relay it.
Fee wallet failoverIf our own fee wallet can't pay gas, an eligible mainnet settlement goes to PayAI or Coinbase CDP automatically. Refusals (a key that isn't eligible, the daily cap, a bad payment) are never sent elsewhere.
Standard x402 v2The exact scheme with /verify, /settle and /supported. Works with the official SDKs.

Questions

How do buyers find my API?

Agents search the AIPayGen marketplace through our MCP server and API. It indexes the public x402 directories (Coinbase CDP Bazaar and PayAI), so endpoints listed there show up here too. Your own route is listed once its domain is verified and its address answers 2xx. Selling through an agent? List its A2A card free with POST https://aipaygen.com/v1/register_agent.

Can someone call my API without paying?

Not if your API checks the gateway secret, as in the code above. The secret is compared in constant time, and nothing about payments runs in your server.

What are the limits?

Testnet (Base Sepolia) settles with any AIPayGen key. Mainnet (Base) settles only for keys that bought credit or own a site-verified gateway route, up to 500 settlements a day across all merchants and 50 per key; past that, use another facilitator until 00:00 UTC. Settlements are also rate limited per key. Only USDC with the exact scheme is supported today. Testnet is a good way to try it first.

I run a website, not an API.

Pay-per-crawl uses the same gateway to charge AI crawlers per page while people browse free.