Comfy-Org/ComfyUI · error · RuntimeError
Unexpected response: the first item is not the base image.
Error message
Unexpected response: the first item is not the base image.
What it means
Raised by ByteDanceSeedreamLayerSeparationNode when the first item's z_index is neither 0 nor 1,000,000 (the sentinel used for missing/unparseable z_index). The node requires the first item to be the base image; a non-base first item means the ordering contract of the response was violated.
Source
Thrown at comfy_api_nodes/nodes_bytedance.py:1262
if isinstance(v, (int, float)):
return int(v)
if isinstance(v, str):
try:
return int(v.strip())
except ValueError:
return 1_000_000
return 1_000_000
data = [d for d in (response.data or []) if isinstance(d, dict)]
if not data or "url" not in data[0]:
raise RuntimeError("Unexpected response: no base image returned.")
base_item = data[0]
if base_item.get("bounding_box") is not None:
logging.warning(
"ByteDance layer separation: base item unexpectedly carries a bounding_box; ignoring it."
)
if z_index_of(base_item) not in (0, 1_000_000):
raise RuntimeError("Unexpected response: the first item is not the base image.")
layer_items = [d for d in data[1:] if "url" in d]
dropped = len(data) - 1 - len(layer_items)
if dropped > 0:
logging.warning(
"ByteDance layer separation: %d of %d returned elements had no 'url' and were dropped.",
dropped,
len(data) - 1,
)
if not layer_items:
raise RuntimeError("The model returned no layers. Try a different prompt or input image.")
layer_items.sort(key=z_index_of)
base_image = (await download_url_to_image_tensor(str(base_item["url"])))[..., :3].contiguous()
height, width = base_image.shape[1], base_image.shape[2]
specs = []
for item in layer_items:
flags = []View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Retry once — ordering anomalies can be transient.
- Update ComfyUI to the newest version, since the z-index heuristics may have been updated for a new API behavior.
- File a bug with the raw response from ComfyUI/temp/api_logs/ attached.
Defensive patterns
Strategy: retry
Try / catch
except RuntimeError as e:
if 'first item is not the base image' in str(e):
result = await separate_layers(image) # one retry; ordering anomalies are often transient
# if it repeats, report with api_logs payload
else:
raise Prevention
- Retry once on ordering-contract errors before investigating.
- Keep the raw response from ComfyUI/temp/api_logs/ when filing issues.
When it happens
Trigger: The API returns a layer (not the base) first, carrying an explicit z_index other than 0; z_index_of parses a value like 2 or 5 for data[0].
Common situations: BytePlus changes the ordering of returned items or adds new z_index semantics; a response contract change shipped server-side.
Related errors
- Unexpected response: no base image returned.
- Only a single input image is supported.
- The model returned no layers. Try a different prompt or inpu
- Failed to download layer {i + 1} of {len(specs)} (name={item
- Only {len(urls)} of {len(response.data)} images were generat
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/4cb0ebc1d656c43c.
Report an issue: GitHub.