How It Works
Quick Start
1
Simple Usage
OPENAI_API_KEY in your environment before running.2
With Configuration
3
Async
achat() is genuinely non-blocking as of PR #5219 — the image round-trip runs on a worker thread, not the event loop. See Non-blocking async below.pip install "praisonaiagents[llm]"
Non-blocking async (PR #5219)
ImageAgent.agenerate_image, agenerate, aedit, avariation, and (transitively) achat now offload the synchronous image call via asyncio.to_thread, so awaiting one no longer freezes the event loop for the 10–60 second image round-trip.
Reference: PR #5219, fixes #5162.
Run an ImageAgent and a text-only Agent side by side — the text agent keeps streaming while the image generates:
Features
DALL-E Integration
Seamless integration with DALL-E for high-quality image generation.
Async Support
Asynchronous operations for better performance in concurrent environments.
Natural Style
Generate images with natural, realistic styling options.
Verbose Mode
Detailed output logging for better debugging and monitoring.
Best Practices
Use environment variables for API keys
Use environment variables for API keys
Read
OPENAI_API_KEY from the environment — never hardcode keys in source files.Pick the right model
Pick the right model
Use
dall-e-3 for quality; switch models via the llm parameter when cost or speed matters more.Prefer async in web apps
Prefer async in web apps
Use
achat() when serving multiple concurrent image requests from a FastAPI or gateway handler.Describe style explicitly
Describe style explicitly
Pass
style="natural" or include style cues in the prompt for consistent visual output across runs.Related
Multimodal
Text, image, and audio processing with agents
Outbound Media Delivery
Deliver generated images to users via messaging bots
Async Safety
How blocking calls are offloaded to keep the event loop responsive

