LicenRoute

LicenRoute › Guides

How to charge for your API (even if AI built it)

Updated 21 November 2026 · 7 min read

Short version: decide what is worth paying for, sell it in packages of uses, give each customer a key you can revoke, and make sure that when something fails, nothing is given away for free. If your backend is Express, your AI assistant can set this up with LicenRoute while you approve each change.

You built an app (maybe with Claude Code, Cursor, Lovable or Bolt) and people are using it. Some of what it does is clearly valuable: a report, a dataset, an export, an AI-powered endpoint that costs you money every time it runs. The question is how to charge for that part without breaking the rest.

1. Decide what is worth paying for

Don't put your whole app behind a paywall. Look for the parts that:

Everything else should stay free: sign-up, login, your home page, health checks. Making those paid doesn’t earn money; it just locks people (and your monitoring) out.

2. Pick a pricing model

ModelHow it worksGood for
Monthly subscriptionFixed price, access while you payApps used by people every day
Packages of usesBuy 1,000 calls for a price; buy more when they run outAPIs used by programs and AI agents; costs that grow with use
Pay per callEvery single request is billedHigh volume, with a billing system that can handle it

For an API, packages of uses are usually the simplest place to start: the customer knows what they pay, and you never serve more than they bought.

3. The five pieces you need

  1. Keys. Each customer gets a secret key that they send with every request. Keys must be impossible to guess, and you should store only a fingerprint (hash) of them, never the key itself.
  2. A usage counter. Every request to a paid part uses one unit. When the package is used up, the next request is refused.
  3. Revocation. If someone stops paying or abuses the API, you switch their key off and the very next request is refused, without redeploying.
  4. A clear “pay first” answer. A request without a valid key should get a standard answer: HTTP 402 Payment Required, ideally saying which plan unlocks it and where to buy it. Programs and AI agents can read that; an error page they can’t.
  5. Safe failure. If the system that checks keys is down, paid parts must close, not open. Free parts must keep working.

4. Mistakes that quietly give your API away

5. Build it yourself, or let your assistant set it up

You can ask your AI assistant to write all of this from scratch. It will produce something that looks right; the mistakes above are what it usually gets wrong, and you'll need tests for every case.

If your backend is Node.js with Express, LicenRoute does the five pieces for you. Paste this into your assistant:

Add paid access to my Express API with LicenRoute.
First read https://licenroute.com/llms.txt and follow its rules.
1. Tell me which of my routes could be paid and which must stay free.
2. Show me the exact change before writing anything.
3. When I agree, give me the command to approve it in my own terminal.
4. Then run the LicenRoute tests and explain the results in plain words.

Your assistant reads your code, proposes what to charge for, and shows you the change. Nothing is written until you type a short code in your terminal: the one step it can’t do for you. Then LicenRoute tests your API like a customer would: no key (402), valid key (200), fake key (403), package used up, key revoked, and the system down.

Honest status: LicenRoute is a free developer preview. Today it runs in demo mode on your computer, so you can test the whole flow; charging real money needs the hosted service, which isn’t open yet. It works with Express only, not yet with Next.js, Supabase or Python.

Try it on your app

Copy the prompt from the home page, or follow the 10-minute tutorial on the example app. Using another framework? Tell us what you built.

Related guides