Use this file to discover all available pages before exploring further.
Image Generation in PraisonAI allows you to create high-quality images using natural language descriptions. The Image Agent supports both synchronous and asynchronous operations, making it flexible for various use cases.
First, install the PraisonAI Agents package with LLM support:
pip install "praisonaiagents[llm]"
2
Set API Key
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY=your_api_key_here
3
Create Agent
Create a new file image_gen.py with the basic setup:
from praisonaiagents.agent.image_agent import ImageAgent# Create an image agentagent = ImageAgent( llm="dall-e-3",)# Generate an imageresult = agent.chat("A cute baby sea otter playing with a laptop")print("Image generation result:", result)
1
Install Package
First, install the PraisonAI Agents package with LLM support:
pip install "praisonaiagents[llm]"
2
Set API Key
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY=your_api_key_here
3
Create Async Agent
Create a new file image_gen_async.py with the async setup:
import asynciofrom praisonaiagents import ImageAgentasync def main(): agent = ImageAgent( name="ImageCreator", llm="dall-e-3", style="natural" ) result = await agent.achat("A cute baby sea otter playing with a laptop") print(f"Image generation result: {result}")if __name__ == "__main__": asyncio.run(main())