Opami ProtectOpen the console

Rate limits

Over a limit, the API refuses the request and tells you how long to wait in the Retry-After header (seconds). A refused request is not charged. Console sessions count as one caller per account.

LimitValueOver it
Per client IP, all /v1/* routes60 requests/s, burst 120429 rate_limited + Retry-After, before authentication
Per API key, /v1/detect60 requests/s, burst 120429 rate_limited + Retry-After
Console session, per account10 requests/s, burst 30429 rate_limited + Retry-After
Console billing routes, per account20 per minute, burst 5429 rate_limited + Retry-After
Detections in progress, per account1 at a time429 rate_limited + Retry-After
Model capacityn/a429 model_busy + Retry-After
Text, /v1/detect20,000 code points413 text_too_long
Request body, /v1/detect1 MB413 text_too_long
Request body, other customer routes64 KB413 request_too_large
Active API keys, per account25409 key_limit_reached
Slow requestsbody over 30 s, request over 60 s408 request_timeout

The detection limit covers the whole account: all its API keys and its playground. Send detections one after another. Contact us if you need more.

See the error table for every code.

How to retry

Send an Idempotency-Key with each call. The API does not replay results: a reuse of a key within 24 hours returns 409 idempotency_key_reused, with no inference and no charge, when the first call was charged or is still running. A call that ended with nothing charged (model_busy, model_unavailable) frees its key.

curl

KEY=$(uuidgen)
curl -i https://api-protect.opami.ai/v1/detect \
  -H "Authorization: Bearer $OPAMI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $KEY" \
  -d '{"model":"protect-v1","text":"Zoë Müller lives in Berlin."}'
# After a 429 with "Retry-After: 2": wait 2 seconds, then run the same curl again (same $KEY).
# After a 503 model_unavailable: wait, then run the same curl again (same $KEY).
# After a 408 or another 5xx: run KEY=$(uuidgen) first, then the curl.

TypeScript

async function detect(text: string, maxAttempts = 5): Promise<unknown> {
  let key = crypto.randomUUID();
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    let res: Response;
    try {
      res = await fetch("https://api-protect.opami.ai/v1/detect", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${process.env.OPAMI_API_KEY}`,
          "Content-Type": "application/json",
          "Idempotency-Key": key,
        },
        body: JSON.stringify({ model: "protect-v1", text }),
        signal: AbortSignal.timeout(65_000),
      });
    } catch {
      // No response: keep the same key.
      await sleep(backoff(attempt));
      continue;
    }
    if (res.ok) return res.json();
    const retryable = res.status === 408 || res.status === 429 || res.status >= 500;
    if (!retryable) throw new Error(`detect failed: ${res.status}`);
    // A 429 or 503 ended with nothing charged and frees the key: keep the same key.
    // After 408 or another 5xx the attempt is finished: use a new key.
    if (res.status !== 429 && res.status !== 503) key = crypto.randomUUID();
    const wait = Number(res.headers.get("Retry-After"));
    await sleep(wait > 0 ? wait * 1000 : backoff(attempt));
  }
  throw new Error("detect failed after retries");
}

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
const backoff = (n: number) => Math.min(30_000, 500 * 2 ** n) * (0.5 + Math.random() / 2);

A 409 idempotency_key_reused is not retried above. It means an earlier attempt with that key was charged or is still running. Check your usage before you send again.

Need more (design partners, batch jobs)? Contact us; higher limits per account on request.