Skip to content

dev-formata-io/limitr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

150 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Limitr is an in-process usage runtime that decides what every user and agent is allowed to do, and what it costs.

Quickstart

npm i @formata/limitr
// wasm runtime, works anywhere, no system dependencies
import { Limitr } from '@formata/limitr';

// Tell Limitr what users can do, how much they have, and what you charge for it
const policy = await Limitr.new(`policy: {
  credits: {
    claude_sonnet_5: { overhead_cost: 2e-6, price: { amount: 3e-6 } }
  }
  exchange: { euro: { value: 1.14, currency: 'usd' } }
  plans: {
    pro: {
      entitlements: {
        ai_chat: { limit: { credit: 'claude_sonnet_5', value: 10_000, resets: true } }
      }
    }
  }
}}`);

// High-level observability & enforcement caps - credit grants, overages, credit exchanges, etc.
await policy.startMarginMeasurement(userId, 'ai_pipeline', 'euro');

// Enforce usage limits and block calls that you or users don't want to pay for
if (await policy.allow(userId, 'ai_chat', tokens)) {
  callLLM(prompt);
} else {
  alert('Limit hit, purchase more or wait');
}

const { charged, costs, margin } = await policy.captureMarginMeasurement(userId, 'ai_pipeline');
// User charged: €0.03 · Overhead cost: €0.04 · Pipeline Margin: -28.51%

Cloud

Limitr Cloud adds managed policies, alerting, billing & payment integrations, and per-customer/per-feature/per-vendor analytics on top of the same engine. Learn more →

import { Limitr } from '@formata/limitr';

// Managed & always in-sync - no-code & versioned policy changes without redeploys
// No network calls in any hot paths, just a web socket in the background
const policy = await Limitr.cloud({ token });

// Everything else stays the same

What Limitr Is

Everything that used to live in scattered code, webhooks, and spreadsheets now lives in one place — a policy document that Limitr reads and uses to decide what every user and agent is allowed to do, and what it costs.

Define plans, entitlements, credits, prices, overhead, and governance as a single config. Limitr manages user state, checks, and balances inside a local WebAssembly container.

It's a fast, secure, and maintainable way to ship pricing and packaging for modern software.

Why It's Different

  • Usage policy as configa maintainable config document instead of custom code.
  • Native executionexecutes 100% locally, in-process, event-driven, sandboxed, extensible, & flexible.
  • Hybrid modelsany pricing model, in the same policy without having to choose.
  • Real per-user marginsmaps vendor costs to your prices for margins computed on every request.
  • Credit exchangedefine credit exchanges/rollups for credit burndown models & currency exchanges.

Where This Came From

Stof comes out of a decade spent building parametric and geometry formats for CAD and graphics systems.

Limitr started as an internal Stof project while trying to control margins at the pace of AI model development and at the pace we now ship code.

We really wanted a config that was easy to reason about and collaborate on, that when changed, our marketing sites, front-end apps, and backend services all enforce and reflect the new usage limits, packaging, and prices immediately, without redeploys & coordination.

Friends wanted it available to them, and thus it's available to you, too.

Advanced & Enterprise

Larger orgs, product, finance, sales, and engineering teams have requested a platform beyond embedded enforcement, where they can manage custom dealflow, product agility, and per-customer/vendor margin & analytics.

If this describes you, your org, or your needs, Limitr Cloud is for you.

Learn More

License

Apache 2.0. See LICENSE for details.

About

In-process usage runtime that decides what every user and agent is allowed to do, and what it costs.

Topics

Resources

License

Stars

7 stars

Watchers

2 watching

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors