Image Generation

AI image generation, editing, and variations

ImageAgent() works without llm=. It defaults to gpt-image-2.5-flare for generate() and edit(); variation() still defaults to dall-e-2, the only model with a variations endpoint. Pass llm= when you want a different image model (e.g. openai/gpt-image-2.5-sunburst).

Generate Image

Basic

python
from praisonaiagents import ImageAgent

agent = ImageAgent()
agent.generate("A sunset over mountains").save("sunset.png")

Advanced

python
from praisonaiagents import ImageAgent

agent = ImageAgent(llm="openai/gpt-image-2.5-flare")
result = agent.generate("A futuristic city", size="1536x1024", quality="high")
result.save("city.png")      # save the first image
print(result.usage)          # raw provider response is still accessible

quality is sent for any model when set (GPT image: "low", "medium", "high", "xhigh", "max", "auto"). style is forwarded only for the retired dall-e-3; ImageAgent drops it for other OpenAI models.

.save(path) decodes base64 or downloads the URL, so the same line works for every model. See Save to a file.

Edit Image

Basic

python
from praisonaiagents import ImageAgent

agent = ImageAgent()  # defaults to gpt-image-2.5-flare
agent.edit("photo.png", "Add a rainbow").save("photo-rainbow.png")

Advanced

python
from praisonaiagents import ImageAgent

agent = ImageAgent(llm="openai/gpt-image-2.5-flare")
result = agent.edit("photo.png", "Add sunset", mask="mask.png", size="1024x1024")
result.save("photo-sunset.png")

markup= is not supported — edit() raises ValueError. Use mask= or call the OpenAI SDK’s images.edit directly. See PR #6262.

Image Variations

python
from praisonaiagents import ImageAgent

# Defaults to dall-e-2 (only model with a variations endpoint); llm= shown for clarity
agent = ImageAgent(llm="openai/dall-e-2")
result = agent.variation("original.png", n=3)
for i, _ in enumerate(result.images):
    result.save(f"variation-{i}.png", index=i)

Models

ModelGenerateEditVariation
openai/gpt-image-2.5-flare (default)✅✅❌
openai/gpt-image-2.5-sunburst✅✅❌
openai/gpt-image-2.6-flare✅✅❌
openai/gpt-image-2.6-sunburst✅✅❌
openai/dall-e-2——✅ (variations only)

gpt-image-2.6-* models are rolling out and may return 403 model_not_found on some projects. OpenAI retired dall-e-2/dall-e-3 on 2026-05-12 and gpt-image-1 on 2026-10-23; dall-e-2 is kept only for variation().