ImageAgent: Generating and saving visual assets
Generate images cleanly with ImageAgent
ImageAgent wraps image-generation models (such as DALL-E / GPT-Image / Imagen) behind one consistent API for blog headers, product mockups, and slide diagrams.
Example
from praisonai import ImageAgent
img_agent = ImageAgent(llm='dall-e-3')
result = img_agent.generate('Clean isometric diagram of 3 collaborating AI agents on white background')
print(result)Example explained
- ImageAgent(llm='dall-e-3') — Configures the target image generation backend.
- img_agent.generate(prompt) — Produces the image and returns its URL/local artifact metadata.
Improve image quality with a prompt-refinement step
Short prompts like 'AI agent' produce generic art. Specify subject, composition, lighting, color palette, and 'no illegible text' — or precede ImageAgent with a PromptExpanderAgent.
Common pitfall: generating images in an unchecked loop
Image generation calls cost 50x–100x more than short text completions. Cache generated assets by prompt hash and cap batch sizes explicitly.
Reference: documentation