Skip to content

Errors

Errors come back with an HTTP status and a JSON body. type is stable and meant for code; message is meant for people and can change. Some errors add fields with details.

{
"error": {
"type": "insufficient_balance",
"message": "This job costs $0.04; the balance is $0.01.",
"price_usd": 0.04,
"balance_usd": 0.01
}
}
Status Type When What to do
400 invalid_request The body, query or path doesn’t match the endpoint, such as a missing user. issues lists every problem. Fix the request.
400 invalid_input The model’s input failed validation, such as a width that isn’t a multiple of 16. issues lists every problem. Check the fields on the model’s page.
400 invalid_image An upload or reference image is empty, isn’t a JPEG, PNG or WebP, or can’t be decoded. Send a valid image.
400 image_too_large An image is over 20 MB (413 when the upload body itself is too large). Resize or recompress it.
400 image_unreachable An image URL to import couldn’t be fetched. Check that the URL is public and returns an image.
401 missing_api_key No Authorization: Bearer vk_... header. Send your API key.
401 invalid_api_key The key is wrong or has been revoked. Use an active key from the console.
402 insufficient_balance The balance can’t cover the task’s price. Includes price_usd and balance_usd. Top up in the console.
402 spend_cap_reached The task would take this key over its monthly cap. Wait for next month, or use a key with a higher cap.
403 account_suspended The account has been suspended. Contact us.
403 end_user_suspended This user reached 10 strikes. Don’t send more tasks for this end user.
403 model_not_allowed The API key is limited to other models. Edit the key’s models in the console, or use another key.
404 not_found No task or upload with that id belongs to your account. Check the id.
404 unknown_model The model doesn’t exist. Use an id from GET /v1/models.
409 task_finished You tried to cancel a task that had already finished. Nothing to do.
409 task_not_finished You tried to delete the outputs of a task that’s still queued or running. Cancel the task or wait for it to finish.
415 unsupported_media_type An upload wasn’t an image, a multipart form with file, or JSON with url. Set the Content-Type to match the body.
422 prompt_blocked Content screening refused the prompt. Includes categories, and for strikes end_user_strikes and end_user_suspended. Show the end user a refusal; don’t retry the same prompt.
422 upload_blocked A face in the image looks under 18, so it can’t be used. Includes upload_id. Don’t retry with the same image.
422 reference_not_allowed A reference is a CDN link that isn’t your account’s live output, or an upload that’s expired or belongs to another account. rejected lists them. Use your own outputs, your uploads, or other image URLs.
422 idempotency_key_reused The Idempotency-Key was already used with a different request. Use a new key for a new request.
429 too_many_declined_prompts More than 60 prompts were refused on your account in the last minute. Slow down and look at who is sending them.
500 internal_error Something went wrong on our side. Retry with the same Idempotency-Key.
503 model_unavailable The model can’t take tasks right now. Retry later or use another model.
503 screening_unavailable Prompt or image screening couldn’t run, so nothing was created or held. Retry with backoff.

A task can also be accepted and then fail. That isn’t an HTTP error: the task’s state becomes failed, its error explains why, and its hold is released. If meta.withheld is true, the output safety check withheld the images (see Output checks). Tasks that haven’t finished 30 minutes after they were created fail the same way.

  • Retry network errors, 500 and 503 with exponential backoff. Use an idempotency key so a retried POST /v1/tasks can’t create a second task.
  • Don’t retry 4xx errors unchanged. They fail the same way until you change the request, the balance or the key.