Skip to content

Error codes

This document lists error codes that the AIX Gateway API may return and what they mean. When a request fails, the response includes a specific error code to help you locate the issue quickly.

INFO

When reporting an issue, please include the X-Request-Id from the response headers so we can investigate.

Error response format

json
{
  "error": {
    "message": "Detailed error description",
    "type": "Error type",
    "code": "Error code"
  }
}

HTTP status codes

All error responses return a corresponding HTTP status code:

  • 4xx: Client errors (request format, parameters, authentication, etc.)
  • 5xx: Server errors (service faults, upstream failures, etc.)

Error code categories

Authentication and authorization errors

Error codeHTTP statusDescriptionResolution
invalid_api_key401API Key is invalid or expiredCheck that the API Key is correct, or contact an admin for a new key
authentication_error401Authentication failedConfirm the request includes a valid Authorization header
permission_denied403Insufficient permissionsYour account cannot access this resource; contact an admin

Quota and rate-limit errors

Error codeHTTP statusDescriptionResolution
insufficient_quota403Insufficient quotaYour account balance or quota is exhausted; top up or upgrade your plan
rate_limit_exceeded429Rate limit exceededRequest rate is too high; retry later or ask an admin to raise the limit
too_many_requests429Too many requestsToo many requests in a short period; reduce request frequency
billing_quota_exceeded403Billing quota exceededYour usage has reached the quota limit

Request errors

Error codeHTTP statusDescriptionResolution
invalid_request_error400Invalid parameters are invalidCheck that parameters match the API documentation
request_parse_failed400Failed to parse the requestConfirm the request body is valid JSON
request_validation_failed400Request validation failedCheck for missing required parameters or incorrect types
unprocessable_entity422Unprocessable requestFormat is valid but content cannot be processed; check parameter values
request_timeout408Request timed outThe server did not receive the full request in time; check your network

Resource errors

Error codeHTTP statusDescriptionResolution
not_found_error404Resource not foundThe requested resource (model, task, etc.) does not exist; check the resource ID
task_not_found404Task not foundThe requested task ID does not exist or has expired
conflict_error409Resource conflictThe operation conflicts with the current resource state

Model and feature errors

Error codeHTTP statusDescriptionResolution
channel_model_mapping_failed400Model unavailableThe requested model is currently unavailable; try another model
feature_not_supported501Feature not supportedThe current model or channel does not support this feature (e.g. stream_options)

Content moderation errors

Error codeHTTP statusDescriptionResolution
sensitive_words_detected403Sensitive words detectedYour request contains sensitive content; modify and retry
moderation_blocked403Content blocked by moderationThe request violates content policy and cannot be processed
text_moderation_failed403Text moderation failedThe text content did not pass moderation

Service and upstream errors

Error codeHTTP statusDescriptionResolution
internal_server_error500Internal server errorThe server hit an unexpected error; retry later or contact support
service_unavailable503Service unavailableService is temporarily unavailable (maintenance or high load); retry later
engine_overloaded503Engine overloadedThe AI engine is under heavy load; retry later
upstream_error502Upstream service errorThe upstream AI service returned an error; retry later
upstream_timeout504Upstream service timeoutThe upstream AI service timed out; retry later
upstream_unavailable503Upstream service unavailableThe upstream AI service is temporarily unavailable

Async task errors

Error codes used in async task scenarios:

Error codeHTTP statusDescriptionResolution
task_not_found404Task not foundThe task ID does not exist or has expired; check the task ID
task_execution_failed500Task execution failedTask creation or execution failed; see error details
task_fetch_failed500Failed to fetch task statusUnable to get task status; retry later

FAQ

1. What should I do if I get a 401 error?

Cause: Invalid, expired, or malformed API Key

Resolution:

  • Check that the request header includes Authorization: Bearer YOUR_API_KEY
  • Confirm the API Key is correct (extra spaces can be introduced when copying)
  • Check whether the API Key has expired or been disabled
  • Contact an admin for a new API Key

2. What should I do if I get a 403 error?

Cause: Insufficient quota, insufficient permissions, or content policy violation

Resolution:

  • Insufficient quota (insufficient_quota): Top up or upgrade your plan
  • Rate limit (rate_limit_exceeded): Reduce request frequency
  • Sensitive words (sensitive_words_detected): Modify the request content
  • Insufficient permissions (permission_denied): Contact an admin to enable access

3. What should I do if I get a 429 error?

Cause: Request rate is too high

Resolution:

  • Reduce request frequency (recommend exponential backoff retries)
  • Check whether multiple clients share the same API Key
  • Contact an admin to raise the rate limit

4. What should I do if I get a 500 / 502 / 503 error?

Cause: Temporary server-side failure

Resolution:

  • Wait 1–5 minutes and retry
  • Implement automatic retries (recommend 3 attempts with increasing intervals)
  • If failures persist for more than 30 minutes, contact technical support

5. What should I do if a streaming request is interrupted?

Possible error codes:

  • stream_closed: Connection closed by upstream
  • stream_timeout: Streaming processing timed out
  • stream_parse_failed: Data format error

Resolution:

  • Check that the network connection is stable
  • Increase the client timeout
  • Resubmit the request

Retry strategy recommendations

Errors that should be retried

These errors are usually transient; implement automatic retries:

HTTP statusScenarioRetry strategy
408Request timeoutRetry immediately, up to 3 times
429Rate limitWait then retry (exponential backoff: 1s, 2s, 4s)
500Internal errorWait then retry (1s, 3s, 5s)
502Upstream errorWait then retry (1s, 3s, 5s)
503Service unavailableWait then retry (2s, 5s, 10s)
504Gateway timeoutWait then retry (2s, 5s, 10s)

Errors that should not be retried

These errors are deterministic; retries will not help:

HTTP statusScenario
400Invalid parameter error
401Authentication failed
403Insufficient permissions / quota exhausted
404Resource not found
422Request cannot be processed

Retry example code

python
import time
import requests

def call_api_with_retry(url, headers, data, max_retries=3):
    for attempt in range(max_retries):
        try:
            response = requests.post(url, headers=headers, json=data, timeout=30)

            # Success
            if response.status_code == 200:
                return response.json()

            # Do not retry
            if response.status_code in [400, 401, 403, 404, 422]:
                return response.json()

            # Rate limited
            if response.status_code == 429:
                wait_time = 2 ** attempt  # exponential backoff
                print(f"Rate limited, waiting {wait_time}s...")
                time.sleep(wait_time)
                continue

            # Server error
            if response.status_code >= 500:
                if attempt < max_retries - 1:
                    wait_time = (attempt + 1) * 2
                    print(f"Server error, retrying in {wait_time}s...")
                    time.sleep(wait_time)
                    continue

        except requests.exceptions.Timeout:
            if attempt < max_retries - 1:
                print("Timeout, retrying...")
                time.sleep(1)
                continue

        except requests.exceptions.RequestException as e:
            print(f"Request failed: {e}")
            break

    return None
js
async function callApiWithRetry(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const response = await fetch(url, options)
      const data = await response.json()

      // Success
      if (response.ok) {
        return data
      }

      // Do not retry
      if ([400, 401, 403, 404, 422].includes(response.status)) {
        return data
      }

      // Rate limited
      if (response.status === 429) {
        const waitTime = Math.pow(2, attempt) * 1000
        console.log(`Rate limited, waiting ${waitTime}ms...`)
        await new Promise((resolve) => setTimeout(resolve, waitTime))
        continue
      }

      // Server error
      if (response.status >= 500 && attempt < maxRetries - 1) {
        const waitTime = (attempt + 1) * 2000
        console.log(`Server error, retrying in ${waitTime}ms...`)
        await new Promise((resolve) => setTimeout(resolve, waitTime))
        continue
      }

      return data
    } catch (error) {
      if (attempt < maxRetries - 1) {
        console.log('Request failed, retrying...')
        await new Promise((resolve) => setTimeout(resolve, 1000))
        continue
      }
      throw error
    }
  }
}

Troubleshooting steps

Step 1: Confirm the error code

Check the error.code field in the response and look it up in this document.

Step 2: Check the HTTP status code

  • 4xx: Usually a client issue; check request parameters and authentication
  • 5xx: Usually a server issue; you can retry

Step 3: Read the error message

error.message contains a detailed description and often provides more context.

Step 4: Resolve by category

  • Auth issues: Check the API Key
  • Parameter issues: Compare parameters against the API docs
  • Quota issues: Check account balance
  • Service issues: Retry later or contact technical support

Technical support

Contact technical support if:

  • The error persists for more than 30 minutes
  • The error message is unclear or does not match the docs
  • You suspect a service outage
  • You need a higher quota or rate limit

Appendix

Error code quick reference

Grouped by HTTP status code:

400 Bad Request

  • invalid_request_error
  • request_parse_failed
  • request_validation_failed
  • channel_model_mapping_failed

401 Unauthorized

  • invalid_api_key
  • authentication_error

403 Forbidden

  • insufficient_quota
  • permission_denied
  • sensitive_words_detected
  • moderation_blocked
  • billing_quota_exceeded

404 Not Found

  • not_found_error
  • task_not_found

408 Request Timeout

  • request_timeout

429 Too Many Requests

  • rate_limit_exceeded
  • too_many_requests

500 Internal Server Error

  • internal_server_error
  • task_execution_failed
  • task_fetch_failed

502 Bad Gateway

  • upstream_error

503 Service Unavailable

  • service_unavailable
  • engine_overloaded
  • upstream_unavailable

504 Gateway Timeout

  • upstream_timeout
  • stream_timeout