Implementation:CrewAIInc CrewAI DALL E Tool
| Knowledge Sources | |
|---|---|
| Domains | Tools, Image_Generation |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Generates images from text descriptions using OpenAI's DALL-E API.
Description
DallETool extends BaseTool to provide image generation capabilities through OpenAI's DALL-E models. It accepts a natural language image description via ImagePromptSchema, sends it to the DALL-E API with configurable model, size, quality, and count parameters, and returns a JSON string containing the generated image URL and the revised prompt that DALL-E actually used. The tool requires the OPENAI_API_KEY environment variable to authenticate with OpenAI services.
Usage
Use this tool when a CrewAI agent needs to generate visual content programmatically, such as creating illustrations for reports, generating product mockups, or producing images based on textual specifications.
Code Reference
Source Location
- Repository: CrewAI
- File:
lib/crewai-tools/src/crewai_tools/tools/dalle_tool/dalle_tool.py - Lines: 1-75
Signature
class DallETool(BaseTool):
name: str = "Dall-E Tool"
description: str = "Generates images using OpenAI's Dall-E model."
args_schema: type[BaseModel] = ImagePromptSchema
model: str = "dall-e-3"
size: Literal["auto", "1024x1024", "1536x1024", "1024x1536",
"256x256", "512x512", "1792x1024", "1024x1792"] | None = "1024x1024"
quality: Literal["standard", "hd", "low", "medium", "high", "auto"] | None | Omit = "standard"
n: int = 1
def _run(self, **kwargs) -> str: ...
Import
from crewai_tools import DallETool
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| image_description | str | Yes | Natural language description of the image to generate |
| model | str | No | DALL-E model to use (default: dall-e-3)
|
| size | str | No | Image dimensions (default: 1024x1024)
|
| quality | str | No | Image quality level (default: standard)
|
| n | int | No | Number of images to generate (default: 1)
|
Outputs
| Name | Type | Description |
|---|---|---|
| _run() returns | str | JSON string with image_url and image_description (revised prompt), or an error message
|
Usage Examples
Basic Usage
from crewai_tools import DallETool
tool = DallETool()
result = tool.run(image_description="A futuristic cityscape at sunset")
Custom Configuration
from crewai_tools import DallETool
tool = DallETool(
model="dall-e-3",
size="1792x1024",
quality="hd",
n=1,
)