Skip to main content
credit-estimator is a separate open-source project, published to npm under the @tansohq scope. It forecasts credit or usage runway from observed history and explicit low/base/high burn assumptions, and renders the result as an accessible React widget. It is provider-neutral: the deterministic core and React UI have no Tanso dependency and work the same way for any host. An optional adapter maps a Tanso snapshot into the same neutral input any other host would supply.
This is a read-only forecasting tool. It does not own wallets, ledgers, usage events, entitlements, subscriptions, or payments — it projects a balance from data you supply. It never writes back to Tanso.

Packages

All are ESM-only; CommonJS hosts need dynamic import(). React peers are ^18.2 || ^19.

Calculate a forecast

All credit values are canonical decimal strings, not floats. The core reads no clock, filesystem, network, or credentials — asOf is explicit, and invalid input throws a structured ForecastValidationError.

Plan credits before committing

The same core package answers the buyer-side question — “how many credits does this period need?” — with no usage history:
Each metric’s planned credits is estimatedUnits × creditsPerUnit, scenarios scale that by their multipliers, and the optional allocation yields utilization, surplus or shortfall, and a WITHIN_ALLOCATION / OVER_ALLOCATION status per scenario. Everything is an explicit input — the calculator never recommends weights or allocations, never produces money amounts, and never predicts usage from history. Invalid input throws a structured PlanValidationError. For a Tanso host, no adapter is needed: creditsPerUnit is the resolved weight your tariff returns as creditQuote.weight, and allocation is the candidate credit grant. The React package renders it with buyer-facing defaults (Conservative / Expected / Aggressive scenario labels, an allocation meter, a per-metric breakdown, and the calculation trace):

Embed the widget

The component is result-controlled: you calculate (in your browser or your backend) and pass both input and result in as props. It has no fetch, authentication, persistence, or billing dependency, so it never resolves a stale forecast on its own. Theme it with the --credit-burndown-* CSS variables, override any message string, inject your own action slot, and control the selected scenario from outside.

Feeding it from Tanso

@tansohq/credit-forecast-tanso maps a Tanso snapshot plus explicit assumptions into the same ForecastInput any other host would build by hand:
The adapter does not fetch data, call a Tanso API, or reconstruct a balance — you assemble snapshot from your own authenticated call to the credits Client API, such as a pool’s /pools/{poolId}/transactions history. There is no automatic Tanso source connector. Mapping failures throw TansoMappingError, whose toJSON() returns { code: "TANSO_MAPPING_FAILED", issues }.
Tanso remains authoritative for actual balances, grants, deductions, and billing state. The forecast is a projection from the snapshot you supplied at call time — if it and Tanso’s current state have since diverged, refetch the snapshot and recalculate. Nothing in this package reserves credits, alters an entitlement decision, or writes back to the ledger. See the optional Tanso adapter boundary for the full contract, including what the adapter is forbidden from doing.