What is DallETool?
DallETool wraps OpenAI's image generation API so agents can produce marketing visuals, UI mockups, or illustrative diagrams as part of a larger Crew workflow. Constructor knobs mirror the public API — model family, pixel dimensions, and quality tier — which directly drive latency and price per image. Because image calls are orders of magnitude more expensive than text tokens, gate the tool behind explicit task instructions or a human approval step when budgets are tight.
Returned URLs are often time-bounded; if you need durable assets, download and persist to object storage inside an @after_kickoff hook rather than assuming the CDN link survives forever. Content policy refusals surface as tool errors — teach agents to rewrite prompts conservatively instead of looping the same banned phrase.
Combine with FileWriterTool or a custom upload tool when your pipeline must attach generated images to tickets, CMS posts, or slide decks automatically.
When to Use
Visual content needs in your crew (illustrations, mockups).
Use Cases
- • Marketing content
- • Illustrative diagrams
Key Features
- ✓ Multiple sizes
- ✓ Model selection
When NOT to Use
High-volume production imagery — use a dedicated provider.
Notes
OPENAI_API_KEY and org billing
Image endpoints bill separately from chat completions. Monitor usage in the OpenAI dashboard and set monthly caps so autonomous agents cannot exhaust budgets overnight.
Latency vs crew timeouts
HD generations can exceed default task timeouts. Increase max_execution_time on the Agent or split image work into its own short crew.
Moderation refusals
When the API rejects a prompt, return a helpful error string from a wrapper tool so the agent explains the refusal to end users instead of retrying blindly.
Storage of binary output
If your integration returns bytes, stream them to disk or S3 immediately — keeping large byte strings in CrewOutput can balloon memory.
Import
from crewai_tools import DallETool
Key Parameters
| Parameter | Type | Default | Purpose |
|---|---|---|---|
| model | str | 'dall-e-3' | OpenAI model id. |
| size | str | '1024x1024' | Image size. |
| quality | str | 'standard' | 'standard' or 'hd'. |
Code Examples
Default DALL·E 3 tool on an agent
from crewai import Agent
from crewai_tools import DallETool
artist = Agent(
role='Visual designer',
goal='Create hero imagery',
backstory='You follow brand colors strictly.',
tools=[DallETool()],
)
Landscape slide with hd quality
from crewai_tools import DallETool
tool = DallETool(model='dall-e-3', size='1792x1024', quality='hd')
Square social asset
from crewai_tools import DallETool
tool = DallETool(model='dall-e-3', size='1024x1024', quality='standard')
Common Mistakes
❌ Assuming returned URLs are permanent
✅ Download and store assets you need long-term.
DallETool FAQ
What is DallETool in CrewAI?
Image generation via OpenAI DALL·E — returns an image URL or bytes. DallETool wraps OpenAI's image generation API so agents can produce marketing visuals, UI mockups, or illustrative diagrams as part of a larger Crew workflow. Constructor knobs mirror the public API — model family, pixel dimensions, and quality tier — which directly drive latency and price per image. Because image calls are orders of magnitude more expensive than text tokens, gate the tool behind explicit task instructions or a human approval step when budgets are tight. Ret…
Which package defines the CrewAI class DallETool?
DevShelfHub maps DallETool to Python module crewai_tools (package path crewai_tools in this reference). Pin your installed crewai version and match imports to the snippet on this page.
When should I use DallETool?
Visual content needs in your crew (illustrations, mockups).
When should I avoid using DallETool?
High-volume production imagery — use a dedicated provider.
How do I import DallETool in Python?
from crewai_tools import DallETool
Where can I explore more CrewAI API reference pages?
Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.