LEAPERone Docs

Error Codes

Common error codes and how to handle them.

All API errors return a JSON body with an error object. Use the HTTP status code and the error.code field to determine what went wrong.

Error Response Format

Example error response
{
  "error": {
    "message": "Rate limit exceeded. Please slow down.",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}

Error Code Reference

CodeMeaningHow to Fix
400Bad RequestCheck request body format and required fields.
401UnauthorizedCheck that your API key is valid and included in the Authorization header.
402Insufficient CreditsTop up credits in the Dashboard.
404Not FoundCheck the endpoint URL and any resource IDs.
410GoneResource has expired (e.g., an image generation task older than 30 days).
429Rate LimitedSlow down requests and implement backoff. See Rate Limits.
500Server ErrorRetry after a moment. Contact support if the issue persists.

Retry Strategy

Not all errors are retryable. Here is a quick guide:

CodeRetryable?Notes
400NoFix the request before retrying.
401NoFix your API key or authentication.
402NoAdd credits, then retry.
404NoFix the URL or resource ID.
410NoThe resource is permanently gone.
429YesWait for the Retry-After header duration.
500YesUse exponential backoff.

Exponential Backoff

For retryable errors, use exponential backoff to avoid overwhelming the API:

Retry with exponential backoff
async function requestWithRetry(fn, maxRetries = 5) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const response = await fn();

    if (response.ok) return response;

    // Only retry on 429 or 5xx
    if (response.status !== 429 && response.status < 500) {
      throw new Error(`Request failed with status ${response.status}`);
    }

    if (attempt < maxRetries) {
      const backoff = Math.min(1000 * 2 ** attempt, 30000);
      const jitter = Math.random() * 1000;
      await new Promise((r) => setTimeout(r, backoff + jitter));
    }
  }

  throw new Error("Max retries exceeded");
}

Always add random jitter to your backoff delay. This prevents many clients from retrying at exactly the same moment.