Skip to content

Errors

LLMAPI returns HTTP status codes and structured error information where possible. Different protocols keep their corresponding error shapes, so there is not only one JSON error format.

Common Error Shapes

Anthropic/OpenAI compatible endpoints often return:

json
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Request body is empty"
  }
}

OpenAI image endpoints often return:

json
{
  "error": {
    "type": "not_found_error",
    "message": "Images API is not supported for this platform"
  }
}

Gemini native paths return Google/Gemini style errors. Clients should inspect both HTTP status and response body.

Common HTTP Status Codes

StatusMeaningCommon causes
400Invalid requestInvalid JSON, wrong parameter type, or platform group mismatch.
401Authentication failedMissing or invalid API key.
403Permission deniedInsufficient balance, image generation disabled, or content moderation blocked.
404Endpoint or capability unavailableNon-OpenAI group calling OpenAI synchronous image endpoints, or OpenAI group calling token count.
409State conflictCanceling an async task that already finished.
413Request body too largeRequest exceeds the configured body limit.
429Rate limitedConcurrency, wait queue, task queue, or upstream account capacity limits.
500Internal errorUnexpected server error.
502Upstream errorUpstream account or platform returned an error.
503Service unavailableAsync tasks disabled, storage not configured, or no available accounts.
504TimeoutUpstream or task execution timed out.

Async Image Task Errors

ReasonHTTP statusMeaning
IMAGE_TASKS_DISABLED503Async image tasks are disabled in server config.
IMAGE_TASK_STORAGE_UNAVAILABLE503OSS/S3 storage is not configured or unavailable.
IMAGE_TASK_INVALID_REQUEST400Request body is invalid.
IMAGE_TASK_UNSUPPORTED_MODEL400Requested model is not a supported image model.
IMAGE_TASK_UNSUPPORTED_FEATURE400Request uses an unsupported async-task feature, such as multipart or stream: true.
IMAGE_TASK_SUBSCRIPTION_UNSUPPORTED400Async tasks currently do not support subscription billing.
IMAGE_TASK_INSUFFICIENT_BALANCE403Balance is insufficient for reservation.
IMAGE_TASK_QUEUE_LIMIT_EXCEEDED429User or API key queue limit was reached, or n exceeds the per-task limit.
IMAGE_TASK_ALREADY_TERMINAL409Task is already finished and cannot be canceled.
IMAGE_TASK_NOT_FOUND404Task does not exist or does not belong to the caller.

Error example:

json
{
  "error": {
    "type": "IMAGE_TASK_INVALID_REQUEST",
    "message": "prompt must be a non-empty string"
  }
}

Platform Restriction Errors

Non-OpenAI group calling an OpenAI synchronous image endpoint:

json
{
  "error": {
    "type": "not_found_error",
    "message": "Images API is not supported for this platform"
  }
}

OpenAI group calling token count:

json
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "Token counting is not supported for this platform"
  }
}

Non-Gemini group calling Gemini native paths:

json
{
  "error": {
    "message": "API key group platform is not gemini"
  }
}

Retry Guidance

Error typeRecommendation
400, 401, 403, 404Do not retry unchanged; fix request, authentication, group, or permission first.
409Fetch the latest task state before deciding what to do next.
413Reduce request body or uploaded resource size.
429Retry with exponential backoff and reduce concurrency or queued tasks.
500, 502, 503, 504Retry with exponential backoff; for async images, query task status first to avoid duplicate submissions.

If an async image submit request returned 202, use the returned task_id for follow-up checks instead of immediately submitting a duplicate task after a client-side timeout.