Imagifly Developer docs
Getting started

Errors

HTTP status codes, error envelopes and task failure states.

Error envelope

Every failed request returns a non-2xx status and a JSON body in the same shape:

{
  "ok": false,
  "error": "NOT_ENOUGH_CREDITS",
  "message": "Not enough credits: this generation costs 12."
}

error is a stable machine-readable code; message is human-readable and may change. Branch on error, not on the wording.

Status codes

StatusCodeMeaning
400INVALID_REQUESTMalformed JSON body or missing field.
400INVALID_IMAGE_REQUESTAn image parameter is invalid: unknown model, bad ratio, oversized reference image, too many references.
400INVALID_VIDEO_REQUESTA video parameter is invalid: unknown model or variant, unsupported duration, size or ratio.
401UNAUTHORIZEDMissing, invalid, revoked or expired API key.
402NOT_ENOUGH_CREDITSThe account cannot cover the generation cost.
403UNAUTHORIZEDThe account is disabled.
404GENERATION_NOT_FOUNDNo such task, or it belongs to another account.
429CONCURRENCY_LIMITToo many tasks are already running for the account's plan.
500INTERNAL_ERRORUnexpected server error.
503SERVICE_CONFIGURATIONThe requested capability is not configured on the server.
503MODEL_UNAVAILABLEThe requested video model is temporarily unavailable.

Task failure is not an HTTP error

A task that is accepted and later fails still returns 200 from the polling endpoint. Check the task fields:

{
  "ok": true,
  "generation": {
    "id": "gen_2f1c9a...",
    "status": "failed",
    "error": "The model rejected this prompt (content policy).",
    "durationMs": 3200,
    "imageUrls": []
  }
}
statusMeaning
generatingStill running; keep polling.
successFinished; read imageUrls or videoUrls.
failedFinished with an error; read error.

Credits for a failed task are returned automatically. A failed task is not retried: submit a new request if you want to try again.

Retrying safely

  • Retry 429 and 5xx responses with exponential backoff.
  • Do not retry 400, 401/403, 402 or 404 without changing the request; they will fail again.
  • Every accepted POST creates a new task and charges credits, so a blind retry after a timeout can double-charge. Read the error first — if the request was rejected before acceptance, retrying is safe.

On this page