Handling async tasks

Tool requests return immediately. You choose how to get the result.

Media generation (images, video, audio) takes anywhere from a few seconds to a couple of minutes. Rather than holding a connection open for that entire time, the VideoGen API returns a response instantly with an execution id. You then choose how to receive the result: poll for it, or let us push it to you via a webhook.

How it works

POST /v1/tools/generate-image → { "toolExecutionId": "vg_exec_..." }

Every POST /v1/tools/... endpoint returns 202 Accepted with a toolExecutionId. The execution progresses through these statuses:

StatusMeaning
pendingQueued, waiting to start
runningGeneration in progress
succeededDone, result is ready
failedSomething went wrong
cancelledCancelled by you

succeeded, failed, and cancelled are terminal statuses. The execution won’t change after reaching one of these.

Getting the result

There are two ways to know when an execution finishes:

MethodBest for
PollingScripts, CLI tools, or any situation where you can block and wait.
WebhooksProduction backends, serverless functions, and anywhere you don’t want to hold a connection open.

Cancellation

You can cancel an in-progress execution at any time:

$POST /v1/tools/executions/{toolExecutionId}/cancel

If the execution hasn’t completed yet, its status will transition to cancelled.