Skip to main content

Limits, keys and headers

A project has a rate ceiling set by the operator and spend caps you set yourself. Every metered answer says where the rate windows stand, GET /v1/account reads it all at once, and a key can be narrowed to what it needs.

What the limits are, and how to ask for more, is on Rate limits and spend caps. This page is the HTTP side.

Spend caps​

Cap what a project can spend in a day, a week or a month, on top of the credit balance; whichever is lowest applies. Set them on the project's Limits page on the platform (an owner or admin), or from a key over the API. Amounts are micro-dollars (1,000,000 is $1), and 0 or an omitted field means no cap on that window. Windows are calendar UTC: the day from 00:00, the week from Monday, the month from the 1st.

# the caps, and spend today (against the ceiling), this week and this month (against their caps)
curl -s https://api.jevlin.ai/v1/limits -H "Authorization: Bearer $JEVLIN_API_KEY"

# a $5 a day and $50 a month cap; a window left out is left as it is
curl -s https://api.jevlin.ai/v1/limits \
-H "Authorization: Bearer $JEVLIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"daily_micros": 5000000, "monthly_micros": 50000000}'
  • GET returns the project's tenant_id, the three caps under limits (daily_micros, weekly_micros, monthly_micros), today with spent_micros, ceiling_micros and remaining_micros, and week and month, each with spent_micros, cap_micros and remaining_micros. ceiling_micros is the daily ceiling the router is enforcing: the lowest of the credit balance and your caps. A week or month with no cap has no remaining_micros, because it is bounded by the balance, which is not here.
  • POST takes daily_micros, weekly_micros and monthly_micros. It is a partial update and needs the limits scope, or a key with no scopes.
  • A cap set through the API binds on the platform's next sweep, up to a minute later; one set on the platform's Limits page binds within seconds.
  • Reaching a cap answers 402 spend_ceiling. Raise or clear the cap, or wait for the window to start over. A search is charged after it runs, at its real cost, so the request that crosses the ceiling completes and the next one is refused.

Reading or setting caps spends nothing and works when the account is at its ceiling or out of credit, so a capped account can always raise its own budget.

The account​

GET /v1/account is one read of what the router knows about the calling key and its project:

  • tenant_id, and the key's id, label, scopes and expires_at (for an unclaimed agent, when its claim window closes);
  • rate: per_minute, burst, per_hour and concurrent (0 is no limit), and the windows as they stand, remaining_minute, remaining_hour, reset_minute and reset_hour: the same counts as the headers below, without making a search, but with the resets as RFC 3339 instants where the headers use Unix seconds;
  • spend: today against the enforced daily ceiling (daily_ceiling_micros, 0 for none, spent_today_micros, remaining_today_micros, credits_exhausted), the week's and the month's spend (remaining_week_micros and remaining_month_micros only when that window has a cap), when each window resets, and non_search_exhausted: true when the credit left is only the part of the weekly allowance kept for search, so fetch and decisions answer 402 search_credit_only;
  • caps, the self-set caps; retention (content, training_consent, ttl_days); tiers_allowed and default_tier;
  • console_url, the platform address where the person who owns the key sees the balance.

The credit balance itself is not here: the router does not hold it. Show spend.remaining_today_micros, which is what will be refused next, and send the person to console_url for the balance. The read spends nothing, works at the ceiling, and counts against the rate like any other read.

Rate limits​

Limits are per project, and every key of a project shares them: requests a minute, requests an hour, and requests at once. Every call to api.jevlin.ai counts, the free reads too: traces, limits and the account. The exceptions: POST /v1/turns has a rate of its own, GET /v1/fast-sets is not counted (it still takes one of the requests at once), and GET /healthz is counted against nothing. Traces read on the platform's own pages come from its store and cost your rate nothing.

Every search, stream and turn-end answer says where the two windows stand after it was charged:

headermeaning
X-RateLimit-LimitThe per-minute bucket's size. Absent when the project has no per-minute limit.
X-RateLimit-RemainingWhole requests left in the per-minute bucket. It refills continuously, so 0 is usable again before the reset.
X-RateLimit-ResetUnix seconds at which the per-minute bucket is full again.
X-RateLimit-Limit-Hour, X-RateLimit-Remaining-Hour, X-RateLimit-Reset-HourThe same three for the per-hour bucket.
Retry-AfterOn a 429: seconds until the next request is back. It can be minutes when the hourly bucket ran out; wait it out, do not spin. On 429 as_of_rate_limited, the seconds until the next dated-search slot is free, at least 1. On 429 outcome_quota_exceeded, the seconds until midnight UTC. 1 on 409 idempotency_in_progress, 503 overloaded and 429 concurrency. On 503 rollouts_store_failed, 1, or 5 while the store is not ready yet; on a delete, 10 while another is running, and up to 60 after one that may still be running.

A 429 from the rate or concurrency limit carries Retry-After and none of the window headers, and so do the router's other gate refusals (the 401s, 402s, 403 scope and 503 paused). A search the router refused after charging the windows (a 400, 403 or 422 of its own, or 429 as_of_rate_limited) carries them. The 402s and 503 paused carry no Retry-After: waiting does not fix a 402, and a pause has no known end.

Safe retries​

A retry of a search that already ran is a second search and a second bill. Send Idempotency-Key with a value unique to the logical request, 1 to 255 printable ASCII characters (a UUID is the usual shape), on POST /v1/search:

whenanswer
The same key and the same body within 24 hoursThe first run's answer, with the same request_id and Idempotent-Replayed: true. Nothing runs or is billed again.
The same key while the first is still running409 idempotency_in_progress. Send it again after Retry-After.
The same key with a different body422 idempotency_key_reused. A bug in how the keys are made; final.
  • "The same body" means the same bytes, not the same JSON: send the retry with the identical body.
  • A refusal is stored too: a request refused for its body replays the same refusal.
  • A replay still counts against your rate, though nothing runs and nothing is billed.
  • An invalid key (empty, too long, a space or a control character) is 400 invalid_request.

Keys are kept per project, in the router's memory: at most 10,000 of them and 24 hours, the oldest going first, and a router restart forgets them all. They are for retrying a request whose answer you did not receive, not for deduplicating a day's work. The stream ignores the header.

Key scopes​

A project's owner or admin can create a key limited to some of three scopes on the project's API keys page:

scopecovers
searchPOST /v1/search, /v1/search/stream, /v1/fetch, /v1/decisions, /v1/turns, /v1/feedback, /v1/judge and /v1/rollouts/outcome, DELETE /v1/rollouts/outcome, and GET /v1/fast-sets
readGET /v1/traces, /v1/traces/{id}, /v1/rollouts/summary, /v1/rollouts/export, /v1/decisions/models, /v1/limits, /v1/account and /v1/fast-sets
limitsPOST /v1/limits

A key with no scopes may do everything. A call outside a key's scopes is 403 scope, with a message naming the missing scope, before any rate counter moves. An agent key's claim-time scope, credits, is a different thing, the platform's grant, and does not limit the search API.

  • Expiry. A key can be created to expire in 1 to 365 days. After that it is refused with the same 401 bad_key as a revoked or unknown key.
  • Rotation. Rotating a key mints a successor with the same label, scopes and limits, and keeps the old one working for an overlap of 1 to 168 hours (24 by default), so a deploy can swap the secret at its own pace.
  • Per-key limits. A key can carry its own requests a minute, burst, requests an hour and requests at once. They sit inside the project's, so a key's limit is only ever tighter. There is no per-key budget; spend caps are per project.

Readiness​

GET /healthz needs no key and answers {"ok": true} when the router is serving, or 503 not_ready while it starts or drains. It carries no version and no provider list, and is counted against nothing. Use it for "is it up", nothing else.