Ship per-token billing for your AI product this afternoon
Copy-paste, production-shaped Python code plus a button-by-button Stripe walkthrough. Idempotency, retries, decimal money math, usage caps, abuse protection — the tricky parts are already handled.
One-time payment · No subscription · Instant download
Billing is the part nobody wants to rebuild at 2 a.m.
Token usage metering looks like a weekend project until you hit the edge cases. The kit covers them before you do.
Usage is never lost
MeterEvents report with UUID idempotency keys, exponential-backoff retries, a circuit breaker, and a local fallback queue when Stripe is unreachable. Webhook signatures verified and events de-duplicated.
Pricing that never loses money
validate_plan_economics() checks your plan price against your real backend cost — including Stripe and platform fees — and tells you SAFE or money-losing, plus the max tokens you can safely include.
Abuse protection built in
One customer on your priciest model can wipe a day of margin. Weighted quota units, hard USD caps, per-customer rate limits, daily sub-caps, and auto-throttling on 5× usage spikes — every block audit logged.
14 files, ready to drop into your project
The core engine has zero dependencies and runs on any Python 3.8+ setup. The Stripe SDK is only needed when you go live.
Code 3 files
- billing_module.py — full engine: separate input/output pricing, cache-read discounts & cache-write surcharges, tiered pricing (volume & graduated), minimum charge, 80/90/100% alerts, failed calls bill zero, batch billing, multi-tenant engine, multi-currency display, JSON-lines audit log. Money math in Decimal; Stripe's 12-decimal unit amounts handled.
- stripe_integration.py — MeterEvents reporting with retries, circuit breaker, fallback queue; webhook verification & de-dup; metered subscription helpers.
- quickstart.py — one runnable file demoing every feature and printing real billing results.
Docs guides
- 10-minute Quickstart — install, run, see money calculated
- Stripe Metered Billing setup guide — exact clicks, fields & example values, test mode → live mode
- Webhook integration guide — Flask/FastAPI/Django examples, retry semantics, edge cases
- 10 billing anti-patterns + audit playbook — how token billing goes wrong, and how the kit prevents each one
- 2026 model pricing cheat sheet — verified prices for GPT-5.6, Claude, DeepSeek V4 (peak/off-peak), Gemini, with sources
- Hybrid pricing guide — fixed fee + quota + overage math that never loses money
- Anti-abuse guide — weighted quota, caps, anomaly detection, chargeback prevention, copy-paste Fair Use Policy
Legal & extras included
- LICENSE.md — Basic vs Extended terms
- DISCLAIMER.md — AS IS warranty & trademark notice
- 9 validated plan presets — budget, smart, premium model routes
- requirements.txt — stripe only, for the live integration
python3 code/quickstart.py
Sell plans like the pros
$19/month including 10M tokens, then $1.50 per extra million. Ship the model used by mature AI products — fixed fee, included quota, metered overage — with the exact math behind every number.
- 9 plan presets across budget / smart / premium routes
- Validator accounts for payment fees AND platform fees
- Graded usage alerts at 80% / 90% / 100% of quota
The same trick frontier AI products use
Weighted quota units. Premium models drain quota up to 22× faster than budget models — so one user can't quietly route every request to your most expensive endpoint.
- Overage OFF by default, with a hard USD cap
- Per-customer rate limits and daily sub-caps
- Automatic throttling when usage spikes 5× above baseline
- Every block written to the audit log, ready for support disputes
Price your plans against real model costs
The cheat sheet covers verified August 2026 prices for the major model families — including peak/off-peak differences — so your margins are based on what tokens actually cost today, not last year's blog post.
- Input / output / cache prices split out correctly
- Blended cost formula for mixed traffic
- Every figure sourced and dated
Buy once, own it forever
Buy once, own it forever. No subscription, no recurring fees — the files are yours to integrate and deploy.
Basic License
For your own product
- Complete 14-file kit, instant download
- Use in one end product you own or operate
- Full source code — modify and deploy freely
- All future patch updates
- Client / agency work
- Multi-tenant commercial SaaS
- Personalized license certificate
Extended License
For freelancers, agencies & SaaS teams
- Everything in Basic — same complete kit
- Use in unlimited products, including client work
- Commercial multi-tenant SaaS license
- Personalized, named License Certificate PDF — ready for client handovers and procurement audits
- Priority email support
- All future patch updates
- Upgrade later? Basic buyers pay only the $50 difference
Digital product, instant download. If anything isn't working, email us first — most issues are fixed within a day. If we genuinely can't resolve it within 14 days of purchase, you get a full refund, no questions asked. tingstudio.ai@gmail.com
Frequently asked questions
Still unsure? Email tingstudio.ai@gmail.com — a real human replies.
What exactly do I get after purchase?
An instant download of the complete kit: 3 Python files (the billing engine, the Stripe integration, and a runnable quickstart), 7 guides covering Stripe setup, webhooks, anti-patterns, hybrid pricing, abuse protection and 2026 model prices, plus LICENSE.md and DISCLAIMER.md. Your purchase receipt includes a license key.
Do I need a Stripe account or any API keys to start?
No. The core billing engine has zero dependencies — run python3 code/quickstart.py right now and watch it calculate real billing results offline. You only need a (free) Stripe account and pip install stripe when you connect live metered billing, and the setup guide walks you through every click from test mode to live.
What are the technical requirements?
Python 3.8 or newer. That's it for the engine. The webhook examples cover Flask, FastAPI and Django — Flask is optional and only needed for the example server.
What's the difference between Basic and Extended?
Basic covers one end product you own. Extended covers unlimited products, including paid client/agency work and commercial multi-tenant SaaS. Extended buyers also receive a personalized, named License Certificate PDF (great for client handovers and procurement audits) and priority email support. The files are identical — the difference is the license grant.
Can I upgrade from Basic to Extended later?
Yes. Email your purchase receipt to tingstudio.ai@gmail.com and upgrade for the $50 difference.
I'm billing AI API usage — does this handle input vs output and caching correctly?
Yes — separate input/output pricing, cache-read discounts and cache-write surcharges, tiered (volume and graduated) pricing, batch calls, minimum charges, and failed calls billing zero are all in the engine. Money math uses Python Decimal end-to-end, including Stripe's 12-decimal unit amounts.
What's the refund policy?
Because it's a digital instant-download product, email us first if anything isn't working — most issues are fixed within a day. If the kit doesn't work for you and we genuinely can't resolve it, email within 14 days of purchase for a full refund, no questions asked. Even after 14 days, reach out — we'll do our best to make it right.
Is this affiliated with Stripe or the model providers?
No. This is an independent code kit. It is not affiliated with, sponsored, or endorsed by Stripe, OpenAI, Anthropic, DeepSeek, or Google; all trademarks belong to their respective owners. Code is provided AS IS — test before production.
Stop wrestling Stripe docs. Start billing tokens.
Join the indie hackers shipping usage-based pricing this week — with the edge cases already handled.
Get the Kit — from $49