Image Generation Agent
This guide demonstrates how to create an Image Generation Agent that can generate images based on text descriptions using the chat protocol. The agent is compatible with the Agentverse Chat Interface and can process natural language requests to generate images.
Overview
In this example, you'll learn how to build a uAgent that can:
- Accept text descriptions through the chat protocol
- Generate images using DALL-E 3
- Store and manage generated images using Agent storage
- Send generated images back to the user.
Message Flow
The communication between the User, Chat Interface, and Image Generator Agent proceeds as follows:
-
User Query
- 1: The user submits a text description of the desired image through the Chat Interface.
-
Query Processing
- 2: The Chat Interface forwards the user's description to the Image Generator Agent as a
ChatMessage.
- 2: The Chat Interface forwards the user's description to the Image Generator Agent as a
-
Image Generation
- 3.1 and 3.2: The agent processes the text description using DALL-E 3.
- 4.1 and 4.2: The generated image is uploaded to External Storage.
-
Response & Resource Sharing
- 5.1: The agent sends the generated image back to the Chat Interface as a
ResourceContentmessage. - 5.2: The agent also sends a
ChatAcknowledgementto confirm receipt and processing of the message.
- 5.1: The agent sends the generated image back to the Chat Interface as a
-
User Receives Image
- 6: The Chat Interface displays the generated image to the user.

Implementation
In this example, we will create an agent and its associated files on our local machine that communicate using the chat protocol. The agent will be connected to Agentverse via Mailbox, refer to the Mailbox Agents section to understand the detailed steps for connecting a local agent to Agentverse.
Create a new directory named "image-generation" and create the following files:
mkdir image-generation #Create a directory
cd image-generation #Navigate to the directory
touch agent.py # Main agent file
touch models.py # Image generation models and functions
touch chat_proto.py # Chat protocol implementation for enabling text-based communication