CheaperGen

Guides

Errors

Every CheaperGen API error code and HTTP status — 400, 401, 402, 404, 409, 429, 502, 503 — with causes and how to handle or retry each one.

The API uses conventional HTTP status codes: 2xx means success, 4xx means the request needs to change, and 5xx means something failed on our side or upstream. Every error response has the same JSON shape, so you can handle them in one place.

Error format#

400 Bad Request
{
  "error": {
    "code": "invalid_request",
    "message": "\"resolution\" must be one of: 480p, 720p",
    "param": "resolution"
  }
}
  • code — a stable, machine-readable string. Branch on this, not on the message.
  • message — a human-readable explanation, safe to log. Wording may change.
  • param — present when a specific request field caused the error.

Error codes#

HTTPcodeMeaningWhat to doRetry?
400invalid_requestThe body is not valid JSON, a required field is missing, a value is out of range or not allowed, the body contains an unknown parameter, a prompt mention points at nothing, or a reference video / audio file is unreadable or outside the model's limits (duration, size, resolution, frame rate). param names the offending field.Fix the request. The message says exactly what is wrong.After fixing
401unauthorizedThe API key is missing, malformed or revoked.Check the Authorization: Bearer header and that the key is active.After fixing
402insufficient_balanceYour balance does not cover the price of this generation. Nothing was charged.Add credits or enable auto top-up in Dashboard → Billing. See Billing.After fixing
403forbiddenThis account can't make requests. This is the API's JSON error; for a 403 on an upload PUT, see Uploads.Contact support.No
404not_foundThe endpoint ID, model or generation does not exist — or the generation belongs to another account.Check the ID against the model list.No
409conflictThe request conflicts with the resource's state — typically canceling a generation that is already running or finished.Read the generation to see its current status.No
410model_delistedThe model is no longer offered. Nothing was submitted or charged; its past generations stay readable.Pick another model from the model list.No
429rate_limitedToo many requests per second, or your queue of generations waiting to start is full.Back off and retry. See Rate limits.With backoff
500internal_errorSomething went wrong on our side.Retry with backoff. If it persists, contact support with the time of the request.With backoff
501direct_upload_unavailableDirect (presigned) uploads are not available on this deployment.Upload with multipart/form-data instead. See Uploads.No
502—A gateway or network error before the request reached our API (rare). Upstream model failures never show up as an HTTP error: the generation fails with an error reason.Retry with backoff. Nothing was charged.With backoff
503model_unavailableThe model is temporarily not accepting new generations.Retry later or switch model. Check the status page.With backoff
503pricing_unavailablePrices couldn't be read for a moment, so the request was not priced. Nothing was submitted or charged.Retry the same request after a few seconds (the response has a Retry-After header), with the same Idempotency-Key.With backoff
503fallback_price_declinedallow_fallback_price: false refuses a request that needs a price adjustment. Nothing was submitted or charged.Request a fresh quote and confirm the amount before retrying. Send allow_fallback_price: true only if you accept the current quote.With backoff
400max_cost_exceededThe quoted price exceeds max_cost_usd. Nothing was charged.Lower the resolution or duration, or confirm the price and raise max_cost_usd.After fixing

Errors inside a generation#

An HTTP error means the request itself was rejected and nothing was charged. A generation that was accepted but later fails is different: the API call succeeded (even POST /run returns 202 when a job fails right away), and the generation's status becomes failed with an error object. Its hold is refunded automatically. The same object is in GET /generations, the webhook payload and the MCP tools' results.

A failed generation
{
  "status": "failed",
  "error": {
    "code": "generation_failed",
    "message": "ByteDance's safety review for Seedance 2.0 Fast rejected the prompt.",
    "reason": "content_blocked",
    "hint": "Describe the character's look instead of naming a copyrighted character or real person, keep it non-explicit, or try another model.",
    "retryable": false,
    "refunded": true,
    "detail": "Your request did not pass content safety review. Please adjust your prompt and try again."
  }
}

code is the broad class (the four values documented since launch). reason says exactly why — branch on it, and show message and hint to your users. retryable says whether sending the same request again can work, param names the field to change when we can tell, and detail carries the model's own wording.

error.reasonerror.codeWhat happenedWhat to doResend as is?
content_blockedgeneration_failedThe model vendor's safety filter rejected the prompt, an input file or the generated result (for example a named copyrighted character, a real person, or explicit content). The message names whose filter it was.Rephrase the prompt (describe the look instead of naming a character, brand or real person), use other input files, or try a model from another vendor. Sending it unchanged fails the same way.No — change it first
invalid_inputgeneration_failedThe model could not accept one of the inputs or settings: a file too large, in an unsupported format, with the wrong dimensions or aspect ratio, too long, or a value it doesn't take. param names the field when we can tell.Fix the named field (see the model's limits on its API page) and resubmit, or try another model.No — change it first
input_unreachablegeneration_failedAn input URL could not be downloaded: it needs a sign-in, its signed link expired, it doesn't point straight at the file, or the host refused the request. When the model can't fetch a file, we usually download it ourselves and retry with our copy, so this mostly means the file couldn't be downloaded at all.Use a public, direct file URL (or upload the file with POST /api/v1/uploads) and resubmit.No — change it first
upstream_unavailableupstream_errorThe model was down, overloaded or at capacity on every route we could use.Retry in a minute or two, or use another model.Yes
upstream_errorupstream_errorThe model hit an internal error on every route we tried.Retry; these errors are usually temporary. If it keeps failing, try another model.Yes
timeouttimeoutThe generation did not finish in time (the model's own time limit, or ours of 40 minutes).Retry. Shorter or lower-resolution clips finish sooner.Yes
output_unavailableupstream_errorThe model finished but returned no usable file, or the result could not be downloaded and stored.Retry.Yes
model_unavailablemodel_unavailableThe model, or this mode of it, stopped being served while the generation was in progress.Pick another model, or retry later.No — change it first
canceledupstream_errorThe service canceled or expired the job before it finished. (A generation you cancel yourself has status canceled and no error.)Retry.Yes
generation_failedgeneration_failedThe model stopped without a result and gave no reason.Retry once; if it fails again, simplify the prompt or inputs, or try another model.Yes

Failures your request caused — content_blocked, a refused file in invalid_input, input_unreachable — are not retried on other routes, because they would be rejected again. Outages and model errors are retried on every eligible route first, at the same price. See Failures and refunds.

When the model can't download one of your input files, we usually try to download it ourselves. If we can, the job is retried with a copy we host — at the same price, with nothing to change on your side; the generation still shows the URLs you sent, and the copy is deleted with the generation under its retention. So input_unreachable mostly means the file couldn't be downloaded at all: it needs a sign-in, its signed link expired, it doesn't point straight at the file, or its host refused the request. We copy images up to 30 MB, videos up to 200 MB and audio up to 50 MB; a larger or unreadable file fails as invalid_input.

Retrying safely#

Retry 429, 500, 502 and 503 with exponential backoff and jitter. Don't retry other 4xx errors unchanged — they will fail the same way.

Submits are not idempotent

Each successful POST /run/{endpoint} creates and bills a new generation. If a submit times out on the network and you don't know whether it was accepted, check your recent generations before sending it again.

const RETRYABLE = new Set([429, 500, 502, 503]);

export async function postWithRetry(url, headers, body, attempts = 5) {
  let resp;
  for (let attempt = 0; attempt < attempts; attempt++) {
    resp = await fetch(url, { method: "POST", headers, body: JSON.stringify(body) });
    if (!RETRYABLE.has(resp.status)) break;
    // exponential backoff with jitter: ~1s, 2s, 4s, 8s…
    await new Promise((r) => setTimeout(r, Math.min(2 ** attempt, 30) * 1000 + Math.random() * 1000));
  }
  const data = await resp.json();
  if (!resp.ok) throw new Error(`${resp.status} ${data.error.code}: ${data.error.message}`);
  return data;
}

Validation examples#

Validation messages name the field and the allowed values, so they can be shown to developers as-is:

[
  {
    "error": {
      "code": "invalid_request",
      "message": "\"prompt\" is required",
      "param": "prompt"
    }
  },
  {
    "error": {
      "code": "invalid_request",
      "message": "Unknown parameter \"resoluton\"",
      "param": "resoluton"
    }
  },
  {
    "error": {
      "code": "not_found",
      "message": "Unknown endpoint \"bytedance/seedance-2.0-fast/text-to-gif\". See GET /api/v1/models."
    }
  }
]

You can also price a request without running it: POST /api/v1/quote/{endpoint} validates the price-relevant fields and returns the cost. See the API reference.

Something unclear or missing? Email support@cheapergen.com — we read everything.