Errors

How the API communicates problems and what to do about them.

When a request fails, the API returns a non-2xx HTTP status code with a JSON body matching the ApiError schema:

1{
2 "message": "API key is invalid or has been revoked.",
3 "code": "invalid_api_key"
4}
FieldTypeDescription
messagestringA human-readable explanation. Safe to display to end users.
codestring | undefinedA machine-readable error code in snake_case. Not present on all errors yet — check the HTTP status code as the primary signal.

HTTP status codes

StatusMeaning
400Bad request — invalid parameters, missing required fields, or malformed body
401Unauthorized — missing or invalid API key
403Forbidden — your API key doesn’t have access to this resource
404Not found — the resource doesn’t exist or doesn’t belong to your team
429Rate limit exceeded — back off and retry (see Rate Limits)
500Internal server error — something went wrong on our end

Error codes

CodeTypical statusDescription
missing_api_key401No Authorization: Bearer ... header was provided, or the token is empty
invalid_api_key401The provided API key is invalid or has been revoked
invalid_id400A resource id (file, execution, endpoint) is malformed or has the wrong prefix
invalid_parameters400One or more request parameters failed validation

More codes will be added over time. Always use the HTTP status code as the primary indicator, and treat code as supplemental information for programmatic branching.

Handling errors in SDKs

Both SDKs throw a typed error that includes the HTTP status and the ApiError body:

1import { VideoGenClient, VideoGenError } from "@videogen/sdk";
2
3try {
4 await client.tools.generateImage({ prompt: "" });
5} catch (err) {
6 if (err instanceof VideoGenError) {
7 console.error(err.statusCode); // 400
8 console.error(err.body.message); // "prompt is required"
9 console.error(err.body.code); // "invalid_parameters"
10 }
11}