DEV Community

MR-RAHAD
MR-RAHAD

Posted on

I Wrapped All My APIs Behind One Key and Started Selling Access (From Bangladesh)

I maintain a handful of small APIs: a Grok chat bot, a Kimi chat API, an image generator, a photo enhancer, and a video downloader. Each had its own URL, its own auth (or none), and its own way of breaking at 2 AM.

So I built a gateway. One endpoint, one API key, plan limits, and a dashboard. It's live at Rahad API Marketplace (Railway), and this is what I learned shipping it in about a day.

The shape of it

  • One key (rk-...) for every backend: chat, image generation, photo enhancement, media download
  • Plan limits that actually stop abuse: Free 100/day, Pro 5000/day, Unlimited 100k/day
  • Usage is charged only when an upstream call succeeds — if my backend fails you, it shouldn't cost your quota
  • A dashboard where you sign up, verify your email, and get a free key instantly

Payments are the Bangladesh part of the story: no Stripe here, so Pro upgrades run through bKash with a manual transaction-ID approval flow. Ugly? A little. Working? Completely.

One bug class that bit me

When an upstream API fails (say it returns 401), my first version passed that straight through to the buyer. Their client then told them "unauthorized" — which sounds like their key is wrong. That's my bug wearing their error message.

Fix: the gateway now translates any upstream failure into an honest 502 that names the backend, and only counts usage on success. Small change, much fairer billing.

What it's honest about

GET /v1/models doesn't pretend everything is fine. It probes the upstreams and reports real availability — if a backend is down, the endpoint says so instead of selling you a broken promise.

Try it

Honest question for the comments

For those of you selling small APIs from countries without Stripe — how do you take money? Manual mobile-money approvals like mine, Paddle/Lemon Squeezy, or something else entirely? I'm genuinely deciding what to do next, and I'd rather learn from your scars than earn my own.

Top comments (0)