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.-
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.002credits per token) are supported when you configure credit consumption in the plan.
-
Create metered features using Raw events:
- Create features for:
gpt-X.input_tokensgpt-X.output_tokens- (Optional)
cached_input_tokens(if you discount cached prompts)
- Set Feature type to Meter and Meter type to Raw events.
- Create features for:
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.
-
Create a prepaid, paid plan:
- Go to Product Catalog → Plans → +New plan.
- Plan type: Paid → Billing model: Prepaid.
- See the full plan setup in Prepaid credits.
-
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”.
-
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_tokens→A credits / 1,000,000 tokensgpt-X.output_tokens→B 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 genericinput_tokensfeature with amodeldimension in metadata.
- Publish the plan by clicking Publish so it’s selectable for subscriptions.
-
Create a customer:
- Go to Customers → +New customer and set identifiers you’ll use when reporting events (e.g.,
customerId, optionalresourceId).
- Go to Customers → +New customer and set identifiers you’ll use when reporting events (e.g.,
-
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.
-
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.
- Report events to Stigg (watch the balance draw down):
- For every request, report usage events for the relevant features:
featureId:gpt-X.input_tokensorgpt-X.output_tokenscustomerId(and optionalresourceId)event_id(unique),event_timestampvalue(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.
