rate limiting for AI apps

Limit by who they are, not where they are.

Cloud rate limiters count requests per IP. Your costs come from users, workspaces and tiers — and from tokens, not requests. Lymit runs inside your code and deducts real LLM cost from a per-user budget at the edge. No Redis to run.

Continue with GitHubRead the docsno credit card · live key in 60 seconds
terminal

The bill arrives per token.

One user in a retry loop, one abusive script, one generous free tier — an LLM feature can spend a month’s budget in an afternoon. A load balancer can’t see prompt length, and an IP limit can’t tell a paying customer from a bot behind the same NAT.

Lymit’s token bucket is the missing primitive: a refilling budget per userId, workspaceId or tier, charged with the estimated cost of each call before you call the model.

Three steps, one dependency, none to operate.

  1. 01

    Install

    npm install @lymit/sdk. Zero dependencies. Node, Bun, Deno, Cloudflare Workers.

  2. 02

    Declare

    Name a namespace and its algorithm in code — fixed window, sliding window, or a token bucket for AI budgets.

  3. 03

    Limit

    Call limit(identifier, { cost }) with the user, workspace or tier you already have. Change limits later from the dashboard — no redeploy.

app/api/generate/route.tsts
1import { Lymit } from "@lymit/sdk";23const lymit = new Lymit({ apiKey: process.env.LYMIT_API_KEY });45const ai = lymit.namespace("ai_generation", {6  algorithm: "tokenBucket",7  capacity: 5000,   // tokens per user8  refillRate: 1000, // per hour9  interval: "1h",10});1112const { success, remaining } = await ai.limit(user.id, {13  cost: estimatedTokens,14});

Why there’s no Redis.

single writer per key · SQLite at the edge

Each namespace gets its own single-threaded counter — a Cloudflare Durable Object with SQLite storage, placed near your servers. A check is one in-memory operation with no locks, no compare-and-swap and no cluster to run. Decisions stream to an edge SQLite database for your dashboard, off the request path.

Your app
@lymit/sdk · one fetch · zero deps
Edge API
Cloudflare Worker · auth · config · quotas
Counter
Durable Object · SQLite · one per namespace
11–23 ms
p50 measured from Cloudflare's edge in Sydney, London, Frankfurt, New York, Dallas, Toronto and Los Angeles — 5–8 ms of it inside our Worker
0 ms
of telemetry on the request path — events are batched behind the response
1
dependency in your app, and it has none of its own

Add your distance to the nearest Cloudflare location. Regions without Durable Object hosting nearby (South America, Africa, India today) pay one longer hop. Every number we quote is measured and published with its method.

Priced by requests. Start free.

Hobby

$0 forever

  • 10 000 requests / day
  • Fixed & sliding window
  • 7-day analytics
  • Zero-DevOps edge network
Get started

Pro

most popular

$29 per month

  • 1 000 000 requests / month
  • Token bucket for AI budgets
  • Dashboard overrides, no redeploy
  • 30-day analytics
  • $0.05 per 10k overage
Get started

Enterprise

from $149 per month

  • Custom SLAs
  • Dedicated event database
  • Global region priority
  • Sharded hot namespaces
Talk to us