Skip to Content
TQAI Docs

Errors and retries

What an error response looks like, what the common HTTP status codes and error codes mean, which errors to retry and how.

Error response format

An error response keeps the format of the endpoint that answers it.

OpenAI format (/v1/chat/completions, image generation, model listing and others):

{
  "error": {
    "message": "Error message (request id: 20261108120000123456789abcdEFGH)",
    "type": "new_api_error",
    "code": "insufficient_user_quota"
  }
}

Anthropic format (/v1/messages):

{ "type": "error", "error": { "type": "...", "message": "..." } }

Video tasks and reference media endpoints: parameter validation, quotes, uploads and other business errors, plus concurrency-limit errors on these endpoints, come back as:

{ "code": "invalid_request", "message": "...", "data": null }

On those same endpoints, errors rejected before the endpoint runs (token authentication, model unavailable) and the video idempotency 409 and the GET /v1/videos/{task_id}/content errors use the OpenAI format above, {"error": {"code": ...}}. So on the video and reference media endpoints, read the error code from error.code first and fall back to the top-level code.

Decide from the HTTP status and the error code, not from the exact wording of message: the wording can change.

Request ID

Every response carries the X-Oneapi-Request-Id header; read the request ID from that header. Some endpoints also append (request id: ...) to the error message, but not all of them do. Note it down when you need to investigate a request: it identifies exactly that request, and the token log lookup endpoint (Chinese) takes it to find the charge.

Common status codes

StatuscodeCauseWhat to do
400invalid_request and othersInvalid request parameters, such as a missing field, a value outside what the model supports, or a JSON parse failureFix the request using message; do not resend it unchanged
401—Invalid token: missing, mistyped, disabled, deleted, expired, or out of quotaCheck the token, see Base URL and authentication (Chinese)
403insufficient_user_quotaWallet balance is too lowTop up (Chinese), then retry
403pre_consume_token_quota_failedThis token's quota cap is used upRaise the token's quota in the console
403access_deniedThe request IP is not in the token's IP allowlistCheck the token's IP allowlist
403—The token is not allowed to use this modelCheck the token's model restrictions
409Video: idempotency_conflict, idempotency_in_progress; async image: invalid_requestIdempotency key conflictSee Idempotency and concurrency limits (Chinese)
410video_expiredThe finished video is past its retention periodThe file is gone and cannot be recovered; see Delivery retention (Chinese)
413—Request body too largeSend a smaller request; host reference media first, see Reference media hosting (Chinese)
429concurrency_fullConcurrency limit reachedWait as long as Retry-After says, then retry; see Concurrency limits (Chinese)
429— or invalid_requestToo many requests; or the site-wide async image task cap is reached (invalid_request, message is too many async image tasks in flight)Retry later, and honour Retry-After when present
500—Internal server errorRetry later
502 / 504—The generation service failed or timed outRetry later
503model_not_foundWrong model name, or no serving channel available for this model right nowConfirm the name with the models endpoint (Chinese); if the name is right, retry later

Endpoint-specific error codes are on each API reference page.

Is a failure charged

  • A failed synchronous call is not charged; anything pre-deducted before the call is refunded.
  • A rejected async task submission (an error response) is not charged.
  • An async task that is accepted and then fails is refunded in full; the reason is listed under failure categories (Chinese). The exception is the few models that still charge when content moderation rejects the request; see Billing rules (Chinese).

Retries

When the generation service fails, TQAI has already retried automatically on the server before returning the error to you, so what you receive is the result after those retries. When your client retries, follow these rules.

Do retry: 429, 500, 502, 503, 504, plus network errors and connection timeouts.

  • With a Retry-After header, wait at least the number of seconds it gives.
  • Without one, use exponential backoff, for example 2, 4, 8, 16 seconds, with a maximum number of attempts.
  • When concurrency is full (concurrency_full), lowering the number of in-flight requests beats retrying in a loop.

Do not resend unchanged: 400, 401, 403, 409, 410, 413. The result would be the same; handle them as described in the table above first.

Retrying an async task submission:

  • Send the same Idempotency-Key and the same request body. Even if the previous attempt was in fact accepted, you get the original task back instead of paying twice.
  • When a video submission returns 409 (idempotency_in_progress), wait Retry-After seconds and resend with the same key.

Resubmitting a failed task: once a failed task has been refunded in full, its idempotency key is released, so submitting again with the same key creates a new task and charges again. The few content-moderation failures that are still charged do not release the key: resending with the same key returns the original task, so use a new key to generate again. For content moderation rejections, unreachable reference media, rejected reference media and parameters the model does not accept, resending unchanged will most likely fail again: change the prompt, the media or the parameters first.

Timeouts

  • A synchronous request that returns no data for a long time may be dropped by the network path after about 100 seconds. Stream chat responses and use async tasks (Chinese) for image generation.
  • For long polling (wait=N), set the client read timeout above N.

Only this page, the home page and Quickstart have an English version so far; other pages are Chinese only.

On this page