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.

5 min readSume
All posts

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

All Developers posts

Written by Sume