Gateway Error Codes & Troubleshooting

When calling LLMs via the API gateway, a failed response consists of an HTTP status code + a JSON error body. The external HTTP code is consistent with status_code in Console "Call Logs", making it easy to trace by log_id.


1. Unified Error Response Format

Platform Local Interception (Auth, Balance, Rate Limits, etc.)

{
  "error": {
    "message": "Insufficient account balance (below 0.5 CNY)",
    "type": "api_error",
    "code": "402"
  }
}
FieldDescription
error.messageFailure reason description
error.typeapi_error for platform interceptions
error.codeHTTP status code string (e.g., "402"), not an OpenAI semantic error code

Upstream Pass-Through

When the upstream returns valid JSON, the error body may be passed through verbatim (including vendor-specific type / code), while the HTTP status code still aligns with status_code in logs.


2. Status Code Quick Reference

HTTPMeaningTypical message
400Invalid parameters, model type mismatch, content moderation / copyright blockParameter error; PolicyViolation / OutputVideoSensitiveContentDetected / copyright restriction
401Authentication failedMissing Authorization Header / Invalid Bearer Token Format / Invalid API Key
402Insufficient available account balanceInsufficient account balance... / Insufficient balance
403Insufficient permissions (token / IP / model whitelist, etc.)API key disabled / Model xxx not allowed for this token / Daily quota exhausted / IP x.x.x.x not whitelisted
404Model not found, temporarily unavailable, or external resource inaccessibleModel not found: xxx; or message containing status 404 (e.g., input image download failure)
429Rate limit or in-flight task capRPS limit exceeded / RPM limit exceeded / Balance too low, too many active tasks, please recharge
500Gateway internal errorInternal server error
502Upstream unavailable / connection failedUpstream request failed or raw upstream message
504Timeout / gateway interruptionContains timeout, gateway, etc.

Commonly Confused: Insufficient balance -> 402; content moderation/copyright -> 400; no token permission -> 403; 429 only means RPS/RPM or low-balance in-flight task gating.


3. Troubleshooting by Scenario

400 Bad Request (Malformed Request / Type Error / Content Block)

  • Causes: Invalid JSON, missing required fields, calling an image/video model on the chat endpoint; or upstream content safety/copyright/sensitivity policy block (e.g., PolicyViolation).
  • Resolution: Check model and endpoint path; validate JSON. For content moderation blocks, adjust your prompt or reference assets—this is not a token permission issue (see 403 for permissions).

401 Unauthorized (Authentication Failed)

  • Causes: Missing Authorization, malformed Bearer header, or nonexistent Key.
  • Resolution: Authorization: Bearer sk-xxx (with a single space). Disabled/expired tokens return 403.

402 Payment Required (Insufficient Balance)

  • Causes: Available balance is insufficient to cover pre-deduction or minimum charge.
  • Resolution: Top up in the Console. Async task GET polling / DELETE cancellation are still permitted when overdrawn, while POST submissions are blocked.

403 Forbidden (Permissions / Token Quota)

  • Causes:
    • Token disabled (API key disabled), expired (API key expired)
    • Model not in token whitelist (Model xxx not allowed for this token)
    • IP not in whitelist (IP x.x.x.x not whitelisted)
    • Token daily/weekly/monthly/total quota exhausted (e.g., Daily quota exhausted)
    • Creation Center dedicated token invoked outside the Playground environment
  • Resolution: Check token switch, model/IP whitelists, and quotas. Content moderation/copyright blocks return 400, not 403.

404 Not Found (Model or Resource Missing)

  • Causes: The model ID does not exist or is currently unavailable; or an input resource URL (such as an image or video link) cannot be downloaded (contains status 404).
  • Resolution: Verify the model ID matches the Model Plaza; check that image/video URLs in the request are publicly accessible.

429 Too Many Requests (Rate Limit / In-Flight Limit)

  • Causes: Token rps_limit / rpm_limit exceeded; too many concurrent in-flight async tasks of the same type when balance is low.
  • Resolution: Retry with exponential backoff; top up or reduce concurrent async tasks.

500 / 502 / 504 (Service or Upstream Errors)

  • 502: Upstream returned a non-2xx HTTP status or connection failed.
  • 504: Connection or generation timeout.
  • 500: Temporary server error.
  • Resolution: Retry later and check error_message in Call Logs.

4. Special Notes for Async Tasks

For video and other long-running tasks: HTTP may be 200 when submission and polling succeed at the transport layer; check status in the body for business success/failure:

{
  "id": "video_task_xxx",
  "status": "failed",
  "error": { "message": "Upstream failure reason" }
}

Logs record the inferred 4xx/5xx in status_code, while the polling endpoint itself may still return 200. Always rely on status and the logs.


5. Log Tracing

  1. Logs: Every request records log_id, status_code, error_message, latency, and billing; filter by timestamp and log_id during troubleshooting. The HTTP code matches status_code.
  2. Processing Status: After a successful async submission, the log may briefly show status_code=0 (processing) and update to its terminal state once the task completes.

6. Capability-Specific Notes

Common error scenarios by endpoint type:

CapabilityCommon SymptomCode / Explanation
ChatContext too long, invalid parametersMay return an OpenAI-style error or platform api_error + HTTP code
ImageModel type mismatch with /v1/images/generations400; same for invalid multi-image / reference image parameters
Qwen ImageMalformed size, invalid reference image URL400; 1024x1024 is accepted and auto-converted by the gateway to 1024*1024
Video (Async)Submit succeeds but polling returns status: failedPolling HTTP 200; log status_code is 4xx/5xx, see Section 4
Wan VideoMixing start/end frames with reference assets, or audio-only without image/video400
Wan VideoMixing files / links with start/end frame roles400
Video (Sync Block)Insufficient balance, rate limit, model unavailable402 / 429 / 404 consistent with the table above
Native RoutesMisspelled DashScope / Volcengine path404 or 400; verify the path and model name

Raw Markdown (.md) · llms.txt