Submit 40 image jobs with mode webhook in Python on Sume
Send 40 POST /v1/images calls with mode webhook and a webhook_url: each returns a 202 job envelope at once and the result follows. Python, cost, status codes.

For a batch, do not hold 40 connections open for 30 seconds. POST /v1/images defaults to mode: "sync" with a 30-second wait, but the mode field also takes async, subscribe and webhook. With mode: "webhook" and a public HTTPS webhook_url, Sume answers 202 straight away with a job envelope and calls your URL when the job reaches a terminal state.
Note that subscribe is not a progress stream: it is an alias of sync with one bounded wait. For progress, use mode: "async" and read GET /v1/jobs/{id}/events, or use the webhook for the terminal event. Read 2026-10-07 from the Sume docs.
The submit loop
WEBHOOK_URL must be a public HTTPS endpoint you control. The metadata object is stored on the job (it is not sent to the model), so put your row id there to match the callback.
import os, requests
H = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}
URL = os.environ["WEBHOOK_URL"]
prompts = [f"product photo, ceramic mug number {i}, white sweep" for i in range(40)]
ids = []
for i, p in enumerate(prompts):
r = requests.post("https://api.sume.com/v1/images", headers=H, timeout=30, json={
"model": "bytedance-seed/seedream-5-lite", "prompt": p,
"mode": "webhook", "webhook_url": URL, "metadata": {"row": i}})
if r.status_code == 202:
ids.append(r.json()["data"]["job"]["id"])
else:
print(i, r.status_code, r.text[:120])
print(len(ids), "queued", ids[0] if ids else None)Cost and what to expect
Forty Seedream 5 Lite images are 40 x $0.04375 = $1.75 billed. Sume charges only completed generations; a failed or cancelled job is not billed. Each 202 body carries a status_url and a result_url; if a webhook delivery goes missing, poll GET /v1/jobs/{id}/status and read GET /v1/jobs/{id}/result yourself.
Your callback endpoint should be fast and idempotent (a job id is a natural key). For the delivery format and signature rules, read the Sume webhooks page rather than copying from this post.
Sources: Sume Image API docs, Webhooks, Jobs and results (read 2026-10-07).
Sources
Related posts
More in Developers
- Submit 6 ad hooks in parallel in Python with one Idempotency-Key each
A Python script that submits six 3-second Omni hook jobs in parallel, each with its own Idempotency-Key so a retry replays the original job. Cost: $2.25.
- Submit a Sume video job from PHP with cURL: sume/auto and polling
Replace a Sora call in a PHP worker with Sume /v1/videos: submit with cURL, poll the job, read the download URL, and know what a default clip costs.
- Submit and poll a Sume video job from Rust with reqwest
Rust reqwest blocking client for Sume /v1/videos: submit a sume/auto job, poll until completed, print the download URL and usage.cost. Cargo features listed.
- Retry or fix? A status-code policy for Sume API clients in Python
Retry 429 and 503 with the same idempotency key; never retry 400, 401, 402 or 404. A small Python policy function, tested, with the Sume docs rules behind it.
Written by Sume