CoAI LogoCoAI.Dev
Features

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 PanelBillingPricing 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 SettingsOperationsUser 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:

TierLevelDescriptionTarget Users
Free0Basic access with limited quotasNew users, testing
Basic1Entry-level paid planIndividual users
Standard2Enhanced features and quotasSmall teams
Professional3Full access with premium supportEnterprises

Subscription Items

Each plan consists of multiple Items, where each item defines:

{
  "id": "gpt4_access",
  "name": "GPT-4 Access",
  "models": ["gpt-4", "gpt-4-turbo"],
  "quota": 1000,
  "icon": "🤖",
  "description": "1000 GPT-4 requests per month"
}
  • 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:

  1. Calculate Prorated Cost: Based on remaining days in current billing cycle
  2. Charge Difference: Only pay the difference between plans
  3. 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:

  1. Preserve Remaining Time: Current subscription continues until expiration
  2. Calculate Bonus Days: Convert remaining value to new plan duration
  3. 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:

  1. Apply for merchant accounts (WeChat/Alipay)
  2. Obtain API credentials (AppID, merchant keys)
  3. Configure webhook endpoints
  4. Test payment flows
  5. 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:

  1. Check payment gateway configuration and credentials
  2. Verify webhook endpoints are accessible and responding
  3. Review payment method validity and limits
  4. Check for fraud detection false positives
  5. Implement payment retry logic with exponential backoff

Credit Discrepancies

Problem: User credits don't match expected values

Solutions:

  1. Review usage logs for unexpected consumption
  2. Check for failed payment processing
  3. Verify pricing configuration accuracy
  4. Audit credit adjustment history
  5. 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.