DEV Community

Mohamed Arafa
Mohamed Arafa

Posted on

Selling APIs to AI agents with x402: 69 endpoints, Cloudflare Workers, zero API keys

The pitch

An AI agent needs the EUR/EGP rate. It calls GET /v1/fx/EUR. The server answers 402 Payment Required with a price ($0.01) and a wallet. The agent signs a USDC transfer on Base, retries with an X-PAYMENT header, gets JSON. No signup, no API key, no invoice. That's x402.

I spent two nights building three services on top of it, all on Cloudflare Workers.

What's live

WorldData402 — 39 data endpoints: FX for 160+ currencies, historical rates, SEC company filings, EU public tenders, World Bank indicators, EU VAT validation, public holidays, geocoding, weather, air quality, earthquakes, Wikipedia, arXiv, Crossref, RDAP, DNS, npm/PyPI, barcodes. $0.01–$0.05 per call.

Inference402 — 15 endpoints on Cloudflare Workers AI: chat (small/large), structured JSON output, summarize, translate (plus an Arabic-tuned route that handles Egyptian dialect), extract, classify, sentiment, keywords, rewrite, embeddings, moderation, image description, Whisper transcription. $0.002–$0.02.

Briefs402 — 10 composite reports (company, country, market, tenders, domain due-diligence, location, research literature, product, package risk, long-document translation). It calls the other two internally and sells the finished brief for $0.10–$0.50.

Stack

  • Hono + @x402/hono for the paywall
  • PayAI facilitator (no account needed, 1,000 free settlements, then ~$0.002 each)
  • Cloudflare Workers AI for models (10k neurons/day free, then $0.011 per 1k)
  • One catalog.js per service generates routes, /.well-known/x402, /openapi.json and SKILL.md
  • Settlement happens only after a 2xx response, so failed calls are never charged

Things that bit me

  • x402.org/facilitator is testnet-only. For Base mainnet you need CDP (needs KYC) or PayAI/Mogami (no account).
  • x402scan needs /.well-known/x402 plus an OpenAPI with an input schema on every paid route, or it won't list the route.
  • Several US government APIs (Treasury, USAspending) refuse Cloudflare Workers egress IPs with TLS failures. GDELT rate-limits the whole Workers IP pool.
  • RapidAPI shows operationId as the endpoint name, not summary.

Distribution

Honest status

48 hours live, ~2k requests (all mine), 0 paid calls. Supply is done. If you've sold to agents and found what drives discovery, I'd like to hear it.

Top comments (0)