imgenv0.3.1

Batch mode

Run many prompts from one JSON file, with shared defaults, progress output and per-job error handling.

Two file formats

A plain array, where every job uses the CLI flags for anything it does not set:

[
  { "prompt": "A mountain landscape", "out": "images/mountain.png" },
  { "prompt": "A cityscape at night", "out": "images/city.png" }
]

Or an object with shared defaults:

{
  "defaults": { "model": "black-forest-labs/flux-schnell", "width": 1024, "height": 1024, "webp": 80 },
  "jobs": [
    { "prompt": "A mountain landscape at sunset", "out": "images/mountain.png" },
    { "prompt": "A futuristic cityscape with neon lights", "out": "images/city.png", "width": 1920, "height": 1080 },
    { "prompt": "A coffee shop interior", "out": "images/coffee.png", "model": "stability-ai/sdxl" }
  ]
}

A job value beats defaults, and defaults beat the CLI flags. All fields are listed in the prompt file reference.

Run it

imgen --prompt-file prompts.json

What happens

Focus
How a batch run proceeds
How a batch run proceedsimgen reads and validates the prompt file first; an invalid file stops the run with exit code 1 before any request. Every distinct model is then resolved once. The jobs run one after another, each with a counter such as [2/5]. A failed job is reported and the next one starts. After the last job imgen exits with code 1 if any job failed, otherwise with code 0.Prompt file → Valid?Valid? → Stopped: noValid? → Resolve models: yesResolve models → Run jobsRun jobs → Any job failed?Any job failed? → Exit code 1: yesAny job failed? → Exit code 0: nonoyesyesnoPrompt file – array or defaults + jobsPrompt filearray or defaults + jobsValid?Valid?Stopped – exit code 1, nothing sentStoppedexit code 1, nothing sentResolve models – each one onceResolve modelseach one onceRun jobs – [1/n] … [n/n], errors reportedRun jobs[1/n] … [n/n], errors reportedAny job failed?Any job failed?Exit code 1 – One or more jobs failedExit code 1One or more jobs failedExit code 0 – all images savedExit code 0all images saved

Source: src/main.rs (main, build_jobs, parse_prompt_file), as of 2026-10-26

Show chart data
Data for How a batch run proceeds
StepKindLeads to
Prompt filestartValid?
Valid?decisionStopped (no), Resolve models (yes)
Stoppedend
Resolve modelsinput or outputRun jobs
Run jobsstepAny job failed?
Any job failed?decisionExit code 1 (yes), Exit code 0 (no)
Exit code 1end
Exit code 0end
Focus
How a batch run proceeds
How a batch run proceedsimgen reads and validates the prompt file first; an invalid file stops the run with exit code 1 before any request. Every distinct model is then resolved once. The jobs run one after another, each with a counter such as [2/5]. A failed job is reported and the next one starts. After the last job imgen exits with code 1 if any job failed, otherwise with code 0.Prompt file → Valid?Valid? → Stopped: noValid? → Resolve models: yesResolve models → Run jobsRun jobs → Any job failed?Any job failed? → Exit code 1: yesAny job failed? → Exit code 0: nonoyesyesnoPrompt file – array or defaults + jobsPrompt filearray or defaults + jobsValid?Valid?Stopped – exit code 1, nothing sentStoppedexit code 1, nothing sentResolve models – each one onceResolve modelseach one onceRun jobs – [1/n] … [n/n], errors reportedRun jobs[1/n] … [n/n], errors reportedAny job failed?Any job failed?Exit code 1 – One or more jobs failedExit code 1One or more jobs failedExit code 0 – all images savedExit code 0all images saved

Source: src/main.rs (main, build_jobs, parse_prompt_file), as of 2026-10-26

Show chart data
Data for How a batch run proceeds
StepKindLeads to
Prompt filestartValid?
Valid?decisionStopped (no), Resolve models (yes)
Stoppedend
Resolve modelsinput or outputRun jobs
Run jobsstepAny job failed?
Any job failed?decisionExit code 1 (yes), Exit code 0 (no)
Exit code 1end
Exit code 0end
  1. The file is read and validated. Nothing is sent yet.
  2. Every distinct model is resolved once. If one cannot be resolved, the run stops here.
  3. The jobs run one after another. Each starts with a counter such as [2/5].
  4. A failing job is reported with Error: … and the next job starts. After the last job, imgen exits with Error: One or more jobs failed and code 1 if any job failed.

Mistakes caught before any request

Validation happens before the first API call, so a broken file costs nothing. A job without out:

$ imgen --prompt-file examples/prompt-files/missing-out.json
Error: Failed to parse prompt file examples/prompt-files/missing-out.json

Caused by:
    0: Failed to parse jobs array
    1: missing field `out`

An empty jobs array:

$ imgen --prompt-file examples/prompt-files/empty.json
Error: Prompt file contains no jobs

Both outputs are captured from the current binary; the files are in the repository under examples/prompt-files/.

Rate limits

Replicate limits how many requests an account may send, and the limit is lower for accounts with little credit. On HTTP 429, imgen waits as long as the Retry-After header says (10 seconds if it is missing) and retries, up to 5 times per request. Long batches on a new account simply take longer.

Edit this page on GitHub · Docs for v0.3.1