Skip to main content
The API uses standard HTTP status codes and a consistent error object, so you can route failures quickly and recover with less guesswork.

Error response format

Error codes

Handling errors

Use the HTTP status code and error.code together. The status code tells you whether the failure is temporary. The error code tells you what to fix next.

Retryable failures

Retry 429 and 500 responses with exponential backoff.
  • For 429, wait for the Retry-After header.
  • For 500, use backoff with a timeout or retry limit.
  • Log the generation ID when you have one so you can trace the failed generation.
See Rate limits for details.

Terminal failures

Do not retry 400, 401, 402, 404, or 422 until you change the request or account state.
  • 400: fix missing or invalid parameters
  • 401: fix your API key
  • 402: add credits or resolve quota limits
  • 404: verify the resource ID or path
  • 422: revise the prompt or reference image input

Async video failures

Video generations can fail after submission. When you poll GET /v2/videos/generations/{id}, the response can return status: "failed" with an error object.
Treat failed as a terminal state for that generation. Read error.message, fix the input or retry policy, and submit a new generation when you’re ready. See Generate videos for a polling example.