AT
Auto Toon Docs

Rate Limits & Errors

Understand rate limiting, HTTP status codes, and error handling for the Auto Toon API.

Rate Limits

The Auto Toon API enforces a limit of 100 requests per minute per API key. Rate limit information is included in the response headers of every request.

HeaderDescriptionExample
X-RateLimit-LimitMaximum requests per minute100
X-RateLimit-RemainingRequests remaining in current window97
X-RateLimit-ResetUnix timestamp when the window resets1620000000

HTTP Status Codes

CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Missing or invalid API key
402Payment Required - Insufficient credits
403Forbidden - Terms not accepted or feature not available
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error Response Format

All error responses follow a consistent JSON structure. Additional fields may be included depending on the error type.

Response400
json
{
  "error": "Human-readable error message",
  "code": "ERROR_CODE"
}

Common Error Codes

INSUFFICIENT_CREDITS

The account does not have enough credits for this operation.

json
{
  "error": "Insufficient credits",
  "code": "INSUFFICIENT_CREDITS",
  "balance": 2,
  "required": 3,
  "needsTopUp": true
}
TERMS_NOT_ACCEPTED

The user must accept the terms of service before using this feature.

RATE_LIMITED

Too many requests. Includes a retryAfter field indicating seconds to wait.

json
{
  "error": "Rate limit exceeded",
  "code": "RATE_LIMITED",
  "retryAfter": 12
}
INVALID_API_KEY

The API key format is invalid or the key has been revoked.

SAFETY_BLOCK

The submitted content was flagged by safety filters and could not be processed.

Retry Strategy

For 429 and 500 errors, we recommend implementing exponential backoff with jitter. This prevents thundering herd problems when many clients retry simultaneously.

typescript
async function fetchWithRetry(url: string, options: RequestInit, maxRetries = 3) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const res = await fetch(url, options);

    if (res.ok) return res;

    if (attempt < maxRetries && (res.status === 429 || res.status >= 500)) {
      const baseDelay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
      const jitter = Math.random() * 1000;
      await new Promise((r) => setTimeout(r, baseDelay + jitter));
      continue;
    }

    throw new Error(`Request failed with status ${res.status}`);
  }
}

Respect retryAfter

When you receive a 429 response with a retryAfter field, always wait at least that many seconds before retrying.

Dialog Title

Dialog Title

Dialog Title

Dialog Title