Monetization Demo
Interactive monetization demo, running live in your browser.
The particle decision field simulates various types of usage happening over time. Each color represents an entitlement-credit pair. The particles that make it across the line are allowed (allow(...) -> true), and the usage they represent is monetized accordingly.
This is actually running Limitr (@formata/limitr within React) in your browser via WebAssembly.
Controls are simplified for obvious reasons — they change the policy directly. Limitr Cloud works similarly — updates are streamed real-time to clients anytime your policy is updated.
Simulation
Loading the runtime…
How it works
Uses the @formata/limitr npm package with React and Chart.js for UI & graphing.
The policy is kept simple — we define 4 credits for our usage particles, and 1 credit for keeping track of denials, just for the charting you see above (wouldn't add this in real life).
- Revenue Graph — All overage charged to the customer over time (revenue captured).
- Overhead Graph — Entire cost-to-deliver over time (all vendor/overhead costs).
- Margin Graph — The portion of revenue kept over time.
- Usage per credit — Meter value graphed for each entitlement-credit pair.
- Denials — The total number of denials (
allow(...) -> false) over time.
Spend caps in observe mode are used to capture all revenue and overhead metrics for charting. They are set to observe only and reset every minute. Both are used together to determine live margin.
These are never simple usage x price calculations, since prices, overheads, limits, etc. are changing all the time. They do in real life also per customer, per override, per contract dates, etc.
Demo Setup
- Create the Limitr policy:
await Limitr.new(policyYaml, 'yaml'). - Create a customer on the
demoplan. - Add revenue observation spend cap (in
usd) to the demo customer. - Add overhead observation spend cap (in
usd) to the demo customer. - Every particle carries a kind and quantity, calls
policy.allow(...)every time it hits the decision line, continues on if allow returns true. - Add event handler (listens to
meter-limit,meter-changed,meter-overage,meter-reset) that adds current values, revenue, overhead, and margin to a dataset. - Graph that dataset — redraws every time an event is seen and the dataset changes
- Add simple UI controls for changing policy prices, etc.
- You now have the demo you see above...
For the particle spawn rates and quantity ranges, each particle is one of 4 kinds. Higher weights get spawned more frequently, and the amount will fall somewhere within the associated range (inclusive).
const demoKinds = [
{ kind: 'tokens', label: 'AI Tokens', color: '#5b8dee', weight: 3, amountRange: [500, 4000] },
{ kind: 'seats', label: 'Seats', color: '#9b7ede', weight: 1, amountRange: [-1, 3] },
{ kind: 'outcomes', label: 'Outcomes', color: '#4dbbb0', weight: 2, amountRange: [1, 5] },
{ kind: 'storage', label: 'Storage (MB)', color: '#c9a227', weight: 2, amountRange: [1, 10] },
];
Policy
A single plan with the following (starting) entitlements for usage control & monetization:
- tokens — charging $4/MTok, overhead of $3/MTok, 1000 included with plan every 20s, overage allowed & billed.
- seats — charging $5/seat for overage, no overhead cost, hard limit of 10 seats (no overage allowed, no charges), resets every 60s for better graphs.
- outcomes — charging $0.25/outcome, overhead of $0.1/outcome, 20 included with plan every 10s, overage allowed & billed.
- storage (MB) — charging $0.003/MB, overhead of $0.001/MB, 5 MiB included with plan, overage allowed & billed, resets every 60s for better graphs.
policy:
credits:
token:
price: { amount: 0.000004 }
overhead_cost: 0.000003
stof_units: int
seat:
price: { amount: 5 }
overhead_cost: 0
stof_units: int
outcome:
price: { amount: 0.25 }
overhead_cost: 0.10
stof_units: int
mb_storage:
price: { amount: 0.003 }
overhead_cost: 0.001
stof_units: MB
denial: # for denial graph over time
stof_units: int
plans:
demo:
label: Demo Plan
entitlements:
tokens:
limit:
credit: token
mode: soft
value: 1000 # included with plan (not billed)
minimum: 0
resets: true
reset_inc: 20s
seats:
limit:
credit: seat
mode: hard
value: 10
minimum: 0
resets: true
reset_inc: 60s
outcomes:
limit:
credit: outcome
mode: soft
value: 20
minimum: 0
resets: true
reset_inc: 10s
storage:
limit:
credit: mb_storage
mode: soft
value: 5MiB
minimum: 0
resets: true
reset_inc: 60s
denials:
limit:
credit: denial
mode: observe
resets: true
reset_inc: 1min