Billing System
Flexible billing models including elastic billing, subscription plans, and payment processing
Billing System
CoAI.Dev provides flexible billing options to meet diverse user needs, from pay-as-you-go models to comprehensive subscription plans with enterprise features.
Overview
CoAI.Dev supports multiple billing methods designed for different use cases:
- 🔄 Elastic Billing: Pay-per-use with credits system
- 📋 Subscription Plans: Fixed monthly/yearly plans with quotas
- 💳 Payment Processing: Support for multiple payment gateways
- 📊 Usage Analytics: Detailed billing and usage tracking
Billing Modes
Elastic Billing is the foundational billing method for all models, while Subscription Plans provide additional value and quota management on top of the credit system.
Elastic Billing (Credits System)
How It Works
Elastic billing uses a credits-based system where users purchase credits (points) and consume them based on actual usage. This flexible model supports:
- Per-Request Billing: Fixed cost per API call
- Token-Based Billing: Cost based on input/output tokens
- Free Tier Models: No billing required
- Anonymous Access: Optional free access without login
Credit Requirements
To prevent abuse, minimum credit requirements are enforced:
No Restrictions
- Free models have no minimum credit requirements
- Can be used without authentication if anonymous access is enabled
- Useful for public demos and basic features
Pricing Configuration
Access Pricing Settings
Navigate to Admin Panel → Billing → Pricing Configuration
Configure Model Pricing
For each model, set:
- Billing Type: Per-request, token-based, or free
- Input Token Price: Cost per 1K input tokens
- Output Token Price: Cost per 1K output tokens
- Anonymous Access: Allow usage without login
Import Price Templates
Use built-in templates or sync from upstream:
- Built-in Templates: Pre-configured pricing for popular models
- Upstream Sync: Import pricing from other CoAI.Dev instances
- Custom Rates: Set custom exchange rates for different currencies
Test and Apply
- Test pricing with sample requests
- Monitor billing accuracy
- Adjust rates based on usage patterns
User Initial Credits
Security Recommendation
Don't set initial credits too high to prevent abuse from mass registrations. Moderate initial credits help control resource usage while allowing new users to test the platform.
Configure initial credits for new users in System Settings → Operations → User Initial Credits:
- New User Credits: Credits given to newly registered users
- Verification Bonus: Additional credits for verified accounts
- Referral Rewards: Credits earned through referrals
Subscription Plans
Plan Structure
Subscription plans are built on top of the credit system, providing:
- Fixed Monthly/Yearly Pricing: Predictable costs for users
- Quota Management: Usage limits per model
- Tier Benefits: Progressive features and access
- Upgrade/Downgrade Logic: Flexible plan changes
Plan Tiers
CoAI.Dev supports four subscription tiers:
Tier | Level | Description | Target Users |
---|---|---|---|
Free | 0 | Basic access with limited quotas | New users, testing |
Basic | 1 | Entry-level paid plan | Individual users |
Standard | 2 | Enhanced features and quotas | Small teams |
Professional | 3 | Full access with premium support | Enterprises |
Subscription Items
Each plan consists of multiple Items, where each item defines:
- Models: Which AI models are included
- Quota: Monthly usage limit (-1 for unlimited)
- Icon: Display icon for the feature
- Description: User-friendly explanation
Upgrade/Downgrade Logic
Upgrading Subscriptions
When users upgrade to a higher-tier plan:
- Calculate Prorated Cost: Based on remaining days in current billing cycle
- Charge Difference: Only pay the difference between plans
- Immediate Access: New features available instantly
Example:
- Current: Basic plan (100 credits/month), 15 days remaining
- Upgrade to: Standard plan (200 credits/month)
- Cost calculation: (15 days / 30 days) × (200 - 100) = 50 credits
- User pays 50 credits and gets immediate Standard access
Downgrading Subscriptions
When users downgrade to a lower-tier plan:
- Preserve Remaining Time: Current subscription continues until expiration
- Calculate Bonus Days: Convert remaining value to new plan duration
- Double Compensation: 2x bonus days for downgrade inconvenience
Example:
- Current: Standard plan (200 credits/month), 15 days remaining
- Downgrade to: Basic plan (100 credits/month)
- Bonus calculation: (15/30) × (200/100) × 2 = 20 days
- Basic plan starts after current expires + 20 bonus days
Payment Processing
Supported Payment Methods
WeChat Pay & Alipay
Note: Requires business registration and custom development
- Requirements: Business license, merchant accounts
- Integration: Custom API development required
- Features: Native mobile payments, QR codes
- Processing: Real-time confirmation
Configuration Steps:
- Apply for merchant accounts (WeChat/Alipay)
- Obtain API credentials (AppID, merchant keys)
- Configure webhook endpoints
- Test payment flows
- Deploy to production
Payment Order Management
Track and manage all payment transactions:
- Order Status: Pending, completed, failed, refunded
- Payment Details: Amount, method, timestamps
- User Information: Account linking and history
- Manual Operations: Status updates, refund processing
- Sync Operations: Verify payment status with providers
Advanced Features
Usage Analytics
Monitor billing performance with detailed insights:
- Revenue Metrics: Daily, monthly, yearly income
- User Patterns: Most popular plans and models
- Credit Flow: Purchase vs consumption rates
- Conversion Rates: Free to paid user conversion
Quota Management
Fine-tune usage limits and access controls:
- Model-Specific Quotas: Different limits per AI model
- Time-Based Resets: Daily, weekly, monthly quota cycles
- Overage Handling: Block, charge extra, or allow with warnings
- Group Policies: Different quotas for user tiers
Billing Automation
Streamline financial operations:
- Auto-Renewal: Seamless subscription renewals
- Payment Retry Logic: Handle failed payment attempts
- Credit Expiration: Automatic cleanup of old credits
- Invoice Generation: Automated billing statements
Best Practices
Pricing Strategy
- Market Research: Analyze competitor pricing
- Value-Based Pricing: Price based on user value, not just costs
- Tier Progression: Clear upgrade incentives between plans
- Geographic Considerations: Adjust pricing for different markets
User Experience
- Transparent Pricing: Clear cost breakdown for users
- Usage Monitoring: Help users track their consumption
- Payment Security: Secure payment forms and data handling
- Support Integration: Easy access to billing support
Financial Management
- Revenue Recognition: Proper accounting for subscriptions
- Chargeback Prevention: Fraud detection and verification
- Tax Compliance: Handle VAT, sales tax automatically
- Financial Reporting: Regular revenue and usage reports
Troubleshooting
Common Billing Issues
Payment Failures
Problem: Payment processing fails or gets stuck
Solutions:
- Check payment gateway configuration and credentials
- Verify webhook endpoints are accessible and responding
- Review payment method validity and limits
- Check for fraud detection false positives
- Implement payment retry logic with exponential backoff
Credit Discrepancies
Problem: User credits don't match expected values
Solutions:
- Review usage logs for unexpected consumption
- Check for failed payment processing
- Verify pricing configuration accuracy
- Audit credit adjustment history
- Implement detailed usage tracking
Subscription Issues
- Plan Changes: Ensure proper upgrade/downgrade calculations
- Renewal Failures: Handle payment method updates
- Quota Overages: Configure appropriate handling policies
- Access Permissions: Verify tier-based model access
Ready to set up billing? Start with User Management to understand user accounts, or explore Analytics to track your revenue and usage patterns.