Generate and Test Image Prompts
Automatically probe OpenAI's DALL-E for jailbreaks using promptfoo's iterative red-team retry loop.
Why it matters
This asset helps users generate and test image prompts for DALL-E, ensuring they are robust and produce desired outputs. It's designed for red-teaming to uncover potential vulnerabilities or biases in image generation.
Outcomes
What it gets done
Generate image prompts for DALL-E.
Test generated prompts for effectiveness and safety.
Identify potential prompt injection or adversarial attacks.
Audit image generation outputs for unintended content.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/pfoo-redteam-dalle | bash Steps
Steps in the chain
Overview
Redteam Dalle
A promptfoo example that automatically discovers jailbreaks in OpenAI's DALL-E model through an iterative prompt-retry loop against pre-configured adversarial test cases. Use only for authorized red-teaming of your own DALL-E integration - running it may get your OpenAI account flagged or banned. Filter-rejection errors during a run are expected.
What it does
This promptfoo example automatically discovers jailbreaks in OpenAI's DALL-E image generation model, using a set of pre-configured test cases that attempt to generate various different types of harmful content. When DALL-E's safety system rejects a prompt, promptfoo automatically retries with modified prompts in a loop until it succeeds or reaches a maximum number of iterations - by default 4 per test case, raised via PROMPTFOO_NUM_JAILBREAK_ITERATIONS.
When to use - and when NOT to
Use this only for authorized red-teaming of your own DALL-E integration to understand where its safety boundaries actually are - running it may get your OpenAI account flagged for moderation or banned, per the example's own explicit warning. Error messages like "blocked by our content filters" during a run are expected behavior, not a failure, since the whole point is probing where the filters hold and where they don't.
Inputs and outputs
export OPENAI_API_KEY=your_key_here
npx promptfoo@latest init --example redteam-dalle
npx promptfoo@latest eval
npx promptfoo@latest view
In the web UI, enable "Render model outputs as Markdown" to display generated images and set "Max text length" to unlimited, then use the magnifying-glass icon to inspect the final modified prompt, full conversation history, and scoring breakdown per iteration. DALL-E image URLs expire after 2 hours, so the example includes an extension hook that downloads each generated image locally to an images directory as soon as it's created, named by test description and timestamp.
Integrations
Enable debug logging with LOG_LEVEL=debug npx promptfoo@latest eval -j 1 to see the internal jailbreak-retry mechanics; reduce concurrency with -j 1 if you hit rate limits, and if you hit a timeout error the evaluation is likely still running in the background rather than failed. Test cases mirror those in promptfoo's own DALL-E jailbreak blog post, and can be reviewed or modified directly in promptfooconfig.yaml before running your own evaluation against them.
Who it's for
Security and safety teams authorized to red-team their own DALL-E integration who need an automated, iterative jailbreak-discovery loop rather than manually crafting adversarial prompts one at a time. The example's own test cases are drawn from promptfoo's published "Automated jailbreaking techniques with Dall-E" blog post, so teams can compare their own results against a documented baseline rather than starting from an empty config, and promptfoo's broader red-team documentation covers the same iterative-retry technique applied to other model types beyond image generation.
Source README
redteam-dalle (DALL-E Red Team Example)
You can run this example with:
npx promptfoo@latest init --example redteam-dalle
cd redteam-dalle
This example demonstrates how to use promptfoo to automatically discover jailbreaks in OpenAI's DALL-E image generation model. It includes pre-configured test cases that attempt to generate various types of harmful content.
⚠️ Warning: Running this example may get your OpenAI account flagged for moderation or banned.
Setup
Set your OpenAI API key:
export OPENAI_API_KEY=your_key_hereInitialize the example:
npx promptfoo@latest init --example redteam-dalle
Usage
Review and optionally modify the test cases in
promptfooconfig.yaml. The example includes the same test cases shown in our blog post.Run the evaluation:
npx promptfoo@latest evalView the results in the web UI:
npx promptfoo@latest viewImportant table settings:
- Under TABLE SETTINGS, enable "Render model outputs as Markdown" to display generated images
- Set "Max text length" to unlimited to view complete responses
- Click the magnifying glass icon (🔍) in the "View output and test details" column to see the final modified prompt that was used, complete conversation history, and scoring breakdown for each iteration.
Expected Behavior
During evaluation, you may see error messages like:
Error from target provider: 400 Your request was rejected as a result of our safety system.
Error from target provider: 400 This request has been blocked by our content filters.
This is normal expected behavior. Promptfoo automatically retries with modified prompts in a loop until it succeeds or reaches the maximum number of iterations.
Configuration
The default configuration uses 4 iterations per test case. To increase this (and potentially find more jailbreaks), set:
export PROMPTFOO_NUM_JAILBREAK_ITERATIONS=6For debugging or to see the internal workings, enable debug logging:
LOG_LEVEL=debug npx promptfoo@latest eval -j 1
Troubleshooting
Note: DALL-E image URLs expire after 2 hours. The example includes an extension hook that downloads images to a local images directory as soon as they are generated. Each image is saved with a filename based on the test description and timestamp.
- If you get rate limit errors, try reducing concurrency with
-j 1 - If you get timeout errors, the evaluation is still running in the background. Wait a few minutes and check the results
- For other issues, please check our documentation or file an issue
Learn More
For more details about LLM red teaming with promptfoo, check out:
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.