Rate limits and budgets
How the gateway meters you: rate_limited versus budget_exhausted, the rate-limit headers, spend caps, and reading your live headroom.
Two separate controls can refuse a request with 429: a rate limit on how
fast you send requests, and a budget on how much you spend. The body's
code tells you which one you hit, and they need different handling. Your
account's limits are shown in your Console, and GET /api/v1/limits returns
them, with live headroom, to your code.
rate_limited or budget_exhausted
| rate_limited | budget_exhausted | |
|---|---|---|
| What ran out | Request rate: too many requests in the current window. | Allowance: the plan's monthly cap, its 12-hour burst pool, or the monthly epos request cap is spent. A developer key that has used the plan's API share reads api_share_exhausted instead. |
| What to do | Back off and retry after Retry-After. | Stop retrying. No immediate retry succeeds. |
| Clears | When the rate window resets. | At reset_at, when the spent window resets. |
| Headroom | rate_limits.chat on GET /api/v1/limits | token_pool and api_share on GET /api/v1/limits |
Spend caps refuse with 429 too, under their own codes: a monthly cap on a
key (key_spend_cap_exceeded), a monthly cap on a workspace
(workspace_spend_cap_exceeded), and the credit pool (credits_exhausted).
Like budget_exhausted, they mean an allowance is spent, and they clear only
at reset_at or when the cap changes. Every 429 carries Retry-After; on
these codes and on budget_exhausted it counts down to reset_at, and
retrying sooner fails the same way.
POST /api/v1/moderations never returns budget_exhausted: moderation is
exempt from the subscription pool, so a spent allowance cannot switch it off.
It can still return rate_limited or a spend-cap code.
Rate-limit headers
Metered responses carry the state of the bucket the route is metered on:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | Requests allowed per window. |
X-RateLimit-Remaining | Requests left in the current window, never below 0. |
X-RateLimit-Reset | When the current window ends, as an absolute Unix time in seconds, not a duration. |
Retry-After | On every 429, the seconds to wait. On a budget or spend-cap refusal, the seconds until reset_at. |
The X-RateLimit-* headers always describe the per-minute request window, so
a budget refusal can still show requests remaining.
The X-RateLimit-* headers are absent on a 401, because authentication runs
before the limiter, and on a 403 from the key check (key_scope_forbidden,
key_read_only). They are also absent when the limiter cannot reach its own
storage; that request is served unmetered, or refused with 503
limits_unavailable where the deployment fails closed.
# -D - prints the response headers; look for X-RateLimit-* and, on a 429, Retry-After.
curl -s -D - -o /dev/null https://api.cruxy.ai/api/v1/limits \
-H "Authorization: Bearer $CRUXY_API_KEY"// These clear only at reset_at; every other 429 clears after Retry-After.
const ALLOWANCE_SPENT = new Set([
'budget_exhausted',
'key_spend_cap_exceeded',
'workspace_spend_cap_exceeded',
'credits_exhausted',
])
const res = await fetch('https://api.cruxy.ai/api/v1/chat', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'epos',
stream: false,
messages: [{ role: 'user', content: 'Hello' }],
}),
})
const remaining = res.headers.get('X-RateLimit-Remaining')
const resetAt = res.headers.get('X-RateLimit-Reset') // Unix seconds
if (res.status === 429) {
const { code, reset_at, request_id } = await res.json()
const waitSeconds = Number(res.headers.get('Retry-After'))
if (ALLOWANCE_SPENT.has(code)) {
// No retry succeeds before reset_at.
console.log(`allowance spent: ${code}, resets at ${reset_at} (request_id ${request_id})`)
} else {
// rate_limited, or a transient headless check: wait Retry-After, then retry.
console.log(`${code}; retry in ${waitSeconds}s (request_id ${request_id})`)
}
} else if (remaining !== null) {
console.log(`${remaining} requests left until ${new Date(Number(resetAt) * 1000).toISOString()}`)
}Pace yourself before you reach 0: when X-RateLimit-Remaining runs low,
slow down until X-RateLimit-Reset rather than waiting for a 429.
Read your limits
GET /api/v1/limits returns the limits that apply to your key, with live
headroom. Every value comes from the same limiter and budget state that chat
enforces, so remaining is exactly what your next request is checked against.
The call costs nothing, writes nothing, and is rate-limited like any other
route.
curl https://api.cruxy.ai/api/v1/limits \
-H "Authorization: Bearer $CRUXY_API_KEY"const res = await fetch('https://api.cruxy.ai/api/v1/limits', {
headers: { Authorization: `Bearer ${process.env.CRUXY_API_KEY}` },
})
if (!res.ok) throw new Error(`limits request failed: ${res.status}`)
const limits = await res.json()
const perKey = limits.rate_limits.chat.per_key
console.log(`chat: ${perKey.remaining} of ${perKey.limit} left this window`)
if (limits.token_pool) {
console.log(`token pool: ${limits.token_pool.state}`) // healthy, low, or blocked
}Everything comes from the key you send; nothing is read from the request.
Which blocks appear depends on your billing bucket:
| Field | Meaning |
|---|---|
object | limits. |
bucket | Which kind of key this is: subscription (a signed-in credential), apikey (a developer API key, which draws on its owner's plan and needs a paid one), or headless (billed from prepaid credits). Both subscription and apikey carry token_pool. Memory and standing rules are on by default only for subscription. |
tier | Your account's plan: free, core, advanced, pro, or max. It sizes token_pool and picks the plan_limits row; see Plan limits. A Pro subscription from the beta reads pro_legacy and has Pro's limits. The field can also read ultra or enterprise. This is not a model tier. |
models | Subscription and developer-key buckets. The chat tiers your plan includes, by public id: saga on Free; epos and saga on Core; all three from Advanced. A request naming another is 403 model_not_in_plan, and auto routes only among these. |
context_window | Subscription and developer-key buckets. plan is your plan's window in tokens (256,000 on Free, 1,000,000 on a paid plan), and models maps each included tier to its effective window, the smaller of the tier's own and the plan's. A turn past it is 400 context_overflow. |
api_share | On every plan with API access. The share of the month's token_pool that developer API keys together may use: share (0.25), cap, used, remaining, state, window (monthly), starts_at, and resets_at, in units. Past it a developer-key request is 429 api_share_exhausted; a signed-in credential is never counted or refused by it. |
rate_limits.chat.max_concurrent_per_key | Developer keys only. How many chat requests this key may have in flight at once, streaming or not, within the account's max_concurrent_requests. One more is 429 rate_limited with reason: concurrency and Retry-After: 1. |
rate_limits.chat.per_key | The chat request-rate window for this key: limit, remaining, resets_at, and window_seconds. resets_at is null until a request opens the window. |
rate_limits.chat.per_org | The same window, for your whole organization. |
rate_limits.chat.max_concurrent_requests | How many chat requests your account may have in flight at once, across all three chat endpoints. One more is refused at once, not queued: 429 rate_limited with reason: concurrency and Retry-After: 1. |
token_pool | Subscription and developer-key buckets. The usage budget behind budget_exhausted, in units. |
plan_limits | Subscription and developer-key buckets. Your plan's row of the limits table: files_per_month, images_per_month, files_per_message, images_per_message, storage_bytes, max_file_bytes, projects, works, and context_window. A count that is null has no fixed cap. The row never changes within a month, so read it once; see Plan limits. |
files, images | Subscription and developer-key buckets, for each kind of upload the plan caps (Max caps neither, so it has neither block). This month's stored uploads against the plan's allowance: cap, used, remaining, state, window (monthly), starts_at, and resets_at. An image is a file whose detected type is image/*; it never spends a file. |
storage | What you hold against the plan's storage pool, in unit: bytes: cap, used, remaining, and state. |
credits | Headless bucket only. The dollar-credit pool: granted, adjustment, used, remaining, and resets_at. |
key_spend_cap | Present only when the key has a monthly spend cap: cap, spent, remaining, and resets_at, in USD. |
workspace_spend_cap | Present only when the key's workspace has a monthly spend cap, in the same shape. |
token_pool has two windows, each with cap, used, remaining,
percent_used, resets_at, and a state of healthy, low, or blocked:
monthly: the cap over your account's own month, withstarts_atbesideresets_at. A paid plan's month is its billing period; a Free account's runs from the day of the month it was created. No allowance runs on the calendar month.burst: the trailing 12-hour sliding cap, on every plan.
Every monthly allowance on the response, token_pool.monthly, api_share,
files, and images, is measured over that same month and resets at the same
instant, the resets_at each one carries. There is no message allowance:
nothing counts messages on any plan. The spend caps are the exception: they
run on the UTC calendar month.
token_pool also carries an overall state, blocked_models, and the unit
(units). While an operator has the Epos request brake on, it carries epos,
a monthly request cap on the epos tier with its own cap, used,
remaining, resets_at, and state. Next to it,
mira carries the same cap under the field's former name, present whenever
epos is and with the same values, so existing code keeps working. Read
epos.
percent_used is used over cap as a percentage from 0 to 100, to one
decimal place, rounded down, so it reads 100 only once the cap is reached.
On a token_pool window it is null when there is no cap to measure
against. api_share, files, images, and storage carry it too. Draw a
usage bar from it instead of dividing used by cap.
There is no tokens-per-minute limit and no per-model daily cap. The gateway enforces neither, so neither appears here.
Read your month so far
GET /api/v1/limits/month returns the month in progress day by day: one entry
per UTC day from the day the month began to today, oldest first, each with a
date and a percent_used. A day's percent_used is the share of the
month's limit used from the start of the month through the end of that day, and
through now for today. It is the same measure as
token_pool.monthly.percent_used on GET /api/v1/limits, over the same
month, so today's entry equals that figure, and the response's starts_at and
resets_at are that window.
curl https://api.cruxy.ai/api/v1/limits/month \
-H "Authorization: Bearer $CRUXY_API_KEY"const res = await fetch('https://api.cruxy.ai/api/v1/limits/month', {
headers: { Authorization: `Bearer ${process.env.CRUXY_API_KEY}` },
})
if (!res.ok) throw new Error(`month request failed: ${res.status}`)
const month = await res.json()
if (!month.enforced) {
// A headless key has no unit pool, so there is no series to draw.
console.log('no monthly limit applies to this key')
} else {
for (const day of month.days) {
console.log(`${day.date}: ${day.percent_used}%`)
}
console.log(`resets ${month.resets_at}`)
}{
"object": "limits.month",
"enforced": true,
"starts_at": "2026-11-19T09:30:00Z",
"resets_at": "2026-12-19T09:30:00Z",
"days": [
{ "date": "2026-11-19", "percent_used": 40.1 },
{ "date": "2026-11-20", "percent_used": 42.3 }
]
}The series has no gaps and never falls: a day with no usage repeats the day
before. The response carries no unit count, cap, or remainder; read
GET /api/v1/limits for those. Like that call, it reads everything from the
key you send, writes nothing, and costs nothing, and it is rate-limited on its
own bucket. A headless key, which draws on dollar credit and has no unit pool,
gets enforced: false and an empty days.
Budgets and auto
A request with model: "auto" may be budget-downgraded to epos. Read
cruxy.routed_tier on the response to see the tier that served it, rather than
assuming the router's first choice; see
Auto routing.
Next steps
- Plan limits: what each plan allows, every plan's entitlements from
GET /api/v1/limits/plans, and when each allowance resets. - Errors and retries: every
429code, and a retry loop that honoursRetry-After. - Features overview: the tiers and
auto. - Get your API key: key restrictions, including spend caps.