Submit your first generation task, poll until it finishes, and download the result.
Every WideRouter job follows the same three steps regardless of whether you are
generating an image or a video, and regardless of which model you pick.
import timewhile True: task = requests.get( f"https://api.widerouter.com/v1/task/{task_id}", headers={"Authorization": f"Bearer {os.environ['WIDEROUTER_API_KEY']}"}, timeout=30, ).json() if task["status"] in ("completed", "failed"): break time.sleep(3)print(task["outputs"])
Expect 15–40 seconds end to end for a 1K image. A finished task carries an
outputs array of image URLs.
Poll with backoff, not in a tight loop. Start around two to three seconds; a
client polling every 100 ms gets rate limited without finishing any faster.
Send a User-Agent header when you download. The delivery CDN returns a bare
403 to requests with no User-Agent and to the default Python-urllib/3.x
one, which looks like an expired link but is not.