A CLI that generates images from text prompts using Replicate.
- Text-to-image generation via Replicate API
- Batch processing from YAML files
- Caching based on prompt+model hash (avoids duplicate generations)
- Automatic WEBP conversion using nativewebp
- Model search by popularity
- Agent-friendly: JSON output, dry-run, structured exit codes
curl -fsSL https://raw.githubusercontent.com/kevinmichaelchen/replicate-images/main/scripts/install.sh | bashRequires Go 1.21+:
go install github.com/kevinmichaelchen/replicate-images/cmd/replicate-images@latestexport REPLICATE_API_TOKEN="r8_..."
# Generate an image
replicate-images "a cat wearing a hat"
# Use a different model
replicate-images --model stability-ai/sdxl "a sunset over mountains"
# Custom output directory
replicate-images --output ./my-art "abstract painting"
# Skip cache
replicate-images --no-cache "a cat wearing a hat"
# Search for models
replicate-images models "anime"
# Batch process from YAML
replicate-images batch prompts.yaml
# Validate YAML before processing
replicate-images validate prompts.yamlprompts:
- prompt: "a cat in space"
model: black-forest-labs/flux-schnell
- prompt: "a dog on the moon"
- prompt: "a bird underwater"
model: stability-ai/sdxlPrompts without a model use the default or --model flag value.
| Model | Best For |
|---|---|
black-forest-labs/flux-schnell |
Fast, high-quality generations (default) |
black-forest-labs/flux-1.1-pro |
Higher quality, slower. Best for final outputs |
stability-ai/sdxl |
Classic model with wide style range |
google/nano-banana-pro |
Text rendering, diagrams, technical illustrations |
Other models may work but are untested. List supported models:
replicate-images supported-models
replicate-images supported-models --json # For agents| Flag | Default | Description |
|---|---|---|
--model, -m |
black-forest-labs/flux-schnell |
Model to use |
--output, -o |
./generated-images |
Output directory |
--no-cache |
false |
Force regeneration |
--concurrency, -c |
3 |
Concurrent generations (batch) |
--json |
false |
Output as JSON/JSONL |
--dry-run |
false |
Preview without generating |
--quiet, -q |
false |
Suppress output, use exit code |
# Single prompt
replicate-images --json "a cat in space"
{"status":"generated","prompt":"a cat in space","model":"black-forest-labs/flux-schnell","hash":"f417c5f0015e36af","output_file":"./generated-images/f417c5f0015e36af.webp","cached":false}
# Batch (JSONL - one JSON per line)
replicate-images batch --json prompts.yamlPreview what would be generated without making API calls:
replicate-images --dry-run --json "a cat in space"
{"to_generate":1,"cached":0,"prompts":[{"prompt":"a cat in space","model":"black-forest-labs/flux-schnell","hash":"f417c5f0015e36af","status":"pending"}]}Query available models programmatically:
replicate-images supported-models --json
[{"id":"black-forest-labs/flux-schnell","name":"FLUX Schnell","description":"Fast, high-quality generations. Great default choice.","default":true},...]Check YAML syntax and detect issues before processing:
replicate-images validate prompts.yaml
replicate-images validate --json prompts.yaml| Code | Meaning |
|---|---|
| 0 | Success (all generated or cached) |
| 1 | Partial failure (some failed) |
| 2 | Total failure (all failed) |
| 3 | Invalid input (bad YAML, missing file) |
Suppress all output; rely on exit codes:
replicate-images -q "a cat in space" && echo "Success" || echo "Failed"- Go 1.21+
- golangci-lint
- pre-commit (optional)
# Clone the repo
git clone https://github.com/kevinmichaelchen/replicate-images.git
cd replicate-images
# Install pre-commit hooks (optional)
pre-commit install
# Build
make build
# Run tests
make test
# Run linter
make lint
# Format code
make fmtReleases are fully automated via release-please:
- Push commits to
mainusing conventional commits - release-please creates/updates a Release PR with changelog
- Merge the PR when ready to release
- GitHub Actions automatically builds binaries and publishes the release
Commit prefixes and version bumps:
| Prefix | Version Bump | Example |
|---|---|---|
fix: |
Patch | fix: handle empty response |
feat: |
Minor | feat: add retry logic |
feat!: or BREAKING CHANGE: |
Major | feat!: change API response format |
