Case study · AI API gateway

NyanAPI

One API key for many AI models, paid in kyat. Built for Myanmar developers and students who can't pay AI providers with an international card.

RoleFounder and developer
Year2026
StackReact, Express, tRPC, Postgres, Docker
StatusLive at nyanapi.com ↗

The problem

AI providers bill in dollars to international cards, and some don't serve Myanmar at all. A student who wants to build with these models has no simple way to pay for them.

What I built

  1. One key, many modelsA single endpoint that speaks the OpenAI, Anthropic and Gemini request formats, so existing SDKs and coding tools work by changing only the address and the key.
  2. A wallet in kyatTop up from K5,000 with local payment apps, upload the receipt, and the balance is credited once the order is approved.
  3. Free models to startA set of free models with daily limits, so people can try the API before they pay anything.
  4. Keys, usage and limitsCreate several API keys, cap what each one can spend, and see usage and cost per request.
  5. A command-line toolA nyanapi CLI published on npm, for getting set up from the terminal.
  6. Admin consoleOrders, customers, models, prices and provider health in one place.

The hard parts

  1. Money that never driftsEvery amount is a whole number: one kyat is 10,000 units, so a request costing a fraction of a kyat is stored exactly. Every balance change is a row in a ledger, written in the same transaction as the balance itself.
  2. Charging for something that streamsThe real cost is only known when the answer finishes. A hold is placed on the wallet before a request starts and settled against the actual token count at the end, so two requests at once can't spend the same balance.
  3. Staying up when a provider goes downEach model can have more than one route. If a provider errors or times out, the request moves to the next one. A free request never falls over to a paid route.
  4. Never selling at a lossProvider prices change. A price sync and a break-even check compare what customers pay with what each request costs, and a reconciliation job checks recorded usage against what providers actually billed.
  5. Bonuses that can't be farmedWelcome, first top-up and referral credit sit in a separate bonus balance that expires and only works on cheaper models. Sign-up has a CAPTCHA and email verification.