The image_generation (specifically openai_image_generation) tool empowers agents to create and edit visual content directly within a conversation. It leverages advanced generative AI models (such as DALL-E 3) to turn natural language descriptions into high-quality images.
Beyond simple creation, this tool supports image-to-image workflows, allowing you to provide source documents as references for editing or style transfer.
Use image_generation when you need to:
- Visualize Concepts: Turn abstract ideas into concrete visual representations.
- Create Assets: Generate illustrations, icons, or marketing materials.
- Edit Images: Modify existing images based on natural language instructions (e.g., “Add a red hat to the person in this photo”).
- Mockup UI: Quickly generate visual prototypes for interfaces or layouts.
The tool accepts the following parameters:
Prompt EngineeringModern image models often rewrite your prompt to optimize it. The tool returns the revised_prompt in the output, which shows you exactly how the model interpreted your request.
Output Structure
The tool returns a structured object containing references to the generated images and metadata.
Example Usage
1. Text-to-Image Creation
Generating an image from scratch.
Input:
2. Image Editing
Modifying an existing asset.
Input:
Note: The document provided in document_ids must be a valid image file (PNG, JPG, WEBP).
Capabilities
Source Image Support
One of the most powerful features of this tool is its ability to accept source images. By passing document_ids, you can:
- Edit: Ask the model to add, remove, or change elements in the uploaded picture.
- Inspire: Use the composition or color palette of the source image to guide the new generation.
Automatic Optimization
The tool handles the complexity of image formats and API constraints for you. It automatically:
- Converts uploaded documents to the correct format (PNG) required by the model.
- Resizes images if they exceed the maximum input dimensions.
- Manages temporary storage for intermediate processing steps.