Once you have defined your Product, the next step is to determine what you will measure and charge for. This is done using Billable Metrics.

What is a Billable Metric?

A Billable Metric represents a quantifiable unit of usage or outcome related to your Product that you intend to bill your Customers for.

  • Association: Every Billable Metric belongs to a specific Product.
  • Purpose: They define the unit of consumption. Examples include:
    • API requests made
    • Gigabytes transferred
    • CPU hours consumed
    • Tokens processed (input/output)
    • Reports generated
    • Seats occupied
    • Successful transactions

Essentially, if you want to charge for something based on how much of it a Customer uses or achieves, you need to define it as a Billable Metric.

Metric vs. Price

It’s crucial to understand that a Billable Metric itself does not define a price. It only defines what is being measured.

  • Billable Metric: What you measure (e.g., API requests).
  • Price: How much you charge per unit of that metric (e.g., $0.001 per API request).

The actual cost is defined later when you create Prices and group them into Plans. A single Billable Metric can have different Prices in different Plans.

Details

When creating a Billable Metric, you need to specify:

  • productId: The ID of the Product this metric belongs to.
  • name: A short, descriptive name for the metric (e.g., API Requests, Input Tokens). This might be shown to customers.
  • description: A brief explanation of what the metric represents.
  • unit: The unit of measurement (e.g., requests, tokens, GB, hours). This is primarily for display purposes on invoices and dashboards.
  • aggregation: How usage should be aggregated over a billing period. Currently, only SUM is supported. This means Sulu will sum up all the reported quantities for this metric within the billing period to calculate the total usage.

Example: LLM Token Billing

Imagine you’re monetizing an LLM service. You want to charge differently for input tokens and output tokens.

  1. Product: You have a Product named “My LLM Service”.
  2. Billable Metrics: You would create two separate Billable Metrics associated with this Product:
    • Metric 1:
      • name: Input Tokens
      • unit: tokens
      • aggregation: SUM
    • Metric 2:
      • name: Output Tokens
      • unit: tokens
      • aggregation: SUM

Later, when creating a Plan, you would define separate Prices for each of these Billable Metrics (e.g., $0.000001 per Input Token and $0.000002 per Output Token).

With your Billable Metrics defined, the next step is to set their cost using Plans and Prices.