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()
result = agent.generate("A sunset over mountains")
print(result.data[0].b64_json[:40], "...")

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")
print(result.data[0].b64_json[:40], "...")

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.

Edit Image

Basic

python
from praisonaiagents import ImageAgent

agent = ImageAgent()  # defaults to gpt-image-2.5-flare
result = agent.edit("photo.png", "Add a rainbow")
result.save("edited.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("edited.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")
variations = agent.variation("original.png", n=3)
for img in variations.data:
    print(img.url)

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().