Skip to content
Docs version r8
OpenAPIJSONYAML
Guides / Errors

Errors

A refused request answers with an HTTP status and an error body. A task that fails after it was accepted reports error.code on the task and in its webhook.

Markdown fileTry in PlaygroundDocs version r8

Error body

Every error response has the same shape. Branch on error.code, not on the message, which may change.

422 invalid_input
{
  "error": {
    "code": "invalid_input",
    "message": "input does not match the model's schema",
    "retryable": false,
    "request_id": "9f2c41d07ab3e5c8a1d40be7c26f5e13",
    "errors": [
      { "path": "/settings/duration", "rule": "required" },
      { "path": "/settings/aspect_ratio", "rule": "value_not_allowed" }
    ]
  }
}
FieldMeaning
codeStable machine-readable reason.
messageA short description for logs. It never contains your input.
retryabletrue only for 429 and 503: the same request may succeed later.
request_idInclude it when you contact support.
errorsOn 422 input errors only: each failed field, as a JSON pointer into input (path) and a rule name (rule).

Request errors

These are the values of error.code on a refused request. The request created nothing and held no Credits.

HTTPerror.codeMeaningWhat to do
400invalid_inputThe request body is not valid JSON or does not have the request shape.Fix the body. Do not retry unchanged.
401invalid_credentialsThe API key is missing, malformed, expired or revoked.See Authentication.
402insufficient_balanceAvailable Credits cannot cover the hold.Top up, then submit again.
402balance_negativeThe balance is below zero: a task's actual usage went past its hold and your balance, and Credits are owed.Top up to bring the balance back to zero or above, then submit again.
403scope_deniedThe key lacks the scope for this operation or project.Use a key with the scope.
403ip_not_allowedThe request came from outside the key's IP allowlist.Call from an allowed address.
403model_not_allowedThe key's model allowlist excludes this model.Allow the model on the key.
403budget_exceededThe key's daily or monthly spend limit would be exceeded.Raise the limit or wait for the next UTC day or month.
403spending_blockedSpending is paused on the organization.Contact support.
404resource_not_foundThe model, task or asset does not exist in this project.Check the ID and the key's project.
404draft_not_foundThe draft_task names no succeeded draft of this project.Use the ID of your own succeeded draft.
409conflictThe request conflicts with the resource's state.Read the resource, then decide.
409storage_quota_exceededThe organization's upload storage is full.Delete assets you no longer need.
422invalid_inputinput does not match the model's schema, for example a media URL that is not https. errors lists each field.Fix the fields named in errors.
422tier_not_soldThe input is valid but selects a price tier your project cannot buy.Change the resolution, the media or the length.
422input_media_invalidA media link's file has a format the model does not take in that field.Send a supported format. See Model inputs and media.
422input_media_too_largeA media link's file is larger than the model allows for its kind.Send a smaller file. See Model inputs and media.
422input_duration_out_of_rangeA measured input video or audio is shorter or longer than the model or tier accepts, alone or in total. errors names each file or total with its rule (see below). A length the model's rules accept but the selected tier cannot price comes without errors; its message names the range the tier accepts.Trim the media or pick another tier.
422draft_expiredThe draft is older than 7 days.Generate a new draft.
429rate_limitedA request rate or the open-task backlog is used up.Wait Retry-After seconds. See Rate limits.
429concurrency_limitedAs many tasks of this media type are running as your limit allows: by default 3 video tasks at once per organization (10 image, 10 audio). See Rate limits.Wait Retry-After seconds, or queue on your side.
500request_failedThe request failed on our side.For a create, check recent tasks before submitting again.
503temporarily_unavailableThe service is briefly unavailable.Retry later with backoff.

Most creates are funded just after they are accepted. Then a balance, budget or spending refusal does not answer the request: the task is accepted with HTTP 202 and fails with the same code. See [Task errors](#task-errors).

The media checks read only the start of each linked file. When a check cannot read a file's format, size or duration, the request is still accepted and the model checks the file when it fetches it.

Estimate a price refuses the same input and media as a create, with the same errors. A create can still fail where an estimate succeeded: on balance or budget, on the rate and concurrency limits, or when a price changes in between.

Important

A timeout or a dropped connection on a create is not an error body: the task may exist. Do not resend the create. Follow Interrupted submissions.

Input field rules

A 422 lists one entry per failed field. Common rule values:

ruleMeaning
requiredA required field is missing.
field_not_allowedThe model's schema does not list this field.
wrong_typeThe value has the wrong JSON type.
value_not_allowedThe value is not one of the allowed values here.
out_of_rangeA number or length is outside its limits.
bad_formatA string does not have the required format, for example a media URL.
too_many_items, too_few_itemsA list has too many or too few entries.
prompt_or_contentsSend exactly one of prompt and contents (Kling 4.0).
frames_with_referencesImage frames cannot be combined with reference media.
ratio_must_be_adaptiveThis kind of input only accepts adaptive.
draft_not_upgradableOnly a 480p draft can be turned into a final video.
media_format, media_sizeWith input_media_invalid or input_media_too_large: the linked file's format or size.
video_length, media_length, video_total_too_long, audio_total_too_long, input_plus_output_too_longWith input_duration_out_of_range: one file, or the files together, have a length the model does not accept.

Each model has a reference page under Models in the docs navigation, with its fields, allowed values and rules.

Task errors

A task accepted with HTTP 202 can still close without a result. Its status is failed or canceled and error.code names the reason. The webhook carries the same code as error_code, except delivery_failed and generation_failed, for which it may omit error_code. A task that closes without a result is not charged; its hold is released.

error.codeMeaningWhat to do
insufficient_balanceFunding was refused: the balance could not cover the hold.Top up, then submit a new task.
balance_negativeCredits were owed when the task came to be funded.Top up to bring the balance back to zero or above, then submit a new task.
budget_exceededThe key's daily or monthly spend limit would be exceeded.Raise the limit or wait for the next UTC day or month.
spending_blockedSpending is paused on the organization.Contact support.
recovery_reviewThe task was waiting for funding when we restored service after an incident, and was closed for review. Nothing was held or charged.Submit a new task.
input_moderatedContent safety refused the input. Moderation is always on; see Content moderation.Change the prompt or media.
output_moderatedContent safety refused the result.Change the prompt or media.
input_media_invalidThe model refused a media file when it fetched it: its format, size or length, or its width, height, aspect ratio, pixel count or frame rate.Check the model's media limits.
input_media_unreachableThe model could not fetch a media URL.Keep the URL reachable until the task closes, or upload the file.
input_rejectedThe model refused the input for another reason.Change the input.
draft_expiredThe draft expired before the final video started.Generate a new draft.
provider_unavailableThe model was temporarily unavailable; the task was canceled.Submit a new task later.
delivery_failedThe result was generated but could not be stored for download.Submit a new task.
generation_failedAny other failure.Submit a new task; contact support if it repeats.