Turn single-image generation into apipeline: one product list → a whole set of commercial shots with unified style.
The hard part of batching is not "running it many times", but thatthe generated images must look like one set. The core of this skill isseparating the spec segment from the variable segment: the visual spec stays word-for-word unchanged, and only the product description varies with the SKU.
Generation result example
| Input: product list (2 SKUs) |
|---|
SKU001 军绿色麻花针织圆领毛衣,落肩宽松版型 |
SKU002 黑色亮面皮革布洛克德比鞋,厚底系带 |
The command actually executed (loop body, the two SKUs differ only in DESC and --images , while the spec segment is word-for-word identical):
for sku in a-sweater b-shoes; do
case $sku in
a-sweater) DESC='军绿色麻花针织圆领毛衣,落肩宽松版型' ;;
b-shoes) DESC='黑色亮面皮革布洛克德比鞋,厚底系带' ;;
esac
dlazy seedream-5.0 \
--prompt "电商商拍图。图1 是商品:${DESC}。商品的颜色、材质纹理、款式细节必须与图1完全一致。放置在同一套统一视觉里:纯米白色摄影棚背景,柔和顶光加左侧补光,45 度视角,画面下方留出统一的商品投影,构图与留白在整组图中保持一致。真实商业产品摄影,无文字无水印。" \
--images docs/batch-image/sku-${sku}.jpg --size 1:1 --resolution 2k \
--save docs/batch-image/example-output-${sku}.jpg
done
Output: two SKUs under the same visual spec
| SKU001 | SKU002 |
|---|---|
| 1:1 / 2K,5 credits | 1:1 / 2K,5 credits |
The two images have consistent background color, lighting position, camera angle, and shadow direction—because the spec segment is word-for-word identical; each product remains faithful. 100 SKUs means running this loop 100 times, at a total cost of about 500 credits.
1. Capability boundaries
| Capability | Description |
|---|---|
| Batch size | Up to 100 products per batch (corresponding to the enterprise feature's specifications) |
| Cost advantage | In batch scenarios, the compute cost per image can drop to about 70% |
| Collaboration | Multi-user online collaboration, real-time tracking of image production progress |
| Asset sharing | Shared models / reference images / works / compute credits |
| Implementation in this skill | List-driven loop + concurrency control + failure retries + archiving by SKU + summary report |
Do not: do not mix different visual specs within the same batch (that is not one batch); do not skip sampling quality checks and list everything directly; do not relax product fidelity requirements just because it is a batch.
2. Input asset rules
Before generation, self-check these hard constraints:
- Size:20KB ~ 15MB
- Resolution:greater than 400×400
- Format:jpg / jpeg / png / webp
Product list (manifest) is the input for batching; CSV is recommended:
sku,image,desc
SKU001,docs/batch-image/sku-a-sweater.jpg,军绿色麻花针织圆领毛衣,落肩宽松版型
SKU002,docs/batch-image/sku-b-shoes.jpg,黑色亮面皮革布洛克德比鞋,厚底系带
Each product image must still satisfy the single-image rules:20KB~15MB、>400×400、jpg/jpeg/png/webp。
Must-dos before batching
| Step | Description |
|---|---|
| ✅ First get 1 SKU working | If a single one is wrong, running 100 just means being wrong 100 times |
| ✅ Then sample 5 SKUs | Cover edge cases across categories/colors/light and dark shades |
| ✅ Confirm cost | --dry-run unit price × number of SKUs × number of batches |
| ❌ Go straight to full volume | The easiest way to burn compute credits |
3. Spec segment / variable segment separation
This is the only way to produce unified visuals in batch:
prompt = [规范段:整批逐字不变] + [变量段:每个 SKU 不同]
| Segment | Content | Does it change |
|---|---|---|
| Spec segment | Background, lighting position, camera position, composition whitespace, shadow, color tone, output style,no text, no watermark |
Word-for-word unchanged for the whole batch |
| Variable segment | Product category + color + material + key structural features | Different for each SKU |
Write as shell:
SPEC='放置在同一套统一视觉里:纯米白色摄影棚背景,柔和顶光加左侧补光,45 度视角,画面下方留出统一的商品投影,构图与留白在整组图中保持一致。真实商业产品摄影,无文字无水印。'
while IFS=, read -r SKU IMG DESC; do
dlazy seedream-5.0 \
--prompt "电商商拍图。图1 是商品:${DESC}。商品的颜色、材质纹理、款式细节必须与图1完全一致。${SPEC}" \
--images "$IMG" --size 1:1 --resolution 2k \
--save "docs/batch-image/out/${SKU}.jpg"
done < manifest.csv
Once the specification section is changed, the entire batch must be rerun—otherwise two visual styles will appear within the same batch.
4. Concurrency, Retries, and Progress
Concurrency: dlazy handles one task per call; batching relies on shell concurrency. Keep it at 4–6 parallel jobs; too high easily triggers rate limiting.
run_one() { ... } # 单个 SKU 的生成逻辑
export -f run_one
xargs -P 5 -I{} bash -c 'run_one {}' < sku-list.txt # 5 路并发
Retries: Occasional network and server-side failures are normal; wrap it in a retry layer.
for attempt in 1 2 3; do
dlazy ... && break
echo "retry $attempt for $SKU" >&2; sleep $((attempt * 10))
done
Async mode: When there are many SKUs, use --no-wait to submit all tasks first, get the generateId and then poll uniformly, avoiding occupying the process for a long time.
GID=$(dlazy seedream-5.0 --no-wait ... | python3 -c 'import sys,json;print(json.load(sys.stdin)["result"]["task"]["generateId"])')
echo "$SKU,$GID" >> tasks.csv
# 稍后统一收结果
while IFS=, read -r SKU GID; do dlazy status "$GID" --wait; done < tasks.csv
Progress and summary: Record one status line per SKU, and output a report when finished.
echo "$SKU,$(test -f out/$SKU.jpg && echo ok || echo fail)" >> report.csv
awk -F, '{c[$2]++} END{for(k in c) print k, c[k]}' report.csv
5. Tool Invocation
This skill uses dLazy's seedream-5.0(the key metrics for batch scenarios arecost per imageandreference image support: this model costs about 5 credits per image, supports up to 10 reference images, and supports 2K/3K/4K; the cost for 100 SKUs drops from hundreds to tens. For batches with extremely high product fidelity requirements, switch to gpt-image-2)。
Invocation method
Two equivalent ways to write it; choose one. The unified entry point automatically selects the backend, retries on failure, creates directories and writes to disk, and estimates cost:
# A. 统一入口(推荐):可切任意后端,加 --dry-run 不计费空跑
node scripts/gen.mjs --task batch-image \
--prompt '<见下方 Prompt 模板>' \
--images <按下表顺序> \
--save output/batch-image-<sku>.jpg
# B. 直接用 dLazy CLI(不想引入 Node 依赖时,效果等价)
dlazy seedream-5.0 --prompt '...' --images ... --save output/batch-image.jpg
Parameter conventions (fixed usage for this skill)
| Parameter | Value | Reason |
|---|---|---|
--images |
[该 SKU 的商品图](+ reference images / model images shared by the entire batch) |
Shared assets are placed in a fixed location and referenced in the prompt by fixed image numbers |
--size |
Uniform across the entire batch (1:1 main image / 3:4 vertical) |
If not uniform, it is not a set |
--resolution |
2k |
Sufficient for listing; 4K only for batches that need printing |
--batch |
1(batch scenarios rely on the number of SKUs, not on batch) |
batch doubles the cost |
--no-wait |
Enable when there are many SKUs | Submit first, then poll, avoiding long blocking |
--save |
docs/batch-image/out/<SKU>.jpg |
Name by SKU for easy backfilling into the product database |
Model switching:
seedream-5.0is cheap and suitable for atmosphere and scene images; for batches with extremely high product fidelity requirements (pattern position, hardware details), switch togpt-image-2, at about 6 times the cost. Do not mix the two models within the same batch.
Command Examples
# basic call: 单个 SKU(先跑通这个,再谈批量)
dlazy seedream-5.0 \
--prompt '电商商拍图。图1 是商品:军绿色麻花针织圆领毛衣,落肩宽松版型。商品的颜色、材质纹理、款式细节必须与图1完全一致。放置在同一套统一视觉里:纯米白色摄影棚背景,柔和顶光加左侧补光,45 度视角,画面下方留出统一的商品投影。真实商业产品摄影,无文字无水印。' \
--images docs/batch-image/sku-a-sweater.jpg --size 1:1 --resolution 2k
# complex call: 完整流水线(清单驱动 + 5 路并发 + 3 次重试 + 汇总报告)
cat > manifest.csv <<'CSV'
SKU001,docs/batch-image/sku-a-sweater.jpg,军绿色麻花针织圆领毛衣,落肩宽松版型
SKU002,docs/batch-image/sku-b-shoes.jpg,黑色亮面皮革布洛克德比鞋,厚底系带
CSV
SPEC='放置在同一套统一视觉里:纯米白色摄影棚背景,柔和顶光加左侧补光,45 度视角,画面下方留出统一的商品投影,构图与留白在整组图中保持一致。真实商业产品摄影,无文字无水印。'
mkdir -p docs/batch-image/out
run_one() {
IFS=, read -r SKU IMG DESC <<< "$1"
for attempt in 1 2 3; do
dlazy seedream-5.0 \
--prompt "电商商拍图。图1 是商品:${DESC}。商品的颜色、材质纹理、款式细节必须与图1完全一致。${SPEC}" \
--images "$IMG" --size 1:1 --resolution 2k \
--save "docs/batch-image/out/${SKU}.jpg" >/dev/null 2>&1 && break
sleep $((attempt * 10))
done
if [ -f "docs/batch-image/out/${SKU}.jpg" ]; then echo "${SKU},ok"; else echo "${SKU},fail"; fi
}
export -f run_one; export SPEC
xargs -P 5 -I{} bash -c 'run_one "{}"' < manifest.csv | tee docs/batch-image/report.csv
awk -F, '{c[$2]++} END{printf "\n=== 汇总 ===\n"; for(k in c) printf "%s: %d\n", k, c[k]}' docs/batch-image/report.csv
# 先估价:单价 × SKU 数
dlazy seedream-5.0 --dry-run --prompt '...' --images a.jpg --size 1:1 | grep estimatedCost
echo "SKU 数:$(wc -l < manifest.csv)"
Further Reading
| What to look up | Where to go |
|---|---|
| Authentication, multi-backend configuration, output structure, error codes | references/provider-cli.md |
seedream-5.0 all available parameters of |
references/model-flags.md |
| All options of the unified entry point | node scripts/gen.mjs --help |
6. Prompt Templates
【变量段 · 每个 SKU 不同】
电商商拍图。图1 是商品:[品类 + 颜色 + 材质 + 关键结构特征]。
商品的颜色、材质纹理、款式细节必须与图1完全一致。
【规范段 · 整批逐字不变】
放置在同一套统一视觉里:[背景],[光位],[机位/视角],
画面下方留出统一的商品投影,构图与留白在整组图中保持一致。
真实商业产品摄影,无文字无水印。
Correction sentences appended by issue(if changed, the entire batch must be rerun)
| Issue | Handling |
|---|---|
| Dark products look gray on a light background | Add to the specification section 深色商品需加右侧轮廓光勾边,避免与背景糊在一起 |
| Product size varies from SKU to SKU | Add to the specification section 商品在画面中的占比统一为约 [X]%,边距一致 |
| Inconsistent shadow direction | Add to the specification section 投影统一朝画面右下方,长度约为商品高度的 [X] |
| Some SKUs lack sufficient fidelity | Rerun those SKUs separately with gpt-image-2 and note it in the report |
7. Execution Flow
- Build the manifest:
sku,image,descThree-column CSV; each product image first goes through single-image rule validation. - Write the specification section: background / lighting position / camera position / proportion / shadow / color tone / output style—no changes allowed once finalized。
- Run through 1 SKU: confirm both the specification section and the variable section are correct.
- Sample 5 SKUs: cover the boundaries of dark / light / reflective / large items / small items.
--dry-runEstimate total price: unit price × number of SKUs.- Full run: 5-way concurrency + 3 retries; when there are many SKUs, use
--no-waitand poll uniformly after submission. - Check the summary report: rerun failures individually.
- Sampling quality check: randomly sample 10% to pass detect-task; for non-compliant SKUs, individually use
gpt-image-2to rerun.
8. Common issues
| Symptom | Cause | Handling |
|---|---|---|
| Visual inconsistency within the same batch | The specification section was changed midway | No changes allowed once the specification section is finalized; if changed, rerun the entire batch |
| Dark products blend into the background | Missing rim light | Add a rim light sentence to the specification section and rerun the entire batch |
| Product proportion varies too much | Proportion not constrained | Add proportion and margin sentences to the specification section |
| Some SKUs lack sufficient fidelity | Limitations of low-cost models | For those SKUs, individually use gpt-image-2 to rerun |
| A bunch of failures halfway through the run | Concurrency too high, triggering rate limiting | Reduce concurrency to 4–5, add retries and backoff |
| Cost exceeds budget | Used --batch or 4K |
For batch scenarios --batch 1 + 2k |
| After the run, don't know which ones failed | No report | Use report.csv from Section 4 + summary |
Tips
Visit https://dlazy.com for more information.