-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
high priorityTop most priority based taskTop most priority based task
Milestone
Description
🎯 Problem Statement
Credits are not currently properly calculated/charged based on actual token usage (recently implemented), causing inaccurate accounting for usage-based features.
💡 Proposed Solution
- Define
1 credit = 1000 tokens. - Instrument server-side request flows to capture token usage.
- Calculate
credits_used = ceil(tokens_used / tokens_per_credit). - Deduct
credits_usedfrom the user’s balance atomically. - Store usage records in
credit_usagetable. - Pre-check: if insufficient credits, reject request.
📊 Impact Assessment
User Impact: High (accurate billing).
Development Effort: Medium.
Priority: High.
🧪 Acceptance Criteria
- Token usage captured for all LLM requests.
- Credits deducted based on conversion rule.
- Users see per-request credit deduction on each feature before generating response
- Safe behavior when credits insufficient.
🔗 Related Features
Billing, invoices, credit awarding/referrals, usage dashboard.
📚 Additional Context
Ensure the model's API returns token counts or compute tokens manually.
📋 Checklist
- Token capture for all LLM calls
- Credit conversion and deduction logic
- DB table for usage records
- UX for insufficient credits
- Tests for calculations and concurrency
Metadata
Metadata
Assignees
Labels
high priorityTop most priority based taskTop most priority based task