문서
Async jobs and polling
Every generation is an asynchronous job with 5 public statuses; poll GET /v1/jobs/{id} until it reaches succeeded, failed or cancelled, and download result files within 30 days.
Statuses
| Status | Final | Meaning |
|---|---|---|
queued |
No | Accepted and charged, waiting to start |
running |
No | The model is generating |
succeeded |
Yes | result.files holds the output |
failed |
Yes | error explains why; the price is refunded |
cancelled |
Yes | Cancelled before it finished; the price is refunded |
Polling
async function waitForJob(id: string) {
for (;;) {
const res = await fetch(`https://useflowapi.com/v1/jobs/${id}`, {
headers: { Authorization: `Bearer ${process.env.FLOWAPI_KEY}` },
});
const job = await res.json();
if (['succeeded', 'failed', 'cancelled'].includes(job.status)) return job;
await new Promise((r) => setTimeout(r, 3000));
}
}
Reads allow 1200 requests per minute per key, so polling every 2–5 seconds is well inside the limit.
Timeouts
A job unfinished after 30 minutes (image) or 90 minutes (video) is marked failed and refunded in full.
Cancel
curl -X POST https://useflowapi.com/v1/jobs/JOB_ID/cancel -H "Authorization: Bearer $FLOWAPI_KEY"
Cancel is a request, not a guarantee: a job that has not reached the model yet is cancelled and refunded at once; a job already generating may still finish, and you pay only if it succeeds. A finished job is returned unchanged.
Results
Result files are copied to FlowAPI's own storage and served from there. Each file has an expires_at; files are deleted 30 days after the job finishes.
FAQ
- How often should I poll a job?
- Every 2 to 5 seconds works well; the read limit is 1200 requests per minute per key.
- Is a cancelled job charged?
- No. A job that ends cancelled is refunded in full; a job that finishes despite the cancel request is charged.
- How long are result files kept?
- Result files are kept for 30 days after the job finishes, then deleted.