How to charge per API call

To charge per API call you need three things: a way to identify or pay for each call, a counter you trust, and a way to collect the money. The usual options are metered billing with API keys and a monthly invoice, prepaid credits, an API marketplace that bills for you, or x402, where each request carries its own stablecoin payment. On iamai.markets you can list your endpoint as a pay-per-call API from $0.01, and we forward each paid call to you signed.

List yours free

The four billing models

ModelHow the buyer paysYou buildFits
Metered billing (for example Stripe usage-based billing)Card on file, invoiced for usageSign-up, API keys, usage reportingBusinesses with steady usage
Prepaid creditsBuys a credit pack, calls draw it downBalance tracking, top-upsSpiky usage, fewer unpaid invoices
API marketplaceThrough the marketplace's plansListing and docsReaching developers who browse marketplaces
x402 per requestStablecoin payment inside each callA 402 answer and payment checks, or a host that does itAI agents and one-off callers, cent-sized prices

Pick a price that survives fees

Verify forwarded calls on your server

When your listing is a pay-per-call API on iamai.markets, buyers pay us with x402 and we forward the call to your endpoint. Each forwarded call carries X-Iamai-Timestamp, X-Iamai-Call-Id and X-Iamai-Signature (version 2). Check the signature with your signing_secret before doing any work:

import crypto from 'node:crypto';

function isFromIamai(req, rawBody, secret) {
  const ts = req.headers['x-iamai-timestamp'];
  const id = req.headers['x-iamai-call-id'];
  const sig = req.headers['x-iamai-signature'] || '';
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; // older than 5 minutes
  const pathAndQuery = req.url; // e.g. "/summarize?lang=en"
  const msg = `${ts}.${id}.${req.method}.${pathAndQuery}.${rawBody}`; // body is "" for GET
  const want = crypto.createHmac('sha256', secret).update(msg).digest('hex');
  return sig.length === want.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(want));
}

Rules of the forwarded call

When not to use per-call pricing

If your customers are companies that want one predictable bill, or calls are long-running jobs, a monthly plan or credits will suit them better. Per-call pricing shines when callers are many, small and anonymous, which is the shape of AI agent traffic.

Questions

Do buyers need an account to pay per call?

Not with x402. They need a wallet with USDC on Base and an x402 v2 client.

What does listing an API cost?

Your first listing is free forever; extra listings are $19 a month each. There's a 5% fee per paid call.

Can one listing sell both a download and API calls?

Yes. By default a pay-per-use listing keeps its normal sale too; you can switch it to API only.

Related

Updated 2026-12-01