Skip to main content
Pro: 1,000 messages a month, never more than 200 a day. Scale: 5,000 credits a period, at most 1,000 of them on GPT-4 each day.
Usage limits pace how a customer spends what they have. A plan grants the allowance; a usage limit caps how much of it any one day, week or month may use, so a runaway script, a shared key or one heavy afternoon can’t drain a month’s allowance or run up your model bill. Ledger counts every window on the same check and track calls you already make, and refuses the use that would pass a limit before anything is charged.

The catalog

Limits go in a plan’s controls.usageLimits, and apply to everyone on the plan:

Windows

Each limit counts in its own window, and the count starts again when the window ends:
  • day and week follow UTC calendar days and Monday-start weeks. With anchor: "billing_cycle", they count in 24-hour and 7-day steps from the billing anchor instead.
  • month counts from the billing anchor, so a customer who subscribed on the 14th resets on the 14th. With anchor: "utc", it follows the calendar month.
  • billing_period is the subscription’s own period, monthly or yearly.
Windows run on the customer’s time, so a test clock moves them, and a customer with no plan counts every window in UTC.

Several limits at once

Stack limits to shape use at every scale: a monthly allowance with a daily ceiling, a pool limit beside a per-model one, a plan’s limit and a customer’s own. Every limit that counts a use applies together, and the use must fit all of them.
  • Per target, interval and filter. A plan can hold one limit for each combination: messages per day and messages per week are two limits; two messages per day limits are one too many.
  • Customer and entity limits. Give one customer, or one of their entities, their own limits with POST /v1/customers/controls. A customer’s limit replaces the plan’s with the same target, interval and filter, and an entity’s replaces the customer’s.
  • Entities inside customers. An entity’s own limit counts that entity’s use, inside the customer’s limit, which counts everyone’s.

Properties and filters

Send properties with a check or track to describe the use, and a limit with a filter counts only the uses that match:
This use counts toward { "model": "gpt-4" } and toward any limit with no filter. Values match by type and value, so true and "true" are different, and numbers compare as numbers. Properties are matched against filters only; Ledger doesn’t store them.

What check and track return

A use that fits every limit is answered as usual. The use that would pass one is refused whole, before anything is charged or counted:
Response (409)
used is the window’s use before this one, reservations still held included, and source says which level set the limit: plan, customer or entity. check answers allowed: false with reason: "usage_limit_reached" and the same usageLimit, so your app can say “You’ve reached today’s limit; it resets at midnight UTC” before the work starts. Read every limit in force, with its used, remaining and resetsAt, from GET /v1/customers/controls.

Rules

  • All or nothing. A use that would pass a limit is refused whole, an AI token call included, even where the balance would cover part of it; one that lands exactly on it is allowed.
  • Balance first. A customer out of credits gets insufficient_credits, and one past their allowance limit_reached, before any usage limit is counted.
  • Reservations count while held. A reservation’s hold counts toward the window, on credits and metered features alike. A settle at or below the hold always succeeds and frees the rest; one above it must fit, or it’s refused whole with 409 usage_limit_reached and the hold kept.
  • Overage stops at the limit. Use a limit refuses is never billed, so a daily cap on a metered item with overage caps its overage bill too.
  • Changes apply at once. Limits change in place for everyone on the plan, with no new version. A limit lowered below what’s used refuses the next use, and a new limit starts counting at 0. A draft’s limits change in place too, and promoting the draft makes them the plan’s.
  • Credits and metered features. A limit targets a credits feature, a metered feature or the pool, once per target, interval and filter (400 invalid_usage_limit from POST /v1/customers/controls). Held and boolean features have limits of their own.
  • Properties. Up to 20 keys of 1 to 64 characters, each a string (up to 255 characters), a number or a boolean.
  • Up to 50 limits on each plan, customer or entity.