All PromptsSupabase AI Usage Credit System

Supabase AI Usage Credit System

Part 4
130 words

Share this prompt:

aiwithkyle.com/6607

Prompt

I need to add a credit system to track AI usage in my app with Supabase:

Database schema needed:
1. Add to user profiles table:
   - account_type (free/paid/cancelled)
   - credits_remaining (integer, default based on tier)
   - credits_used_this_month (integer, default 0)
   - last_credit_reset (timestamp)
   - subscription_start_date (timestamp)

2. Create usage_log table:
   - user_id (foreign key to profiles)
   - credits_used (integer)
   - action_type (text: "ai_generation", "api_call", etc)
   - timestamp (when the usage occurred)

Credit rules:
- Free users: 5 credits total, no reset
- Paid users: [INSERT YOUR CALCULATED LIMIT] credits, reset monthly on subscription anniversary
- Each AI request costs 1 credit
- Block requests when credits_remaining = 0
- Show usage dashboard with remaining/used counts

Please create this database structure and the logic to handle credit deduction and monthly resets.

How to Use This Prompt

  1. 1Replace text in [BRACKETS] with your specific information
  2. 2Copy the customized prompt using the button above
  3. 3Paste into ChatGPT, Claude, or your preferred AI tool
  4. 4Review and refine the AI's output as needed

Learn How to Use This Prompt

See this prompt in context with full examples, use cases, and strategies in Getting ready for revenue (Part 4).

See How to Use This

More from This Playbook