Skip to content

How Limitry works

Your check reaches Limitry at the location nearest the server that sent it. Each subject’s counts live in one place, so Limitry decides every check for that subject against the same numbers. When a check also draws from a shared pool, such as a team’s, Limitry first reserves the cost on every subject. It charges them only if every limit fits.

Two things follow from this:

  • Counts are exact. Two requests racing for the last unit can’t both get it, and a pool shared by many users is never overspent. Limitry saves every count before it responds, so a limit stays exact even if a server fails.
  • Changes reach checks at once. A new or edited limit applies to the next check. A revoked API key can keep working for checks for up to 60 seconds.

Limitry keeps each workspace’s counts in one region and sets them up before your first check. A brand-new user, team or agent gets a decision as fast as one you’ve checked a thousand times. A check sent from another continent has to cross the ocean to reach those counts, which adds 100 to 200 ms.

Under Settings → General, an owner or admin sets Region to where your servers run: Western or Eastern North America, Western or Eastern Europe, Asia-Pacific, or Oceania. The default, Automatic, keeps your counts in Eastern North America. One setting covers test and live. The card shows the city your live counts are in, and where most of your live checks come from.

Changing the region moves every count, balance and open reservation there in the background. Nothing goes missing or counts twice, and checks keep working while it moves. Your counts move in parts. Each part pauses while it moves, usually for a few seconds and never more than 30. If a part takes longer, Limitry puts it back and tries again later. A check that arrives during a pause gets 503 moving, and the SDKs retry it with the same idempotency key.

The page shows how far the move has got. Limitry saves the new region once everything has moved, and you can’t change it again until then. The region is a preference, not a guarantee. Limitry runs on Cloudflare, and Cloudflare picks the data center within it.

Every limit has a fail mode, which you choose per limit:

  • open, the default: your code goes ahead as if allowed.
  • closed: your code says no, as if Limitry had refused the check.

The SDK applies it for you. When Limitry doesn’t respond within 1.5 seconds, or returns a 429, a 5xx or 402 plan_limit_reached, guard and reserve fall back to the fail mode of the limits they saw last. Under closed, they throw UnavailableError. That’s a different error from a refusal, which throws LimitReachedError. Choose closed where overspending would hurt more than refusing, such as an agent’s spending budget.

A concurrent limit that fails open still holds. While your code can’t reach Limitry, reserve runs at most the limit’s amount at once in your process, and throws UnavailableError beyond that. See Rolling windows and concurrency.

Limitry counts a check sent with an Idempotency-Key header only once. For an hour, repeating it with the same key returns the same decision and counts nothing. Keys on commits, releases and resets last 24 hours, and a key on a credit never expires. guard, reserve, the SDKs and the CLI send a key for you and retry with it. Committing or releasing a reservation is safe to retry too. See Idempotency.

A reservation that nobody commits or releases gives itself back when it expires, after 5 minutes by default. A worker that crashes in the middle of a job never leaves a user blocked or a concurrency slot taken.

  • Your limits, plus a record of every change to them in the workspace’s audit log.
  • Hourly counts for each limit and subject, kept as long as your plan keeps history. Usage lists how long each plan keeps them.
  • The subject kinds and ids you send. Limitry attaches no meaning to them, so send your own opaque ids such as user_123, not names or email addresses.
  • Any names and labels you give subjects. They’re optional, and DELETE /v1/subjects/{subjectKind}/{subjectId}/names erases them. See Subjects, names and links.
  • Each check of the last 3 days: the subjects it named, its action and cost, and whether Limitry allowed it. Limitry keeps at most 100,000 in each environment.

Limitry never sees the work itself, such as prompts, model output or files. A check carries a subject, an action name and a number.

Every workspace has a test environment and a live environment, each with its own limits, counts, balances, reservations and usage. The API key decides which one a check uses: lim_test_… or lim_live_…. Test checks can’t move live counts, and they have their own allowance that isn’t billed. See Test and live.

An API key belongs to a workspace and one environment. Its scopes say what it may do: checks:write to check, and limits:read and limits:write to read and manage limits. Give each service the narrowest key it needs. Personal access tokens act as the person who created them. See Authentication.