Prevent Unexpected Credit Charges: Preview Costs Before Executing Actions
Stigg now provides dedicated estimation endpoints for usage events and usage measurements.
The estimation uses the same credit calculation logic as actual usage consumption, but does not ingest the event or deduct credits.
For each relevant credit currency, the response includes:
estimatedCost— The number of credits the usage would consumecurrentBalance— The customer’s current credit balancebalanceAfterEstimate— The projected balance after the estimated consumptionwouldOverdraft— Whether the operation would take the balance below zerobreakdown— A per-feature breakdown of the estimated credit costwarnings— Any limitations or unsupported calculations encountered during estimation
Estimations support both customer-level and resource-level usage, including custom event dimensions.
⭐️ Why It Matters
For products with dynamic pricing models, such as LLM workflows, media rendering, or multi-step API pipelines, the credit cost of an action isn't always known up front.
Credit cost estimation enables you to:
- Build pre-flight confirmation flows: Show customers an accurate estimate before launching an expensive task (e.g., "This image generation will cost ~15 credits. Proceed?").
- Prevent mid-task overdrafts: Evaluate
wouldOverdraftto block heavy jobs before execution if a user lacks sufficient credits. - Eliminate calculation drift: Ensure UI estimates perfectly match actual deductions by relying on Stigg's engine rather than re-implementing billing math in your frontend.
⚠️ Current Limitations
- Aggregation types: For event-based estimation,
COUNTandSUMaggregations are supported.UNIQUEandMAXare not currently supported as they rely on historical aggregation state. - Routing: Estimation endpoints are served through the standard Stigg REST API and are not currently routed via the Edge.
📦 Availability
Credit cost estimation is available now through the Stigg REST API and the following REST SDK versions or later:
- TypeScript: v0.1.0-beta.43
- Python: v0.1.0-beta.38
- Go: v0.1.0-beta.39
- Java: v0.1.0-beta.37
- Ruby: v0.1.0-beta.41