For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DashboardAPI PricingGet an API key
  • Guides
    • Introduction
    • Getting started
    • Use with AI agents
    • Examples
    • Authentication
    • Handling async tasks
      • Polling
      • Webhooks
    • File uploads
    • File hydration
    • Embedding videos
    • Errors
    • Rate limits
    • Libraries & SDKs
  • REST API Reference
    • Overview
    • Workflows
        • POSTGenerate image
        • POSTGenerate video clip
        • POSTText to speech
        • POSTGenerate sound effect
        • POSTGenerate avatar clip
        • POSTVectorize image
        • POSTRemove background from an image
        • POSTRemove background from a video
        • POSTUpscale an image
        • POSTUpscale a video
        • POSTCancel tool execution
        • GETGet tool execution info
        • GETList files
        • POSTSearch files
        • GETGet file
        • POSTCreate file upload
        • POSTHydrate file
        • POSTArchive file
        • POSTEnable public preview
        • POSTDisable public preview
        • GETList avatar presenters
        • GETList TTS voices
        • GETList webhooks
        • POSTCreate webhook
        • DELDelete webhook
  • Webhook events
    • Overview
    • Changelog
LogoLogo
DashboardAPI PricingGet an API key
GuidesHandling async tasks

Polling

Poll for the result of an async tool execution.
Was this page helpful?
Previous

Webhooks

Receive events when tool executions complete and files finish processing.
Next
Built with

The simplest way to get the result of a tool execution is to poll GET /v1/tools/executions/{toolExecutionId} until the status is terminal.

Both SDKs ship a pollExecutedTool helper that does this for you:

TypeScript
Python
cURL
1import { pollExecutedTool } from "@videogen/sdk";
2
3const { toolExecutionId } = await client.tools.generateImage({
4 prompt: "A mountain at sunrise",
5});
6
7const response = await pollExecutedTool(client, toolExecutionId);
8
9if (response.status === "succeeded") {
10 console.log("File id:", response.results[0].fileId);
11}

The helper polls every 1.5 seconds (configurable via pollIntervalMs / poll_interval_ms) and returns once a terminal status is reached. Under the hood it’s a simple loop:

TypeScript
Python
1async function pollExecutedTool(
2 client: Pick<VideoGenApiClient, "tools">,
3 toolExecutionId: string,
4 options?: { pollIntervalMs?: number; signal?: AbortSignal },
5): Promise<ExecutedTool> {
6 const pollIntervalMs = options?.pollIntervalMs ?? 1500;
7
8 while (true) {
9 options?.signal?.throwIfAborted();
10 const executed = await client.tools.getToolExecutionInfo({ toolExecutionId });
11
12 if (["succeeded", "failed", "cancelled"].includes(executed.status)) {
13 return executed;
14 }
15
16 await new Promise((r) => setTimeout(r, pollIntervalMs));
17 }
18}

When to use polling: good for scripts, CLI tools, or any situation where you can block and wait. For production systems, consider using webhooks instead.