Skip to content

Limits and retries

This guide describes the limits that apply to requests to the Inola API, how the API answers when one is reached, and how a client repeats a request: when, after how long, and when not at all. It needs an API key; the retry code needs Python 3.10 or later with requests, or Node.js 18 or later.

limitapplies towhen reached
requests per minute (RPM)the organization and the model429 rate_limited with Retry-After
tokens per minute (TPM)the organization and the model429 token_rate_limited with Retry-After
monthly tokens of a model (plans that have them)the organization and the model429 monthly_token_limit until the next billing period
monthly documents of a model (plans that count documents)the organization and the model429 monthly_document_limit until the next billing period
the monthly spend limit set in the consolethe organization429 spend_limit_reached until the next period or a higher limit
unfinished batch workthe organization, across all models429 batch_queue_limit on POST /v1/batches
batch work per completion windowthe organization429 batch_window_limit on POST /v1/batches
balance or paymentthe organization402 payment_required until a top-up or the payment goes through
document length: the model’s maximum in tokenseach document413 too_long; split the document
request body sizeeach request413 body_too_large

The values depend on your plan. They are not written on this page:

  • GET /v1/models lists, for each model, the limits of your plan (rpm, tpm, monthly_tokens, monthly_documents; null when the plan has no such limit) and the maximum document length of each version (context_window);
  • the console (https://console.inola.ai, section Billing) shows what each plan includes.

Short documents usually reach the request limit first, long ones the token limit. The per-minute limits are shared by all keys of the organization.

Every response carries the current state of the per-minute limits of its model:

headermeaning
X-RateLimit-Limit-Requestsrequests per minute of the plan
X-RateLimit-Remaining-Requestsrequests left
X-RateLimit-Reset-Requeststime until the request limit is full again, such as 6s
X-RateLimit-Limit-Tokenstokens per minute of the plan
X-RateLimit-Remaining-Tokenstokens left
X-RateLimit-Reset-Tokenstime until the token limit is full again
Terminal window
curl -sS -i "https://api.inola.ai/v1/infer" \
-H "Authorization: Bearer $INOLA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "cordon-mini", "input": {"state": "Opening hours: 9 to 17 on weekdays."}}'

A 429 is a limit of your plan unless its error.code is overloaded or serverless_cold (our capacity, see below). The body of a plan’s limit says which limit was reached and, when there is one, what the next plan allows:

fieldmeaning
error.codethe limit code, as in the table above
error.messagethe same in words, for example <plan> plan limit reached: <value> requests/min for <model>. followed by what the next plan allows
error.limit.namerequests_per_minute, tokens_per_minute, monthly_tokens, monthly_documents, spend_limit, batch_queue_chars or batch_window_chars
error.limit.valuethe value of the limit on your plan
error.limit.unitrequests, tokens, documents, currency or chars; currency (the spend limit) is an amount in euros (EUR)
error.limit.window1m, month, completion_window, or null for unfinished batch work
error.limit.modelthe model the limit belongs to, for per-model limits
error.limit.reset_atwhen the limit lets requests through again (ISO 8601); null for batch limits, which free up as batches finish
error.planthe code of your plan
error.upgradethe next plan: plan, value (its value of the same limit) and url (where to change the plan); or contact_url when there is no next plan; absent for spend_limit_reached, a limit you set yourself
error.doc_urlwhen present, the section of this code on Error codes

Retry-After (seconds) is the API’s estimate of when the request will pass, not a constant:

  • per-minute limits (rate_limited, token_rate_limited): the time until enough capacity refills;
  • monthly limits and the spend limit: the time until the next billing period (error.limit.reset_at);
  • 429 overloaded and 503 unavailable: the expected time until the request can be served;
  • 507 storage_full: the time after which it is worth sending the request again (the storage is measured on every file and batch request);
  • 429 serverless_cold: only when the model is starting — the expected time until it serves real-time requests; without the header there is no such estimate.

When the service is temporarily over capacity, the answer is 429 overloaded — not a limit of your plan: read error.code to tell it from the plan’s limits, which answer 429 too. A model that is not served at the moment answers 503 unavailable. Both carry Retry-After. A real-time request to a model that is not running now — most often one that runs on on-demand capacity, but any model while its regular capacity is down — may be held while the model starts — the answer can then take several minutes, so give such requests a timeout of at least 11 minutes — or be answered 429 serverless_cold (at once, or when the model did not become ready within that wait); a key of the Free plan is never held — it gets that answer at once. That answer carries Retry-After only when the model is starting; without it send the documents through the Batch API.

When the storage for batch files cannot take one more batch, POST /v1/files and POST /v1/batches answer 507 storage_full with Retry-After. It is not a limit of your plan and nothing was stored or billed. Send the request again after Retry-After seconds; the service frees space on its own. Batches already accepted keep running, and real-time requests are not affected.

429 unused_uploads_limit: too many files no batch uses

Section titled “429 unused_uploads_limit: too many files no batch uses”

Files you upload and do not use in a batch yet are bounded twice: per API key (by default two files of the maximal size: one ready for a batch and one being prepared) and per organization, by the volume your plan gives to such files, whatever number of API keys uploads them. Uploads in progress count with their declared size (Content-Length). Over either limit, POST /v1/files answers 429 unused_uploads_limit; other organizations are not affected. Create batches from the uploaded files or delete the ones you do not need (DELETE /v1/files/{id}), then upload again. The volume of the plan is in the console, on the plan’s page.

statusrepeat?how
429 per-minute limitsyesafter Retry-After
429 monthly limits, spend limitnot until the period endsRetry-After is the time to the next period; a higher limit or plan in the console lifts it sooner
429 batch limitslaterafter earlier batches finish, or with a smaller batch
429 overloaded, 503yesafter Retry-After
429 serverless_cold without Retry-Afternosend the documents as a batch
500yeswith growing pauses (exponential backoff)
no response (network error, timeout)yeswith growing pauses
400, 401, 402, 403, 404, 410, 413nothe same request gets the same answer; the cause is fixed first

Rejected requests are not billed, so repeating after Retry-After costs nothing until the request passes.

The functions below send a real-time request and repeat it by the rules above. They return the last response, so the caller sees a 429 of a monthly limit or any client error.

Save as retry.py and run python retry.py.

"""POST to the Inola API with the retry rules of the API.
Python 3.10 or later, `pip install requests`, key in INOLA_API_KEY.
"""
import os
import random
import sys
import time
import requests
API_URL = "https://api.inola.ai"
API_KEY = os.environ["INOLA_API_KEY"]
def post_with_retry(path, payload, *, max_attempts=5, max_wait_s=60.0, timeout_s=30.0):
"""Send the request; repeat it only when the API says that repeating can succeed.
429 and 503: wait Retry-After seconds, if that is at most max_wait_s; without Retry-After, return at once.
500 and network errors: wait with growing pauses (1, 2, 4 s, with jitter).
Any other status is returned at once: repeating the same request gives the same answer.
"""
for attempt in range(1, max_attempts + 1):
backoff = min(2 ** (attempt - 1), max_wait_s) * random.uniform(0.8, 1.2)
try:
r = requests.post(f"{API_URL}{path}", json=payload, timeout=timeout_s,
headers={"Authorization": f"Bearer {API_KEY}"})
except requests.RequestException:
if attempt == max_attempts:
raise
time.sleep(backoff)
continue
if r.status_code in (429, 503):
if "Retry-After" not in r.headers:
return r # no estimate (429 serverless_cold): the caller sends a batch instead
wait = float(r.headers["Retry-After"])
if wait > max_wait_s or attempt == max_attempts:
return r # a monthly limit or the spend limit: the caller decides
time.sleep(wait)
elif r.status_code >= 500 and attempt < max_attempts:
time.sleep(backoff)
else:
return r
return r
if __name__ == "__main__":
r = post_with_retry("/v1/infer", {"model": "cordon-mini", "input": {"state": "Opening hours: 9 to 17 on weekdays."}})
print(r.status_code, "requests left this minute:", r.headers.get("X-RateLimit-Remaining-Requests"))
if r.status_code != 200:
error = r.json()["error"]
sys.exit(f"{error['code']}: {error['message']}")
print("injection" if r.json()["output"]["answers"]["injection"]["verdict"] else "clean")

Save as retry.mjs and run node retry.mjs.

// POST to the Inola API with the retry rules of the API.
// Node.js 18 or later, key in INOLA_API_KEY. Run: node retry.mjs
const API_URL = "https://api.inola.ai";
const API_KEY = process.env.INOLA_API_KEY;
const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
// Send the request; repeat it only when the API says that repeating can succeed.
// 429 and 503: wait Retry-After seconds, if that is at most maxWaitS; without Retry-After, return at once.
// 500 and network errors: wait with growing pauses (1, 2, 4 s, with jitter).
// Any other status is returned at once: repeating the same request gives the same answer.
export async function postWithRetry(path, payload, { maxAttempts = 5, maxWaitS = 60, timeoutS = 30 } = {}) {
let response;
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
const backoff = Math.min(2 ** (attempt - 1), maxWaitS) * (0.8 + Math.random() * 0.4);
try {
response = await fetch(`${API_URL}${path}`, {
method: "POST",
headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify(payload),
signal: AbortSignal.timeout(timeoutS * 1000),
});
} catch (err) {
if (attempt === maxAttempts) throw err;
await sleep(backoff);
continue;
}
if (response.status === 429 || response.status === 503) {
const header = response.headers.get("Retry-After");
if (header === null) return response; // no estimate (429 serverless_cold): the caller sends a batch instead
const wait = Number(header) || 1;
if (wait > maxWaitS || attempt === maxAttempts) return response; // a monthly limit or the spend limit
await sleep(wait);
} else if (response.status >= 500 && attempt < maxAttempts) {
await sleep(backoff);
} else {
return response;
}
}
return response;
}
const response = await postWithRetry("/v1/infer", { model: "cordon-mini", input: { state: "Opening hours: 9 to 17 on weekdays." } });
console.log(response.status, "requests left this minute:", response.headers.get("X-RateLimit-Remaining-Requests"));
const body = await response.json();
if (!response.ok) {
console.error(`${body.error.code}: ${body.error.message}`);
process.exit(1);
}
console.log(body.output.answers.injection.verdict ? "injection" : "clean");

Both scripts print, for example:

200 requests left this minute: <the value of X-RateLimit-Remaining-Requests>
clean