examples/provider-replicate/image-generation/README.md
You can run this example with:
npx promptfoo@latest init --example provider-replicate/image-generation
cd provider-replicate/image-generation
This example demonstrates state-of-the-art image generation using Replicate's latest models, particularly the FLUX family from Black Forest Labs.
This example tests:
export REPLICATE_API_TOKEN=r8_your_token_here
promptfoo eval
promptfoo eval --filter-providers flux-1.1-pro-ultra --max-concurrency 1
# Test only portraits
promptfoo eval --filter-tests "Photorealistic portrait"
# Test only landscapes and architecture
promptfoo eval --filter-tests "landscape|architecture"
| Model | Best For | Speed | Cost | Resolution |
|---|---|---|---|---|
| FLUX 1.1 Pro Ultra | Highest quality | Fast | $0.06/image | Up to 4MP |
| FLUX 1.1 Pro Ultra (Raw) | Photorealism | Fast | $0.06/image | Up to 4MP |
| FLUX Dev | General use | Medium | ~$0.02/image | 1024x1024 |
| FLUX Dev Realism | Photorealistic | Medium | ~$0.028/image | 1024x1024 |
| SDXL | Artistic styles | Fast | ~$0.01/image | 1024x1024 |
You can customize generation parameters:
providers:
- id: replicate:image:black-forest-labs/flux-dev
config:
width: 1344 # Image width
height: 768 # Image height
num_outputs: 1 # Number of images to generate
guidance: 3.5 # How closely to follow the prompt (1-20)
num_inference_steps: 28 # Quality vs speed tradeoff
output_format: 'png' # png, webp, or jpg
seed: 42 # For reproducible results
:::warning
Replicate image URLs expire after approximately 24 hours. To preserve generated images, use the included save-images.js hook that automatically downloads all images during evaluation.
:::
This example includes a save-images.js hook that automatically downloads all generated images to an images/ directory. To enable it:
# Add to any config file
extensions:
- file://save-images.js:hook
Or run with the included configuration:
promptfoo eval -c promptfooconfig-with-download.yaml
Downloaded images will be saved as:
images/flux-dev-red-apple-on-a-white-table-2025-07-28T12-30-45.pngimages/sdxl-portrait-of-elderly-man-2025-07-28T12-31-02.pngraw: trueAfter running the evaluation:
Running the full test suite (40 images) costs approximately:
--delay 1000 to add delays between requests or --max-concurrency 1 to run sequentially