
Poll an Imagild media task by repeatedly reading its saved task ID; never place a generation POST inside the polling loop. Honor poll_after_seconds, allow only one in-flight read for that task, and stop local waiting when your deadline expires. A stopped poller should leave a resumable record.
This approach uses the existing asynchronous API rather than a webhook or an SDK-specific wait method. Configure credentials through the Imagild API console, and keep the Bearer key in your server-side process.
Key Takeaways
- Poll
GET /tasks/{id}after a generation has returned its task ID. - Use the task's suggested interval and respect HTTP 429
Retry-After. - Return a local “waiting stopped” result without changing the remote task's status.
Start with one saved task
The example below assumes a server-side JavaScript runtime with fetch. Call it with a real task ID already stored by your application. It submits no generation and spends no new generation budget.
Its deadline is an application choice. The code can finish a final in-flight read after that deadline, so use a separate request-timeout policy if your host requires a strict wall-clock limit.
async function readUntilOutcome(taskId, apiKey, waitMs = 120000) {
const base = "https://imagild.com/api/relay/v1";
const deadline = Date.now() + waitMs;
let delayMs = 5000;
let lastTask = null;
while (Date.now() < deadline) {
const remaining = deadline - Date.now();
if (delayMs >= remaining) break;
await new Promise(resolve => setTimeout(resolve, delayMs));
const response = await fetch(
base + "/tasks/" + encodeURIComponent(taskId),
{ headers: { Authorization: "Bearer " + apiKey } }
);
if (response.status === 429) {
const retry = Number(response.headers.get("Retry-After"));
delayMs = Number.isFinite(retry) && retry > 0
? Math.max(5000, retry * 1000) : 60000;
continue;
}
const payload = await response.json();
if (!response.ok) {
return { local: "read-error", http: response.status,
error: payload.error };
}
const task = payload.data;
if (!task || task.id !== taskId ||
typeof task.status !== "string") {
throw new Error("Unexpected task response");
}
lastTask = task;
if (["succeeded", "failed", "unknown"].includes(task.status)) {
return { local: "outcome", task };
}
const seconds = Number(task.poll_after_seconds);
delayMs = Number.isFinite(seconds) && seconds > 0
? Math.max(5000, seconds * 1000) : 5000;
}
return { local: "waiting-stopped", taskId, lastTask };
}
There is one awaited fetch per iteration, so a slow response cannot stack overlapping interval callbacks. A network exception rejects this function; the caller should retain the task ID and display a recoverable connection error.
Keep scheduling separate from generation
Runware's polling documentation recommends spacing status requests rather than overwhelming an asynchronous API. Imagild's fields and routes differ: use its poll_after_seconds, currently five seconds, instead of copying another provider's request shape.
Do not call the function once per visible component. If a thumbnail and a detail panel display the same task, let one application service own polling and distribute its latest result.
At current limits, reads share a per-account allowance of 120 per minute. Twelve tasks checked every five seconds would already request approximately 144 reads per minute before other activity. This arithmetic is a planning check, not a concurrency guarantee. Use a global scheduler, stagger reads or increase intervals as task counts grow.
Decide what the caller does next
A returned outcome of succeeded enables the separate authenticated download. A failed result should surface its sanitized error and usage state. An unknown outcome should stop automatic generation retries and enter review.
A local waiting-stopped result means none of those conclusions was obtained within your chosen wait budget. Offer “Check status again,” which calls the reader with the same task ID.
Verify the design using recorded JSON fixtures before a paid test: hold a queued state for several polls, return a 429 once, and then return success. Count calls and confirm the loop sends zero POSTs. For failed outcomes, use the task diagnostic checklist and points planning guide to explain recovery without silently creating another charge.
Related tasks
- What Should You Check Before Retrying a Failed Image or Video Job?
- Imagild Points, Resolution and Jobs: Plan a Creation Before You Spend
Sources and scope
- Imagild API console and integration guide: Current Imagild entry point, active-member access, asynchronous task reading and authenticated output contract; implementation facts cross-checked in lib/relay and the 2026-10-28 claims manifest.
- Runware Task Polling: General asynchronous acknowledgment/result separation and spaced polling. Runware-specific task shapes, partial results, SDKs and webhooks are not attributed to Imagild.
Product instructions were checked against the current Imagild API contract and the public model catalog. Code, budgets and acceptance checks are illustrative; this article does not claim a new paid generation test, an uptime measurement, a search-volume study or a ranking of AI citations.
Prepared by Imagild Editorial, the company editorial team responsible for these guides. AI assisted research and drafting. This is documentation-based guidance with proposed examples, not a claim of hands-on testing or an independent product review. Report a correction.
Cover: Original Imagild product screenshot captured on 28 October 2026; model availability and prices may change. This image is not an API response or a performance benchmark.