- Home
- Skills
- APIs & Backend
- Next.js 16 Paid AI App Bundle: Stripe, Resend, AI Billing
Next.js 16 Paid AI App Bundle: Stripe, Resend, AI Billing
This bundle contains two skills: nextjs-netlify-stripe-resend (base) and ai-usage-billing (add-on).
$9
Works with the AI Agents you already use
Next.js 16 Paid AI App Bundle: Stripe, Resend, AI Billing
Example session with this skill installed
Add prepaid AI token billing to my Next.js Netlify app. I want to sell $10 credit packs and charge for gpt-4o usage without using a database.
- Read your context and instructions
- Compiled the next js 16
I have integrated the AI usage billing system into your Next.js 16 application. The setup uses Stripe Customer Balance as a ledger to track credits, removing the need for an external database.
AI Usage Billing Implementation
| Component | Status | Implementation Detail |
|---|---|---|
| Base Stack | Installed | Netlify + Resend + Stripe Webhook |
| Metering | Configured | lib/pricing.js set for gpt-4o per-token rates |
| Credit Packs | Ready | Stripe Price price_1Qxyz... ($10.00 pack) |
| Gatekeeper | Active | lib/caps.js enforcing DAILY_CAP_CENTS |
| Chat Route | Deployed | /api/chat with runMeteredChat |
Environment Variables Required
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
RESEND_API_KEY=re_...
STRIPE_PRICE_CREDITS_10=price_...
SIGNING_SECRET=your_hmac_secret
OPENAI_API_KEY=sk-proj-...
LLM Pricing Config (lib/pricing.js)
export const MODEL_PRICES = {
'gpt-4o': {
prompt: 250, // cents per 1M tokens
completion: 1000,
}
};
export const MARKUP_BP = 2000; // 20% margin
Next steps
- Create a One-time Price in the Stripe Dashboard for the $10 credit pack and update
STRIPE_PRICE_CREDITS_10. - Configure your Stripe Webhook to listen for
checkout.session.completedevents pointing to/api/stripe-webhook. - Verify the Resend sender domain to allow transactional balance alerts to reach users.
Connects securely to your tools. The creator never sees your data.
About this skill
This bundle contains two skills: nextjs-netlify-stripe-resend (base) and ai-usage-billing (add-on). The bundle's SKILL.md tells your agent to complete the base workflow first, then the billing add-on.
Base: paid Next.js 16 app on Netlify Free (Stripe + Resend)
Most agents can write a Stripe checkout. Getting a small paid product working end to end on Netlify's free plan is where they trip: webhook signatures that fail because the body was parsed, access granted from the success URL, duplicate receipt emails on Stripe retries, Next 16 build errors, cron jobs that never fire on previews.
- Stripe Checkout for one-time payments, with Stripe promotion codes
- A webhook handler that verifies signatures on the raw body and fulfils idempotently
- Stripe Customer records used as the store, so there's no database to run (with the limits written down, and a clear "don't use this when..." section)
- Resend transactional email from your own domain, with idempotency keys
- HMAC-signed access links and email cookies
- A Netlify scheduled function guarded by a cron secret
- Next.js 16 notes that matter here: async request APIs,
proxy, Turbopack, and the Cache Componentsruntimebuild error
Add-on: AI usage billing
Adding AI to a paid app is easy. Making sure each user pays for what they use is harder. Agents often meter in the browser, bill from character counts, check the balance after the call, or credit a top-up twice when Stripe retries a webhook.
- One server route for every model call. It checks credits and caps, limits
max_completion_tokensto what the user can pay, calls the model, then debits the token usage the provider reports. - Prepaid credit packs sold with Stripe Checkout. Credits are stored on the Stripe customer invoice balance, which is an append-only ledger, so there's no database to run.
- Idempotent top-ups and debits, using Stripe idempotency keys plus a ledger check that covers the full webhook retry window.
- Spend caps: a global kill switch, a balance gate, a per-user daily cap (users can lower their own), and an output-token cap per request.
- An optional postpaid mode that sends usage to Stripe Billing Meters, with retry on 429. It also covers metered prices, usage alerts and credit grants.
- An accurate status note for Stripe's "Bill for LLM tokens" (Metronome), as of the check date. Stripe's docs call it public preview, while the token-meter and AI SDK packages say private preview.
- Notes for Netlify AI Gateway and Next.js
after().
The no-database design has a cost, and the skill says what it is: parallel requests can overspend by up to about one request's maximum cost each. The skill clamps that overspend and records it, and tells you when to move to a real store.
Why a subscription
Next.js, Netlify, Stripe and Resend change often. Each week the skill is re-checked against their changelogs and re-validated by building a fresh app. Every update ships with release notes.
What's included
- Top-level SKILL.md that routes to the base workflow, then the add-on
- base/: SKILL.md workflow (9 steps); 10 reference files (Netlify, Next 16, Stripe, Resend, signed links, cron, pitfalls, testing, go-live, sources); 10 example files (4 route handlers, 4 lib modules, netlify.toml, the scheduled function) plus an env template; scripts/check-signatures.mjs (12 offline checks); CHANGELOG.md and VERSION.md
- ai-usage-billing/: SKILL.md workflow (10 steps) with a "choose your billing model" table and hard rules; 10 reference files (metering, credits, caps, metered billing, token billing status, Netlify AI notes, pitfalls (18), testing, go-live, sources); 12 lib modules (2 copied from the base skill), 3 route handlers, a webhook handler to merge in, and an env template; 24 offline unit tests (
node --test) with an in-memory Stripe fake and a mocked LLM, plus scripts/check-billing.mjs; CHANGELOG.md and VERSION.md
Tested with
Base: validated by building a fresh create-next-app project (Next 16.4.2). Add-on: a fresh create-next-app project (Next.js 16.4.2, Cache Components on); npm test passed 24/24, npm run build passed, ESLint was clean, and local next start route checks passed. Not yet tested against a live Stripe payment, a live Resend send, real meter events, a real LLM call, streaming responses or a Netlify deploy.
Works with
Claude Code, Cursor, Codex (SKILL.md standard). Only the build and tests were run, not each agent.
Honest limits
- Base: One-time payments only, no subscriptions or seats. It won't create your Stripe, Resend or Netlify accounts and won't deploy for you. The no-database pattern fits small products, not apps that need queries. Netlify, Stripe and Resend publish free official skills for their own platforms, so use those for broad platform questions. This skill covers how the three fit together in one paid app.
- Add-on: Model prices are placeholders, and your agent fills them in from your provider's pricing page. Streaming is described but not shipped. It has no team wallets, and it doesn't integrate Metronome. Stripe's and Netlify's free official skills cover their own platforms in more depth. This skill covers how the pieces fit together for usage billing.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Not for high-concurrency team wallets. Credits are restricted to your product. Overspend is bounded but possible during parallel requests. Requires Next.js 16.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 22 days ago
- Accounts
Stripe
Resend
OpenAI
- Software
Node.jseslintcreate-next-app@netlify/skills@next/codemod
Permissions
Allowed Hosts