Flagsmith tells you which variant converts. FlagLedger tells you which one pays for itself: net margin per flag variant and per user cohort, plus a fix you approve in one click.
$docker compose up -dEvery new AI feature ships behind a flag. Flagsmith knows who saw which variant and whether they converted. Your LLM and cloud costs live somewhere else, as one unlabelled number on an invoice.
Nobody can open a flag and see what it burns per hour, or whether its winning variant earns more than it costs.
Free users search the most and pay nothing. A variant that lifts upgrades by 77% can still lose money on their token bill.
Turning the feature off for everyone loses the Pro users who renew because of it. The fix belongs to one cohort, not the whole flag.
FlagLedger breaks every variant down by the traits you already send to Flagsmith. Here the AI search pays for itself with Pro users and leaks money on the free plan.
2,000 identities · 80% free · 20% pro
control $0.0004/search · ai_summary $0.014/search
Every launch has a cost spreadsheet: price per call × calls per user. The price is easy to look up. The usage is a guess, and the better the feature works, the more people use it, so the better the A/B result, the more wrong the estimate.
The price was close. The loss came from usage: free users run about 45 AI searches a week and pay nothing. The spreadsheet’s average hid it; the per-cohort ledger shows it on the screen where you decide to ship.
One extra call after each paid request, through the same SDK and pipeline as your exposures and conversions.
// after the LLM call
flagsmith.trackEvent('cost', {
identifier: user.id,
value: usage.costUsd,
metadata: { feature, variant, plan },
})Exposures, conversions and cost are joined by identity and trait, so you see which variant and which cohort earn or burn.
FlagLedger drafts the rule. You approve it with your own Flagsmith account, so the audit log shows who changed what.
+ segment free_tier_cost_guardrail
plan EQUAL "free"
+ override search_bar_mode
{"mode":"ai_summary","daily_quota":2}One Compose file starts Flagsmith, its task processor, Postgres and FlagLedger. A one-shot setup creates the project, flag, metrics, warehouse connection and experiment for you. No ClickHouse, no Kafka.
$ git clone <this repo> && cd flagledger $ cp .env.example .env # set secrets $ docker compose up -d flagsmith healthy :8000 flagledger-init done experiment running flagledger ready :3000
No. FlagLedger is built for open-source, self-hosted Flagsmith with Experimentation enabled. Events stay in Flagsmith’s own Postgres.
Your app sends them as a `cost` event after each paid call, using the token usage and your price table. The NoteFlow example uses simulated traffic, but its price per AI search is measured: FlagLedger runs the real feature through Claude and prices each call from the token bill ($0.0127 on Opus 5.5, $0.00036 on Haiku 5.5).
Never. FlagLedger only drafts the override. Nothing is written to Flagsmith until a signed-in person approves it, using their own account.
Any multivariate flag whose events carry the feature, variant and plan in metadata. NoteFlow search is the sample.