Skip to main content

Modeling OpenAI-style token pricing in Stigg

Bill for model usage by input and output tokens, with different rates per model if needed, and expose a single AI tokens currency to customers.
  1. Create a credit currency (USD):
    • Go to Product catalog → Credits → Add credit type.
    • Set the Name (e.g., USD Credits) and unit labels (e.g., singular: credit, plural: credits).
    • Fractional conversion rates (e.g., 0.002 credits per token) are supported when you configure credit consumption in the plan.
  2. Create metered features using Raw events:
    • Create features for:
      • gpt-X.input_tokens
      • gpt-X.output_tokens
      • (Optional) cached_input_tokens (if you discount cached prompts)
    • Set Feature type to Meter and Meter type to Raw events.
Only Raw events (event-based) meter type is supported for credit consumption mapping. Calculated usage features will not appear in the credit consumption configuration.
  • After configuring the event filters and aggregation method, you will reach the unit name step. Set the singular unit to token — the plural (tokens) will be populated automatically.
  1. Create a prepaid, paid plan:
    • Go to Product Catalog → Plans → +New plan.
    • Plan type: PaidBilling model: Prepaid.
    • See the full plan setup in Prepaid credits.
  2. Add the metered features to the plan’s entitlements:
    • In the plan, scroll to the Entitlements section and click + Add.
    • Search for and select each feature you created (gpt-X.input_tokens, gpt-X.output_tokens, etc.).
    • Click Add to confirm.
This step is required before mapping features to credit costs. If you skip it, the Credit consumption section will show “No matching metered features”.
  1. Map each metered feature to a credit cost:
    • In the plan’s Price section, under Credit consumption, click + Add.
    • Select the metered feature and define the conversion rate, for example:
      • gpt-X.input_tokensA credits / 1,000,000 tokens
      • gpt-X.output_tokensB credits / 1,000,000 tokens
      • (Optional) cached_input_tokens → discounted rate
    • Tip: You can keep the model in the feature name (gpt-4o.input_tokens) or use a generic input_tokens feature with a model dimension in metadata.
  2. Publish the plan by clicking Publish so it’s selectable for subscriptions.
  3. Create a customer:
    • Go to Customers → +New customer and set identifiers you’ll use when reporting events (e.g., customerId, optional resourceId).
  4. Create a subscription to the prepaid plan:
    • On the customer, click Create subscription.
    • Choose the product, the new prepaid plan, and (if applicable) price localization.
    • (Optional) Add Included credits (purchase or promo), set expiration.
    • (Optional) Configure Auto top-up thresholds and caps.
    • Click Create Subscription.
  5. Top up the customer balance:
    • From the customer/subscription view, use Add to credit balance to purchase credits (admin), or let customers self-serve via your checkout flow.
    • Confirm the new Credits balance.
  6. Report events to Stigg (watch the balance draw down):
  • For every request, report usage events for the relevant features:
    • featureId: gpt-X.input_tokens or gpt-X.output_tokens
    • customerId (and optional resourceId)
    • event_id (unique), event_timestamp
    • value (token count for that event)
  • Stigg converts tokens → credits using the configured rate at the time of the event, decrementing the prepaid balance in real time.