Guides

Errors & Rate Limits

HTTP status codes, error payloads, and throttling.

All documentation

Understand failure modes so you can retry safely and surface clear messages to users.

Error envelope

{
  "success": false,
  "error": "Error message",
  "details": {
    "tokensRequired": 120,
    "remainingTokens": 40
  }
}

details is optional and varies by error type.

HTTP status codes

StatusMeaningTypical cause
200SuccessRequest completed
400Bad RequestMissing prompt/model, unsupported provider, invalid type
401UnauthorizedMissing, invalid, or expired API key
402Payment RequiredNo active subscription or insufficient tokens
403ForbiddenProvider/model not allowed for this key
429Too Many RequestsHourly rate limit exceeded
500Server ErrorUnexpected failure during generation
503UnavailablePricing/config temporarily unavailable

Common error messages

Missing API key

{
  "success": false,
  "error": "API key is required. Please provide it in X-API-Key header or Authorization header."
}

Invalid parameters

{
  "success": false,
  "error": "Prompt is required and must be a string"
}
{
  "success": false,
  "error": "Model is required and must be a string"
}
{
  "success": false,
  "error": "Model not found or unavailable"
}

Insufficient tokens

{
  "success": false,
  "error": "Insufficient tokens for this operation",
  "details": {
    "tokensRequired": 500,
    "remainingTokens": 120
  }
}

No subscription

{
  "success": false,
  "error": "No active subscription found. Please purchase a subscription to use this service."
}

Rate limited key

{
  "success": false,
  "error": "Rate limit exceeded",
  "details": {
    "isRateLimited": true,
    "remainingHourlyRequests": 0
  }
}

Rate limits

Each API key can define rate_limit_per_hour and max_tokens_per_request.

Inspect live values via GET /api/external/ai:

FieldDescription
api_key_info.rate_limit_per_hourMax requests per hour
api_key_info.remaining_hourly_requestsRemaining requests in the current window
api_key_info.max_tokens_per_requestHard cap per call

Retry guidance

StatusRetry?Strategy
429YesExponential backoff; respect hourly window
500 / 503YesRetry with jitter; fail after a few attempts
400 / 401 / 403NoFix request or key configuration
402NoTop up tokens or renew subscription

Client-side pattern

async function callAbzarAI(body, apiKey) {
  const res = await fetch("https://abzar-ai.com/api/external/ai", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": apiKey
    },
    body: JSON.stringify(body)
  })

  const json = await res.json()

  if (!res.ok || !json.success) {
    const error = new Error(json.error || "Request failed")
    error.status = res.status
    error.details = json.details
    throw error
  }

  return json.data
}