Overseas access: www.kdjingpai.com
Ctrl + D Favorites

Flexprice is an open source billing and metering platform designed for developers that supports usage billing, subscription-based and hybrid billing models. Users can deploy it in the cloud or self-hosted with full code transparency to avoid vendor lock-in. The platform simplifies developers' billing logic by processing usage data in real-time, automatically calculating pricing, applying credits, limiting features and generating invoices. It integrates seamlessly with existing payment gateways, CRMs, and accounting tools for businesses that require flexible billing.Flexprice offers SDKs in Python, JavaScript, and Go languages for developers to integrate quickly. The official documentation and community support are well developed and suitable for both beginners and professional developers.

Flexprice: an open source billing tool that supports usage billing and subscription-1

 

Function List

  • Real-time usage measurement: Support for defining custom events such as API calls, computation times, etc. Track and process millions of events in real time.
  • credit management: Support prepaid and promotional credits, set auto-recharge thresholds or credit expiration rules.
  • Flexible Pricing Model: Supports usage billing, subscription-based, tiered pricing or hybrid models for quick pricing adjustments.
  • Functional limitations: Simplify rights management by setting function switches or usage limits based on user plans.
  • Automatic invoice generation: Generate clear invoices based on real-time usage and subscriptions, with support for billing cycles and overage management.
  • SDK Integration: SDKs for Python, JavaScript, and Go are available for quick integration into existing systems.
  • Self-hosted option: The open source code supports self-hosting and allows customization of storage, queues and keys.
  • Multi-tool integration: Seamless connectivity with payment tools such as Stripe, Chargebee, and CRM systems.

 

Using Help

Installation process

Flexprice supports local development or running from source, and requires the installation of Docker, Go and Make tools. Here are the detailed installation steps, based on the official GitHub repository instructions:

  1. clone warehouse::
    git clone https://github.com/flexprice/flexprice
    cd flexprice
    

    Clone the Flexprice repository locally and go to the project directory.

  2. Setting up the development environment::
    make dev-setup
    

    This command automatically installs dependencies and configures the environment, including Postgres, Kafka, ClickHouse, and Temporal.

  3. Initiation of infrastructure::
    docker compose up -d postgres kafka clickhouse temporal temporal-ui
    

    Start the necessary database and message queue services.

  4. Running the Flexprice Service::
    go run cmd/server/main.go
    

    Start the Flexprice main service, running in the local environment.

  5. Other common commands::
    • Restart the Flexprice service:make restart-flexprice
    • Stop all services:make down
    • Clean up and reboot:make clean-start
    • Build the image separately:make build-image
  6. Front-end configuration(Optional):
    If you need a front-end interface, clone the front-end repository:

    git clone https://github.com/flexprice/flexprice-front
    cd flexprice-front
    cp .env.example .env
    

    configure .env.local file, set the following variables:

    VITE_SUPABASE_URL=your-supabase-url
    VITE_SUPABASE_ANON_KEY=your-supabase-anon-key
    VITE_API_URL=http://localhost:8080/v1
    VITE_ENVIRONMENT=development
    

    Start the front-end development server:

    npm run dev
    

    interviews http://localhost:3000 View the front-end interface.

Functional operation flow

Real-time usage measurement

Flexprice allows developers to define custom events (e.g. API calls, calculation times). Event data is sent to Flexprice via the SDK, and the system aggregates and stores the data in real time. Procedure:

  1. Send events using an SDK such as Python or JavaScript:
    from flexprice import FlexpriceClient
    client = FlexpriceClient(api_key="your-api-key")
    client.track_event(user_id="user123", event_type="api_call", value=1)
    
  2. View real-time usage data in the Flexprice dashboard to ensure accuracy.

credit management

Support prepaid or promotional credit. Operation Process:

  1. Create a credit plan in the dashboard and set the credit limit, auto-recharge threshold or expiration time.
  2. Use the API to assign credits:
    const flexprice = new Flexprice({ apiKey: "your-api-key" });
    flexprice.grantCredit({ userId: "user123", amount: 100, expires: "2025-12-31" });
    
  3. The system automatically tracks credit usage and deducts it as the user spends.

Pricing Model Setup

Flexprice supports flexible pricing. Operational Processes:

  1. Log in to the dashboard and create a pricing plan (e.g., pay-per-use or subscription-based).
  2. Define billing rules, such as $1 per 100 API calls.
  3. Apply the plan to the user's account via API or dashboard and the system automatically calculates the cost.

Functional limitations

Developers can set feature switches or limits for different plans. Operation Steps:

  1. Define features in dashboards (e.g. API calls are limited to 1000 per month).
  2. Check permissions in the application:
    if (flexprice.checkFeatureAccess("user123", "api_calls") < 1000) {
    // 允许访问
    }
    
  3. The system automatically limits overuse.

Invoice Generation

Flexprice automatically generates invoices with usage, subscription and credit details. Operational Flow:

  1. Configure the billing cycle (monthly or annual).
  2. The system generates invoices based on real-time usage, which are sent to the user or integrated into payment tools such as Stripe.
  3. View invoice details in the dashboard to ensure accurate financial reconciliations.

caveat

  • self-hosted: Ensure that dependent services such as Postgres, Kafka, etc. are running properly, otherwise usage measurement may be affected.
  • safety: Use environment variables to store API keys and avoid hard-coding.
  • scalability: Storage or queues can be replaced on demand, maintaining system flexibility.

 

application scenario

  1. SaaS platform billing
    SaaS companies can use Flexprice to implement usage-based billing or subscription-based pricing to quickly adjust pricing models. For example, API services can be charged per call and dashboards can show user usage in real time.
  2. AI model hosting
    The AI platform can track compute resource usage (e.g. GPU time) through Flexprice, automatically generating invoices and restricting user access to ensure cost control.
  3. E-commerce platform promotions
    E-commerce companies can use the credit management function to issue promotional credits and set up automatic recharge or expiration rules to improve user stickiness.
  4. Development Tools Subscription
    Developer tool providers can combine subscription and usage billing to restrict premium features to paid users only and simplify privilege management.

 

QA

  1. Is Flexprice completely free?
    Flexprice is open source software and can be self-hosted for free, but some features require a commercial license. There may be costs involved in the cloud version, see https://flexprice.io for details.
  2. How do I integrate with Stripe?
    Configure the Stripe API key in the dashboard and Flexprice will automatically push invoice data to Stripe to process payments.
  3. What programming languages are supported?
    SDKs are available for Python, JavaScript, and Go, with detailed documentation in the official GitHub repository.
  4. How do you handle high concurrent dosage?
    Flexprice uses Kafka and ClickHouse to handle millions of events and ensure data accuracy in highly concurrent scenarios.
  5. What hardware requirements are needed for self-hosting?
    A minimum of a 4-core CPU, 8GB of RAM, and 50GB of storage is recommended, depending on the volume of events and user size.
0Bookmarked
0kudos

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

inbox

Contact Us

Top

en_USEnglish