examples/openai-images/README.md
You can run this example with:
npx promptfoo@latest init --example openai-images
cd openai-images
A simple example showing how to evaluate OpenAI's current image generation models (GPT Image 2, GPT Image 1.5, GPT Image 1, GPT Image 1 Mini) with promptfoo.
# Create this example
npx promptfoo@latest init --example openai-images
# Set your API key
export OPENAI_API_KEY=your-key-here
# Run the evaluation
promptfoo eval
# View the results
promptfoo view
OpenAI's latest image generation model with flexible custom sizes and improved output controls.
providers:
- id: openai:image:gpt-image-2
config:
size: 1024x1024 # common sizes, custom WIDTHxHEIGHT, auto
quality: low # low, medium, high, auto
background: opaque # opaque, auto
output_format: webp # png, jpeg, webp
output_compression: 80 # 0-100, only set with jpeg/webp
moderation: auto # auto, low
n: 1 # 1-10 images
user: promptfoo-user # optional end-user identifier
High-quality GPT Image model with strong instruction following, prompt adherence, and photorealistic quality. Uses token-based pricing.
providers:
- id: openai:image:gpt-image-1.5
config:
size: 1024x1024 # 1024x1024, 1024x1536, 1536x1024, auto
quality: low # low, medium, high, auto
background: transparent # transparent, opaque, auto
output_format: webp # png, jpeg, webp
output_compression: 80 # 0-100, only set with jpeg/webp
moderation: auto # auto, low
High-quality image generation model with superior instruction following and text rendering.
providers:
- id: openai:image:gpt-image-1
config:
size: 1024x1024 # 1024x1024, 1024x1536, 1536x1024, auto
quality: low # low, medium, high, auto
background: transparent # transparent, opaque, auto
output_format: webp # png, jpeg, webp
output_compression: 80 # 0-100, only set with jpeg/webp
moderation: auto # auto, low
Cost-efficient version of GPT Image 1 with the same capabilities at lower cost.
providers:
- id: openai:image:gpt-image-1-mini
config:
size: 1024x1024 # 1024x1024, 1024x1536, 1536x1024, auto
quality: low # low, medium, high, auto
background: transparent # transparent, opaque, auto
output_format: webp # png, jpeg, webp
output_compression: 80 # 0-100, only set with jpeg/webp
moderation: auto # auto, low
dall-e-3 and dall-e-2 remain supported by the provider for backward compatibility, but they are deprecated by OpenAI. Use gpt-image-2, gpt-image-1.5, gpt-image-1, or gpt-image-1-mini for new evals.
Promptfoo's openai:image provider currently supports text-to-image generation. Image edits/reference inputs, variations, and streaming partial images are not part of this example and are rejected if configured.
| Model | Quality | Size | Price per image |
|---|---|---|---|
| GPT Image 2 | Low | 1024x1024 | $0.006 |
| GPT Image 2 | Medium | 1024x1024 | $0.053 |
| GPT Image 2 | High | 1024x1024 | $0.211 |
| GPT Image 1.5 | Low | 1024x1024 | ~$0.064 |
| GPT Image 1.5 | Medium | 1024x1024 | ~$0.128 |
| GPT Image 1.5 | High | 1024x1024 | ~$0.192 |
| GPT Image 1 | Low | 1024x1024 | $0.011 |
| GPT Image 1 | Medium | 1024x1024 | $0.042 |
| GPT Image 1 | High | 1024x1024 | $0.167 |
| GPT Image 1 Mini | Low | 1024x1024 | $0.005 |
| GPT Image 1 Mini | Medium | 1024x1024 | $0.011 |
| GPT Image 1 Mini | High | 1024x1024 | $0.036 |
Note: Prices shown are 1024x1024 output image estimates and do not include input text tokens. For GPT Image 2 auto quality or custom sizes, promptfoo preserves OpenAI usage metadata and leaves cost unset instead of guessing.