Rate limits

How many requests a key may make.

LimitValue
Requests per key20 per second
Failed authentication per IP20 per second

Over the limit, the API answers 429 RATE_LIMITED with a Retry-After header in seconds. Wait that long, then retry.

async function call(url: string, init: RequestInit, attempt = 0): Promise<Response> {
  const res = await fetch(url, init);
  if (res.status === 429 && attempt < 5) {
    const wait = Number(res.headers.get('retry-after') ?? 1) * 1000;
    await new Promise((r) => setTimeout(r, wait));
    return call(url, init, attempt + 1);
  }
  return res;
}

Some operations take longer than a normal request, for example generating a long schedule or running AI enrichment. Allow a client timeout of at least 5 minutes on those. The reference marks them.