tierrun/tier-vercel-openai
关于
这个项目使用 Tier 和 OpenAI 生成营销内容、实现按用量计费,并根据当前订阅检查功能访问权限、报告功能用量、管理订阅等。
网站与应用开发可以做什么
- NextJS 13 /app dir
- AI content generation using OpenAI
- Pricing model using Tier Model Builder
- Subscriptions and Checkout
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Metered billing for an AI content creator app

Get started with usage based billing for your OpenAI based apps!
This project generates marketing content using OpenAI, implements metered pricing model, checks for feature access based on their current subscription, reports usage of a feature, manages subscription and more using Tier.
Demo
Features
- NextJS 13
/appdir - AI content generation using OpenAI
- Pricing using Tier and Stripe.
- Pricing model using Tier Model Builder
- Subscriptions and Checkout
- Feature access and upsells
- Reporting usage of a feature
- Pricing table
- Customer billing portal
- Authentication using Auth.js
- ORM using Prisma
- Database on Vercel Postgres (Default) / Planetscale / Supabase
Why Tier?
Tier decouples billing, metering, and access checks from your application code. With it, you can conveniently establish new pricing models without needing to restructure your app or concern yourself with grandfathering or breaking changes.
Running locally
- Install dependencies
npm i
- Copy
.env.exampleto.env.localand update the variables.
cp .env.example .env.local
- Run the project locally
npm run dev
Tier Pricing Model
- Model Builder - https://model.tier.run/clkkv3fv93bbko972m4w3x9o8
You can clone the pricing model from the above links and make it your own. You can sync it with your Stripe "Test Mode" for both your dev and staging environments. You can also push this model to prod as shown below, by making use of the Tier CLI using this command where you use the model builder link and set a environment variable called STRIPE_API_KEY which should be a restricted key generated will all permissions in your Stripe live mode. You can find restricted keys at Developers > API Keys > Restricted Keys
tier --live push <https://models.tier.run/XXXXXXXX>
Environment variables
We have considerably reduced the number of environment variables in the project to make it easier for you to get started. This is an exhaustive list of all the environment variables in the project
- App:
NEXT_PUBLIC_APP_URL- The is the URL of your application, if you are in the middle of using our deploy button for Vercel, you can open vercel dashboard in another window and visit https://vercel.com/jerric-tier/project-name/settings/domains by replacingproject-namewith yours, make sure to appendhttps://to your domain. In local dev mode, you can set this variable inenv.local / env.developmentand give it this valuehttp://localhost:3000. - Auth:
NEXTAUTH_URL- Used by Auth.JS - When deploying to vercel you do not have to set this value, but when you develop you can set this ashttp://localhost:3000. Find more details here. - Auth:
NEXTAUTH_SECRET- Used by Auth.JS - Used to encrypt JWT and you can easily generate a secret usingopenssl rand -base64 32. Find more details here. - Github OAuth:
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRET- Both Client ID and Client Secret of Github App can be generated at your Github Developer Settings page and you can read the step-by-step directions here. You can provide yourNEXT_PUBLIC_APP_URLas the Homepage URL and append/api/auth/callback/githubfor the callback URL - Tier:
TIER_BASE_URL&TIER_API_KEY- You can set yourTIER_BASE_URLvariable ashttps://api.tier.rundefault value in all your environments andTIER_API_KEYis your Stripe secret key. You can follow the steps in our docs to sync your pricing model with your Stripe account. - OpenAI:
OPENAI_API_KEY- Get your OpenAI API key from OpenAI User Settings - Vercel Storage:
POSTGRES_PRISMA_URL&POSTGRES_URL_NON_POOLING- You will only need these two variables after you have setup your database as we are using Prisma. You can find more details here.
Powered by
This example is powered by the following services:
- Tier (Subscriptions and Pricing)
- OpenAI (AI API)
- Vercel (Hosting NextJS)
- Auth.js (Auth)
- Vercel Postgres (default) / Supabase / Planetscale (Database)
- Stripe (Payments)
- Infisical (Secrets)
License
License under the MIT license.
探索相关项目
加载中…