Skip to content
Playcut Docs

Polling for Results

Generation tasks are async. After submitting you receive a taskId and choose one of three completion strategies.

StrategyWhen to useCost
get-task-status (poll)Cron jobs, batch scripts where latency doesn’t matter1 request per poll
wait-for-task (single call)Synchronous integrations, simple scripts1 request total — server holds the connection
WebhooksProduction apps, agents, fan-out architectures0 requests — Playcut POSTs to you
Terminal window
curl -X POST https://api.playcut.ai/api/v1/tools/get-task-status/execute \
-H "Authorization: Bearer $PLAYCUT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"taskId": "65f3a1b2c3d4e5f600000002"}'
{
"data": {
"taskId": "65f3a1b2c3d4e5f600000002",
"type": "GEMINI_TEXT_TO_IMAGE",
"status": "COMPLETED",
"output": { "assetIds": ["asset_xyz"] },
"processingInfo": { "progress": 100 }
}
}

One call that returns when the task hits a terminal state. No client-side polling loop.

Terminal window
curl -X POST https://api.playcut.ai/api/v1/tools/wait-for-task/execute \
-H "Authorization: Bearer $PLAYCUT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"taskId": "65f3a1b2c3d4e5f600000002"}'

Connection times out after the task’s hard deadline (image 5 min, video 10 min). Retry once on timeout — Playcut never charges for a timeout.

StatusMeaning
PENDINGQueued, not started
PROCESSINGWorker is running
COMPLETEDOutput ready in output.assetIds
FAILEDSee error field
Section titled “Recommended poll intervals (if you must poll)”
Task typeTypical latencyPoll every
Image5–15 s3 s
Video60–120 s5–10 s
TTS3–10 s2 s
Actor15–30 s5 s
const BASE = "https://api.playcut.ai/api/v1/tools"
async function waitForTask(taskId: string, apiKey: string, intervalMs = 5000) {
const headers = { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" }
for (let i = 0; i < 60; i++) {
await new Promise((r) => setTimeout(r, intervalMs))
const res = await fetch(`${BASE}/get-task-status/execute`, {
method: "POST",
headers,
body: JSON.stringify({ taskId }),
}).then((r) => r.json())
if (res.data.status === "COMPLETED") return res.data.output
if (res.data.status === "FAILED") throw new Error(res.data.error?.message ?? "Task failed")
}
throw new Error("Timed out waiting for task")
}

When using the MCP server, call wait-for-task directly — it’s the same tool, just dispatched through the MCP protocol instead of REST.