error.code field. Error codes are stable snake_case strings — branch your error handling on these, not on the error.message, which is human-readable and subject to change.
Error Envelope
Every failed response follows this shape:Error Codes
Notes on Specific Codes
not_found (404)
not_found (404)
not_found deliberately makes no distinction between “wrong ID”, “belongs to another account”, and “archived”. This is intentional — exposing that distinction would allow callers to enumerate resources they don’t own.provider_error (502)
provider_error (502)
For video generations,
provider_error can also indicate that the merged system prompt combined with your scene and prompt text is too long for the upstream provider. If retries fail consistently, try shortening your scene context or prompt.Handling Errors in Code
Branch onerror.code to route each failure to the appropriate recovery path:
error-handling.js