Examples
Image Generation using DALL-E
Hackathon Resources
- Introduction
- Setup
- Examples
- Simple Text Agent
- Agent with Tools
- Agent with Knowledge
- Agent with Structured Outputs
- Research Agent
- YouTube Agent
- Image Input + Tools
- Image Generation using DALL-E
- Image to Structured Output
- Image Generate Audio
- Image Input + Output
- Image Transcription
- Image search using Giphy
- Audio Input
- Audio Input Output
- Audio Sentiment
- Audio Transcript
- Audio Multi Turn
- Audio Generate Podcast
- Video Input
- Video Generation with Models Lab
- Video Generation with Replicate
- Video Captions
- Video to Shorts
- Models
- Pre-built Replit Template
- 🏆 Prizes
Examples
Image Generation using DALL-E
This agent can generate images using DALL-E.
generate_image.py
from agno.agent import Agent, RunResponse
from agno.models.openai import OpenAIChat
from agno.tools.dalle import DalleTools
from agno.utils.log import logger
from rich.pretty import pprint
image_agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[DalleTools()],
instructions="Use the `create_image` tool to generate images.",
show_tool_calls=True,
markdown=True,
)
if __name__ == "__main__":
run_response: RunResponse = image_agent.run(
"Generate an image of a white siamese cat"
)
images = image_agent.get_images()
if images and isinstance(images, list):
for i, image_response in enumerate(images, 1):
logger.info(f"Image {i}: {image_response.url}")
else:
logger.info("No images were generated.")
print("---" * 20)
pprint(run_response.images)
Usage
1
Install libraries
pip install -U agno openai
2
Export API keys
export OPENAI_API_KEY=***
3
Run the agent
python generate_image.py
On this page