/APIXO Docs

Error Codes

Complete API error code reference and troubleshooting guide

Overview

APIXO API uses two types of error codes:

  1. HTTP Status Codes — Returned immediately when request fails
  2. Task Failure Codes — Returned in status query when task processing fails
┌─────────────────────────────────────────────────────────────┐
│                      API Request Flow                        │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  POST /generateTask/{model}                                 │
│         │                                                   │
│         ├── Fail ──→ HTTP Status Code (400/401/429...)      │
│         │           Request rejected immediately             │
│         │                                                   │
│         └── Success ──→ 200 + taskId                        │
│                        Request accepted, task processing    │
│                             │                               │
│                             ▼                               │
│  GET /statusTask/{model}?taskId=xxx                         │
│         │                                                   │
│         ├── state: success ──→ resultUrls                   │
│         │                                                   │
│         └── state: failed ──→ Task Failure Code             │
│                               (failCode/failMsg)             │
│                                                             │
└─────────────────────────────────────────────────────────────┘
TypeWhen TriggeredMeaningExample
HTTP Status CodeImmediately on requestRequest itself has issues401 Invalid API Key
Task Failure CodeWhen querying task statusTask accepted but processing failedSensitiveContentDetected

HTTP Status Codes

CodeNameDescriptionAction
200OKRequest successfulProcess response normally
400Bad RequestInvalid request parametersCheck request body
401UnauthorizedInvalid or missing API KeyCheck API Key
402Payment RequiredInsufficient balanceTop up account
403ForbiddenContent violates policyModify content
404Not FoundResource not foundCheck model ID or task ID
429Too Many RequestsRate limit exceededWait and retry
500Server ErrorInternal server errorRetry later
503Service UnavailableService temporarily unavailableRetry later

Task Failure Codes

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

{
  "code": 200,
  "message": "success",
  "data": {
    "state": "failed",
    "failCode": "SensitiveContentDetected",
    "failMsg": "Your content was flagged by OpenAI as violating content policies."
  }
}

Content Policy Violations

failCodeDescriptionSolution
SensitiveContentContent violates policyModify prompt, avoid sensitive content
SensitiveContentDetectedContent flagged as violationAdjust prompt content
InputImageSensitiveContentDetectedInput image contains violationUse compliant image
InputOutputSensitiveContentDetectedInput or output contains sensitive contentRetry with different input
NSFWNSFW content detectedUse content policy compliant input
ProhibitedContentDetectedProhibited content detectedTry different input

Prompt Errors

failCodeDescriptionSolution
PromptLengthExceededPrompt exceeds limitShorten prompt
PromptInvalidInvalid or rejected promptCheck prompt format and content

Image/Media Errors

failCodeDescriptionSolution
ImageFormatIncorrectIncorrect image formatUse JPEG, PNG, or WebP
InvalidImageSizeInvalid image dimensionsCheck image size requirements
Upload errorImage exceeds 10MB limitCompress image to under 10MB
INVALID_IMAGE_URLCannot access image URLCheck URL accessibility
INVALID_LORA_URLCannot download LoRA modelCheck LoRA URL

Rate Limiting & Quota

failCodeDescriptionSolution
RateLimitedRate limited, retry laterReduce request frequency, wait and retry
RateLimitExceededRate limit exceededRetry later
InsufficientQuotaInsufficient quotaCheck account balance

Processing & System Errors

failCodeDescriptionSolution
TimeoutResponse timeoutRetry later
Task TimeOutTask expired, generation failedSwitch to another task
BadRequestMissing required parametersCheck request parameters
MissingParameterMissing required parameterRefer to API docs, add parameter

Error Response Examples

HTTP Error (Immediate Return)

400 - Parameter Error

{
  "code": 400,
  "message": "Prompt exceeds provider limit (max 2000 chars)",
  "data": null
}

401 - Authentication Failed

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

429 - Rate Limited

{
  "code": 429,
  "message": "Provider rate limited, please retry later",
  "data": null
}

504 - Timeout

{
  "code": 504,
  "message": "Provider timeout, please retry later",
  "data": null
}

Task Failure (When Querying Status)

Content Violation

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContentDetected",
    "failMsg": "Your content was flagged by OpenAI as violating content policies.",
    "createTime": 1767965610929,
    "completeTime": 1767965652317
  }
}

NSFW Content

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "NSFW",
    "failMsg": "NSFW, Try different input please.",
    "createTime": 1767965610929,
    "completeTime": 1767965652317
  }
}

Image Format Error

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "ImageFormatIncorrect",
    "failMsg": "Image format is incorrect",
    "createTime": 1767965610929,
    "completeTime": 1767965652317
  }
}

Error Handling Best Practices

1. Retry Strategy

Error TypeRetry?Strategy
400 (Parameter Error)NoFix parameters then retry
401 (Auth Failed)NoCheck API Key
429 (Rate Limited)YesExponential backoff, wait 60s then retry
500 (Server Error)YesExponential backoff, max 3 times
504 (Timeout)YesWait then retry, max 3 times
Content ViolationNoModify content then retry
Image ErrorNoFix image then retry

2. Exponential Backoff Example

async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (error.code === 429 || error.code >= 500) {
        const delay = Math.pow(2, i) * 1000; // 1s, 2s, 4s
        await new Promise(resolve => setTimeout(resolve, delay));
      } else {
        throw error;
      }
    }
  }
  throw new Error('Max retries exceeded');
}

3. Content Moderation Tips

To avoid content violation errors:

  • Avoid violence, pornography, politically sensitive content
  • Check that input images comply with content policy
  • Use clear, specific descriptions, avoid ambiguous expressions
  • Test with simple, safe content first

4. Monitoring and Logging

Recommended to log for debugging:

  • taskId — Unique task identifier
  • failCode — Failure code
  • failMsg — Failure message
  • Request parameters (sanitized)

Provider-Specific Errors

OpenAI

failCodeDescription
SensitiveContentDetectedContent flagged by OpenAI as violation
InputImageSensitiveContentDetectedImages containing real people not supported

MidJourney

failCodeDescription
Website TimeOutMidJourney website unresponsive after multiple attempts
INVALID_TASK_IDInvalid previous task ID for upscale/vary

Seedream (ByteDance)

failCodeDescription
outputimagesensitivecontentdetectedOutput image contains sensitive content
InvalidImageSizeInvalid image dimensions

FAQ

Q: Got 429 error, how long should I wait?
A: Wait 60 seconds then retry, or use exponential backoff strategy.

Q: How to avoid PromptLengthExceeded error?
A: Each model has different prompt length limits, check the model documentation. Generally keep under 2000 characters.

Q: Can I appeal SensitiveContentDetected error?
A: This is the upstream AI provider's content moderation result. Recommend modifying content and resubmitting.

Q: What should I do with 5xx errors?
A: These are temporary server issues. Use exponential backoff retry, max 3 times. If persistent, contact support.

Q: Why does task status return 200 but state is failed?
A: HTTP 200 means the API request itself succeeded, but task execution failed (e.g., content violation). Actual error info is in failCode and failMsg.


Support

Experiencing persistent errors? Contact support with:

  • taskId — Failed task ID
  • failCode — Error code
  • Request parameters (sanitized)
  • Error occurrence time

Technical Support: support@apixo.ai

On this page