CASOON Open Source
Images from the command line.
imgen sends a prompt to any image model on Replicate, waits for the prediction and saves the result as PNG or WebP. It reads each model's schema to send the size the way that model expects, and runs whole batches from one JSON file.
brew install casoon/tap/imgencargo install --git https://github.com/casoon/imgenCLI tool to generate images via the Replicate API
Usage: imgen [OPTIONS] [PROMPT]
Arguments:
[PROMPT] Text prompt for image generation (ignored when --prompt-file is used)
Options:
--prompt-file <FILE> JSON file containing an array of jobs
--model <MODEL> Replicate model in "owner/name" format [default: black-forest-labs/flux-1.1-pro]
--width <WIDTH> Output width in pixels [default: 1024]
--height <HEIGHT> Output height in pixels [default: 768]
--out <OUT> Output file path (only used for single-prompt mode) [default: output.png]
--webp [<WEBP>] Convert output to WebP with given quality (0-100). Omit value for default 80
-h, --help Print help
-V, --version Print version- ways to send the image size, picked from the model schema
- 3
- prompt-file formats: plain array or defaults + jobs
- 2
- retries on HTTP 429, honouring Retry-After
- 5
- prebuilt release targets
- 4
What it does
Any Replicate image model
Pass owner/name with --model or per job. imgen resolves the latest version itself; FLUX 1.1 Pro is the default.
Schema detection, not model lists
The model’s OpenAPI schema decides whether imgen sends exact pixels, the closest allowed aspect ratio, or plain width and height.
Batches that keep going
A JSON file runs many jobs with shared defaults. Progress shows as [2/5], and a failed job does not stop the rest.
WebP without double encoding
Models with server-side format selection deliver WebP directly. All others are converted locally at the quality you choose.
Generated at build time
All examples →Error: Failed to parse prompt file examples/prompt-files/missing-out.json
Caused by:
0: Failed to parse jobs array
1: missing field `out`
exit code 1Captured from the current binary by examples/capture.sh. Prompt files are validated before the first API request, so a broken batch costs nothing.
examples/missing-out.txtMade with imgen
All examples →Generated once with imgen and ideogram-ai/ideogram-v3-quality, then committed: generation needs a Replicate API token, so these images are not rebuilt with the site. Prompts and commands are in the showcase.
examples/gallery/Quickstart
Three steps from install to a saved image. The documentation covers models, schema detection and batch files.
- Install imgen with Homebrew, a release archive or Cargo.
- Export your Replicate token as
REPLICATE_API_TOKEN. - Run
imgenwith a prompt, or with--prompt-filefor a batch.
# Token from replicate.com/account/api-tokens
export REPLICATE_API_TOKEN="r8_your_token_here"
# One image with the default model (FLUX 1.1 Pro)
imgen "A sunset over the ocean" --out sunset.png
# Many images from a JSON file
imgen --prompt-file prompts.json


