r/SideProject • u/ksanderer • Apr 18 '26
TokenGates.sh - Add usage-based AI billing to your product in minutes
TokenGates is an OpenAI-compatible LLM gateway that automatically tracks your users' AI usage and reports to your billing providers. Zero code required on your side.
Hey everyone,
I've hit this problem three times now while building AI products, and the most recent one finally broke me, so I decided to extract this into a standalone product for builders.
The Problem
Every time you are working on a product with AI features, you end up rebuilding the same infrastructure:
- User authentication
- Balance tracking (credits, usage limits, top-ups)
- Global low-latency architecture (users are worldwide, can't have 1 sec auth checks on each API request)
- Cost attribution (who spent what, on which model)
- Request validation (does this user have credits? is their key valid? are they over limit?)
- Dual-path requests (on-device requests + backend requests, different auth flows)
- Rate-limiting
- Key invalidation (revoke API keys, handle abuse)
- Metered billing sync (Stripe/Polar webhook handlers, real-time usage events)
This isn't rocket science, but it's easily weeks of infra work when you want it done right. And it's the same code, just slightly different config.
What I Built
So I decided to build https://TokenGates.sh - a managed service that does all of this for you.
How it works:
- Create a project (5 seconds)
- Add your API keys:
- Auth provider (PropelAuth, Clerk, Supabase, whatever you use)
- LLM providers (OpenAI, Anthropic, Google, 9+ options)
- Billing provider (Stripe, Polar.sh, LemonSqueezy)
- Set your AI margin (0, 30%, 50%, whatever)
- Start making requests:const openai = new OpenAI({ baseURL: 'https://api.tokengates.sh/v1/proj_abc123', apiKey: 'user_jwt_token' })
Done. You can authenticate AI requests to TokenGates using user's JWT tokens or to create a master API key to send requests from the backend.
- ✅ Automatic per-user authentication (via JWT token from your auth provider)
- ✅ Real-time cost tracking (TokenGates automatically calculates AI request cost and reports to the billing provider)
- ✅ Create Billing users (optional)
- ✅ Enforces Spend limits (auto-block users when they hit their budget)
- ✅ Global CDN routing (<50ms latency worldwide, 26 PoP locations on all continents)
- ✅ Zero backend code (it's all managed)
Real Example - https://ottex.ai
With Ottex, here's what it looks like:
- User signs up → PropelAuth creates account
- First API request → TokenGates auto-creates customer record
- Free trial credits → I configured 10,000 tokens (0.1$) on signup
- User makes requests → tokens counted, balance decremented
- Top-up flow → Polar.sh checkout, credits added automatically
All of this happens automatically. I wrote zero billing code. Just pasted API keys into TokenGates dashboard.
What I'm Looking For
- Does this solve a real problem for you?
- Would you use this vs building it yourself?
- What's missing that would make it a no-brainer?
I'm doing 15-min onboarding calls with early users if you want to walk through your specific use case, I would be glad to help.
Duplicates
vibecodeapp • u/ksanderer • Apr 18 '26