/APIXO Docs

Error Codes

API error codes and troubleshooting

Error Codes

Reference for all APIXO API error codes and how to handle them.

HTTP Status Codes

CodeNameDescriptionAction
200OKRequest successfulProcess the response
400Bad RequestInvalid request parametersCheck your request body
401UnauthorizedMissing or invalid API keyVerify your API key
403ForbiddenAPI key lacks permissionCheck key permissions
404Not FoundResource doesn't existVerify model ID or task ID
429Too Many RequestsRate limit exceededWait and retry with backoff
500Server ErrorInternal server errorRetry after a few seconds
503Service UnavailableModel temporarily unavailableTry again later

Task Failure Codes

When a task fails, the response includes failCode and failMsg:

{
  "data": {
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content violates usage policy"
  }
}

Content Errors

failCodeDescriptionSolution
CONTENT_VIOLATIONPrompt violates content policyModify your prompt
NSFW_DETECTEDNSFW content detectedUse appropriate content
PROMPT_TOO_LONGPrompt exceeds character limitShorten your prompt
INVALID_PROMPTPrompt is empty or malformedProvide a valid prompt

Image/Media Errors

failCodeDescriptionSolution
INVALID_IMAGE_URLCannot access the provided image URLUse a publicly accessible URL
IMAGE_TOO_LARGEInput image exceeds size limitResize to under 10MB
UNSUPPORTED_FORMATImage format not supportedUse JPEG, PNG, or WebP
IMAGE_DOWNLOAD_FAILEDFailed to download reference imageCheck URL accessibility

Processing Errors

failCodeDescriptionSolution
PROCESSING_TIMEOUTGeneration took too longRetry the request
MODEL_UNAVAILABLEModel is temporarily offlineTry again later
GENERATION_FAILEDGeneric generation failureRetry with different parameters
INSUFFICIENT_CREDITSAccount has no creditsAdd credits to your account

Error Response Examples

400 Bad Request

{
  "code": 400,
  "message": "Invalid request",
  "data": {
    "error": "Missing required field: input.prompt"
  }
}

401 Unauthorized

{
  "code": 401,
  "message": "Unauthorized",
  "data": {
    "error": "Invalid or missing API key"
  }
}

429 Rate Limited

{
  "code": 429,
  "message": "Rate limit exceeded",
  "data": {
    "error": "Too many requests",
    "retryAfter": 60
  }
}

Error Handling Best Practices

Retry Strategy

async function apiRequest(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const response = await fetch(url, options);
      
      if (response.status === 429) {
        const retryAfter = response.headers.get('Retry-After') || 60;
        await new Promise(r => setTimeout(r, retryAfter * 1000));
        continue;
      }
      
      if (response.status >= 500) {
        await new Promise(r => setTimeout(r, Math.pow(2, attempt) * 1000));
        continue;
      }
      
      return response;
    } catch (error) {
      if (attempt === maxRetries - 1) throw error;
      await new Promise(r => setTimeout(r, Math.pow(2, attempt) * 1000));
    }
  }
}

Handling Task Failures

async function handleTaskResult(model, taskId, apiKey) {
  const response = await fetch(
    `https://api.apixo.ai/api/v1/statusTask/${model}?taskId=${taskId}`,
    { headers: { 'Authorization': `Bearer ${apiKey}` } }
  );
  
  const { data } = await response.json();
  
  if (data.state === 'failed') {
    switch (data.failCode) {
      case 'CONTENT_VIOLATION':
        console.error('Please modify your prompt');
        break;
      case 'PROCESSING_TIMEOUT':
        console.log('Retrying...');
        // Retry the original request
        break;
      case 'INSUFFICIENT_CREDITS':
        console.error('Please add credits');
        break;
      default:
        console.error(`Error: ${data.failMsg}`);
    }
    return null;
  }
  
  return JSON.parse(data.resultJson).resultUrls;
}

Getting Help

If you encounter persistent errors:

  1. Check the status page for outages
  2. Review your request against the API Reference
  3. Contact support with your taskId for debugging

On this page