DEV Community

Cover image for Batch Image Generation with Codex and dLazy: Build the Pipeline, Not a Prompt Loop
xiaodong Zhang
xiaodong Zhang

Posted on

Batch Image Generation with Codex and dLazy: Build the Pipeline, Not a Prompt Loop

One product identity, four coordinated campaign settings
Generating one good product image is a creative task. Generating 100 good product images that look like they belong to the same catalog is a systems problem.
That is the useful idea behind dLazy's batch-image skill. It gives Codex an operator playbook: read a SKU manifest, keep one visual specification frozen, call the dLazy CLI once per SKU, save results under deterministic names, retry failures, and produce a report you can audit.
The key design choice: SKU count drives the batch. The CLI's --batch flag stays at 1, because increasing it creates extra generations for every SKU and multiplies spend.
The architecture in one screen

Batch-image execution pipeline from manifest to QA
Codex does not run the image model locally. The installed skill teaches Codex the workflow; the dLazy CLI sends prompts and image inputs to the hosted API; seedream-5.0 generates the asset; and --save downloads it to your project.
The skill states that prompts and parameters are sent to api.dlazy.com, local media inputs are uploaded to files.dlazy.com, and generated URLs are hosted there. Treat that as a normal cloud-processing boundary: do not submit assets you are not authorized to upload.
Install the skill and CLI
Ask Codex to install the skill from the repository path:
Install this Codex skill:
https://github.com/dlazyai/ecommerce-skills/tree/main/skills/batch-image
Codex skills use a required SKILL.md. If a downloaded repository uses lowercase skill.md, normalize the filename during installation. You can review the original batch-image skill and the official Codex skills documentation before running it.
Use the pinned CLI version declared by the skill:
npx @dlazy/cli@1.2.3 seedream-5.0 -h

or: npm install -g @dlazy/cli@1.2.3

dlazy auth set
Get the API key from the dLazy dashboard. Do not paste it into a manifest, prompt, repository, or article draft.
Start with one SKU
The model command is dlazy seedream-5.0. The skill recommends 2k, one consistent aspect ratio, and a deterministic output path.
dlazy seedream-5.0 \
--prompt 'Commercial ecommerce photo. Image 1 is the product: black polished leather derby shoe with a chunky lace-up sole. Preserve its color, material texture, silhouette, and construction. Place it in one fixed visual system: warm-white studio, soft top light plus left fill, 45-degree view, consistent lower-right shadow and whitespace. No text or watermark.' \
--images docs/batch-image/sku-b-shoes.jpg \
--size 1:1 --resolution 2k \
--save docs/batch-image/out/SKU002.jpg
Do this before you automate. A bad spec multiplied by 100 is still a bad spec—just more expensive.
Separate the prompt into variables and invariants
Every SKU gets a variable block: category, color, material, and structural details. Every run gets the same invariant block: background, lighting, camera angle, product occupancy, shadow direction, color grade, and output style.
VARIABLE — changes per SKU
Image 1 is the product: [category + color + material + structural details].
Preserve its color, texture, silhouette, and construction.

SPEC — byte-for-byte identical across the run
Warm-white studio; soft top light plus left fill; 45-degree view;
consistent product scale, margins, and lower-right shadow;
commercial product photography; no text; no watermark.
If you change the spec halfway through, you no longer have one batch. You have two visual systems.
Drive the run from a manifest
SKU001,docs/batch-image/sku-a-sweater.jpg,olive cable-knit crewneck sweater with a relaxed dropped shoulder
SKU002,docs/batch-image/sku-b-shoes.jpg,black polished leather derby shoe with a chunky lace-up sole
The reference implementation in the skill uses five parallel workers, three attempts with increasing delays, SKU-based filenames, and report.csv. Keep concurrency around four or five if rate limits appear.
mkdir -p docs/batch-image/out
SPEC='Warm-white studio, soft top light plus left fill, 45-degree view, consistent product scale, margins and lower-right shadow. Commercial product photography, no text, no watermark.'

run_one() {
IFS=, read -r SKU IMG DESC <<< "$1"
for attempt in 1 2 3; do
dlazy seedream-5.0 \
--prompt "Image 1 is the product: ${DESC}. Preserve its identity. ${SPEC}" \
--images "$IMG" --size 1:1 --resolution 2k --batch 1 \
--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
For large catalogs, add --no-wait, capture each generateId, then poll with dlazy status --wait. The asynchronous path prevents a terminal session from blocking on every job.
Estimate before you fan out
Use --dry-run to inspect the payload and estimated cost before executing:
dlazy seedream-5.0 --dry-run --prompt '...' --images a.jpg --size 1:1
wc -l < manifest.csv
The repository's example lists seedream-5.0 at 5 credits for a 1:1, 2K output, so 100 SKUs are illustrated as roughly 500 credits. Pricing can change; treat the CLI's current estimate as the source of truth. Reserve 4K for print work. The skill says gpt-image-2 costs about six times more, so use it selectively for fidelity failures rather than mixing models inside the initial batch.
QA is part of the pipeline
The recommended rollout is deliberately boring: one SKU, then five edge cases, then the full manifest. Sample dark, light, reflective, large, and small products. After the run, inspect the report and randomly review 10% of outputs.
Check identity, texture, color, product scale, margins, lighting, shadow direction, artifacts, text, and watermarks. If one subgroup needs gpt-image-2, rerun only those SKUs and record the exception in the report.
Failure modes worth engineering for
unauthorized: set the key with dlazy auth set and resume.
insufficient_balance: add credits before retrying.
Local file not found: validate manifest paths before launch.
Server or async failure: retry with backoff and preserve the failed SKU list.
Visual drift: freeze the invariant spec and rerun the entire affected batch.
Rate limiting: reduce concurrency to four or five.
Production checklist
1.Validate every input path and SKU identifier.
2.Lock one aspect ratio and 2k resolution for the batch.
3.Freeze the invariant prompt block.
4.Approve one SKU, then five boundary SKUs.
5.Run --dry-run and calculate the catalog total.
6.Execute with bounded concurrency, retries, and deterministic filenames.
7.Review report.csv; rerun only failed items.
8.Sample at least 10% for visual QA.
The scalable unit here is not a clever prompt. It is a reproducible job: manifest in, assets and report out. That is what makes batch-image useful inside Codex.

Top comments (0)