Skip to content

Poll Video Results

GET https://api.apimart.cc/v1/videos/{task_id}
{
"id": "vt-abc123def",
"object": "video",
"model": "tk-wan3.0-video-prime",
"status": "in_progress",
"progress": 45,
"created_at": 1760000000
}
{
"id": "vt-abc123def",
"object": "video",
"model": "tk-wan3.0-video-prime",
"status": "completed",
"created_at": 1760000000,
"completed_at": 1760000142,
"url": "https://cdn.example.com/output/video.mp4"
}
{
"id": "vt-abc123def",
"object": "video",
"model": "tk-wan3.0-video-prime",
"status": "failed",
"created_at": 1760000000,
"error": {
"code": "task_failed",
"message": "Content policy violation detected in prompt"
}
}
StatusDescriptionAction
queuedTask waiting in queueContinue polling
in_progressModel generating videoContinue polling
completedVideo readyDownload from url
failedGeneration failedCheck error field
unknownExecution outcome needs reconciliationRetain the ID and contact support; do not resubmit automatically
import time
import requests
def wait_for_video(task_id, api_key, max_wait=600, interval=5):
"""Poll until the video task reaches a terminal state."""
deadline = time.monotonic() + max_wait
while time.monotonic() < deadline:
response = requests.get(
f"https://api.apimart.cc/v1/videos/{task_id}",
headers={"Authorization": f"Bearer {api_key}"},
timeout=30,
)
response.raise_for_status()
resp = response.json()
if resp["status"] == "completed":
return resp
if resp["status"] == "failed":
raise RuntimeError(f"Video failed: {resp.get('error', 'unknown')}")
if resp["status"] not in ("queued", "in_progress"):
raise RuntimeError(f"Task {task_id} needs review: {resp['status']}")
time.sleep(interval)
raise TimeoutError(f"Video did not complete within {max_wait}s")

If your polling loop times out:

  1. The task may still be running — check again later with the same task ID
  2. Don’t resubmit immediately — you’d be charged for a duplicate
  3. Keep the task ID — no fixed retention window is promised by this guide

The url field in a completed response points to the generated video file.

URLs may expire

We recommend downloading the video file to your own storage as soon as it’s completed. Don’t rely on the URL being permanently available.

# Download the video
download = requests.get(resp["url"], timeout=60)
download.raise_for_status()
video_data = download.content
with open("output.mp4", "wb") as f:
f.write(video_data)

Accepted submission reserves balance; completion settles the final charge. Confirmed failure triggers failure settlement. A polling timeout or unknown state is not a confirmed failure. Inspect usage logs and balance for settlement information. See Pricing & Billing.