Error response format
Error codes
Handling errors
Use the HTTP status code anderror.code together. The status code tells you whether the failure is temporary. The error code tells you what to fix next.
Retryable failures
Retry429 and 500 responses with exponential backoff.
- For
429, wait for theRetry-Afterheader. - 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.
Terminal failures
Do not retry400, 401, 402, 404, or 422 until you change the request or account state.
400: fix missing or invalid parameters401: fix your API key402: add credits or resolve quota limits404: verify the resource ID or path422: revise the prompt or reference image input
Async video failures
Video generations can fail after submission. When you pollGET /v2/videos/generations/{id}, the response can return status: "failed" with an error object.
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.