apimaxDocs
DocsPricingConsole
API ReferenceIntegration GuideUser GuideChangelog

Music Series

Image Series

Video series

Task Management

Error Code ReferenceQuery Task StatusGET

Account Management

Query Quota UsageGET

Docs / Task Management

Task Management

Error Code Reference

A complete list of error codes for failed async tasks with a troubleshooting guide: 8 top-level code enums, detailed upstream.code explanations, and retry strategies.

Overview#

This page is the complete reference of error codes returned when an async task fails, along with a troubleshooting guide. Error codes appear in the error.code field of the task response.

Failures of async tasks (image / video / Suno, etc.) are not returned in the submission response — a successful submission only means the task was queued. The final outcome must be determined by polling status and error via GET /v1/tasks/:id.

Error response format#

When a task fails (status: "failed"), the response contains an error object:

json
{
  "id": "task_xxx",
  "object": "image.generation.task",
  "status": "failed",
  "model": "gpt-image-2",
  "progress": 100,
  "failed_at": 1778570120,
  "error": {
    "code": "upstream_error",
    "message": "openai returned 400: ...",
    "upstream": {
      "provider": "openai",
      "code": "content_policy_violation",
      "message": "your request was flagged ..."
    }
  }
}
FieldTypeDescription
error.codestringTop-level error code (a stable enum, see the overview below); clients use it for coarse routing
error.messagestringUser-friendly error description (sanitized)
error.upstreamobjectOptional. Native upstream error details; present only for execution-stage failures where the provider received an upstream error

Error code overview#

There are 8 stable top-level error.code enums, grouped by stage:

Request stage (returned immediately at submission, no polling needed)#

CodeMeaningRetry?
invalid_requestInvalid request parameters (missing prompt/model, malformed fields, n out of range, etc.)Fix the parameters and retry
model_not_supportedThe model is not on the supported listSwitch models and retry
model_price_errorModel pricing misconfigured (missing price / invalid multiplier)Contact an administrator

Query stage#

CodeMeaningRetry?
task_not_foundThe task ID does not exist or belongs to another callerCheck the ID and retry

Execution stage (the task was queued but failed in the background; retrieve it by polling)#

CodeMeaningRetry?
upstream_errorThe upstream returned 4xx (including content violations, parameter errors, etc.)See the upstream.code details
upstream_unavailableUpstream 5xx with retries exhaustedRetry later
storage_errorFailed to upload the result to cloud storageRetry later
internal_errorGateway internal exceptionRetry later / contact support
Failed tasks automatically refund the prepaid quota.

error.upstream upstream error details#

The top-level error.code is a coarse routing signal. To pin down the cause (for example, distinguishing "content violation" vs "bad image format" vs "rate limit"), read error.upstream.code — it is the provider's native error code and varies by upstream.

ProviderSource of upstream.codeExamples
openaierror.code (raw); falls back to error.type when emptycontent_policy_violation / invalid_image / rate_limit_exceeded
gemini (4xx)error.status (raw); falls back to http_<code> when emptyINVALID_ARGUMENT / PERMISSION_DENIED / RESOURCE_EXHAUSTED
gemini (200 but no image, the entire prompt blocked)prompt_blocked:<blockReason>prompt_blocked:OTHER / prompt_blocked:SAFETY
gemini (200 but no image, candidate stopped midway)finish_reason:<finishReason>finish_reason:SAFETY / finish_reason:PROHIBITED_CONTENT

Gemini's "200 but no image" case (a successful response that produced no image, usually because the content triggered a safety block) is treated as a 4xx upstream_error and must not be retried — retrying blocked content yields the same result.

Troubleshooting common upstream error codes#

content_policy_violation#

The request content was intercepted by the safety review mechanism — the most common failure cause. Covered scenarios:

Sub-typeDescriptionTypical message
Photorealistic peopleUploading photos containing real human facesphotorealistic people detected
Celebrity likenessInvolving celebrities or public figurescelebrity detected in image
Copyright/trademarkInvolving brand logos, trademarks, or copyrighted charactersthird-party content violation
Adult/NSFWContaining nudity or sexually suggestive contentnudity detected
Violence/self-harmContaining violent, gory, or self-harm contentviolence content blocked

How to avoid it: Do not upload photos of real people (use illustration / cartoon styles instead); remove brand logos, trademarks, and IP characters; avoid adult, violent, and other sensitive themes; describe people generically (e.g. "a person") instead of naming specific celebrities.

invalid_image / image_processing_error#

The system could not process the input image. Common causes: the image URL is inaccessible (insufficient permissions, CDN restrictions, expired link); unsupported format (HEIC, AVIF, TIFF); corrupted file; network download failure.

How to handle it: Make sure the image URL is publicly accessible; use standard formats such as JPG / PNG / WebP; switch from the URL method to the file upload endpoint; check that the image is complete and can be opened.

image_dimension_mismatch#

The input image dimensions do not match the request parameters; this is common in image-to-video. For example, aspect_ratio=1280x720 requires a 1280×720 landscape image. Fix: Resize the image to match aspect_ratio, or change aspect_ratio to fit the image.

rate_limit_exceeded / RESOURCE_EXHAUSTED#

The request rate / concurrency limit was exceeded, or upstream resources are temporarily exhausted. Fix: Lower the request rate (an interval of 1-2 seconds between calls is recommended); wait for in-flight tasks to finish before submitting again; retry after waiting 1-5 minutes — the system automatically switches between multiple routes.

Best practices#

Error handling recommendations#

python
import requests
import time

def poll_task_with_retry(task_id, api_key, max_retries=3):
    """Poll a task with automatic retry."""
    headers = {"Authorization": f"Bearer {api_key}"}

    for attempt in range(max_retries):
        resp = requests.get(
            f"https://api.apimax.ai/v1/tasks/{task_id}",
            headers=headers
        )
        data = resp.json()

        if data["status"] == "completed":
            return data.get("data")

        if data["status"] == "failed":
            error = data.get("error", {})
            code = error.get("code", "internal_error")
            message = error.get("message", "")

            # Request-stage error — not retryable, the request must be changed
            if code in ("invalid_request", "model_not_supported", "model_price_error"):
                raise Exception(f"Client error [{code}]: {message}")

            # task_not_found — not retryable
            if code == "task_not_found":
                raise Exception(f"Task not found: {message}")

            # Upstream 4xx content violation — not retryable (retrying yields the same result)
            upstream_code = error.get("upstream", {}).get("code", "")
            if code == "upstream_error" and upstream_code in (
                "content_policy_violation", "invalid_image", "image_dimension_mismatch"
            ):
                raise Exception(f"Upstream [{upstream_code}]: {message}")

            # Upstream 5xx / storage / internal errors — retryable
            if code in ("upstream_unavailable", "storage_error", "internal_error"):
                if attempt < max_retries - 1:
                    time.sleep(2 ** attempt * 5)  # 5s, 10s, 20s
                    continue
                raise Exception(f"Retryable error [{code}]: {message}")

            raise Exception(f"Error [{code}]: {message}")

        # Task is still processing
        time.sleep(3)

    raise Exception("Max polling attempts exceeded")

Retryable vs non-retryable#

Non-retryable (fix the request)Retryable (retry later)
invalid_request — fix the parametersupstream_unavailable — retry after waiting
model_not_supported — switch modelsstorage_error — retry later
upstream_error (content violation / image problems) — change the content or the imageinternal_error — retry later
task_not_found — check the IDupstream_error (rate limit / resource exhaustion) — retry after slowing down

When you hit an unclear error, keep the full task_id and error object and contact support so the issue can be traced.

Next steps

All docs
Relink Audio URLsSynchronously fetch ready-to-use audio URLs by Suno clip_id.Upsample Style TagsPolish and expand style tags and lyrics into a fuller style description.Get Style Inspiration SuggestionsGet random style or inspiration suggestions from the Suno upstream.Method 1: Create a Voice from an Existing SongCreate a vocal voice directly from a song clip already generated in this pool.Upload AudioImport user audio as a Suno-owned clip; returns an async upload task ID. With copyright=true the request switches to the copyright pipeline.Query Quota UsageUse an API key to query the remaining credits, used credits, and unlimited-quota status of the current key and its owning user.
On this page
OverviewOverviewError response formatError code overviewRequest stage (returned immediately at submission, no polling needed)Query stageExecution stage (the task was queued but failed in the background; retrieve it by polling)error.upstream upstream error detailsTroubleshooting common upstream error codescontentpolicyviolationinvalidimage / imageprocessingerrorimagedimensionmismatchratelimitexceeded / RESOURCEEXHAUSTEDBest practicesError handling recommendationsRetryable vs non-retryableNext steps