DEV Community

Marcus Chenmember_832ef635
Marcus Chenmember_832ef635

Posted on

I built a pay-per-call image processing API that AI agents can pay for with USDC

I keep experimenting with the x402 protocol — HTTP 402 payment-gated APIs where AI agents pay per call in USDC on Base, no accounts or API keys. Yesterday it was QR codes; today it's image processing.

Image Toolkit does four operations, 0.01 USDC each:

  • resize — scale to width/height (aspect preserved if you pass only one)
  • convert — PNG / JPEG / WebP
  • compress — quality 1-95 (JPEG/WebP)
  • thumbnail — square center-crop

How it works

You POST JSON with your image as base64:

curl -X POST https://imgkit.187.77.111.249.sslip.io/process -H 'Content-Type: application/json' -d '{"product": "thumbnail", "size": 256, "image_b64": "<base64>"}'
Enter fullscreen mode Exit fullscreen mode

Without payment you get a 402 with the x402 payment requirements (0.01 USDC on Base). Pay, retry with the PAYMENT-SIGNATURE header, get your processed image back as base64. Settlement runs through the PayAI facilitator, so any x402-compatible client library handles the flow automatically.

OpenAPI spec at /openapi.json, agent manifest at /.well-known/agent.json. It's also listed on agent402.tools and x402scan, so agent frameworks can discover it.

Honest status

This is day one. Zero paying callers so far — I'm publishing to find out whether agents actually discover and pay for utility endpoints like this. The QR code service from yesterday has been crawled and listed, but no revenue yet either. If you're building agent commerce, I'd genuinely like to compare notes in the comments.

Stack: Python stdlib HTTP server + Pillow, Caddy for TLS, PayAI as facilitator. Total running cost: a slice of a $4 VPS.

Top comments (0)