Dalle

Legacy DalleTools parameters and examples for OpenAI's deprecated DALL-E models.

DalleTools is retained as a legacy reference for generating images with OpenAI's deprecated DALL-E API.

DALL-E models are deprecated. This DalleTools example is retained as a legacy reference and no longer runs against the current OpenAI API. Use OpenAITools with GPT Image 2 in Image Generation Agent.

Legacy Requirements

This legacy example expected the openai package and an OPENAI_API_KEY. Its DalleTools calls no longer run against the current OpenAI API.

Example

The pinned agent used DALL-E to generate an image from a text prompt.

cookbook/91_tools/dalle_tools.py
from pathlib import Path

from agno.agent import Agent
from agno.tools.dalle import DalleTools
from agno.utils.media import download_image

# Example 1: Basic DALL-E agent with all functions enabled
agent = Agent(tools=[DalleTools(all=True)], name="DALL-E Image Generator")

# Example 2: Enable specific DALL-E functions
agent_specific = Agent(
    tools=[
        DalleTools(
            enable_create_image=True,
            model="dall-e-3",
            size="1024x1024",
            quality="standard",
        )
    ],
    name="Basic DALL-E Generator",
)

# Example 3: High-quality custom DALL-E generator
custom_dalle = DalleTools(all=True, model="dall-e-3", size="1792x1024", quality="hd")

agent_custom = Agent(
    tools=[custom_dalle],
    name="Custom DALL-E Generator",
)

agent.print_response(
    "Generate an image of a futuristic city with flying cars and tall skyscrapers",
    markdown=True,
)

response = agent_custom.run(
    "Create a panoramic nature scene showing a peaceful mountain lake at sunset",
    markdown=True,
)
if response.images and response.images[0].url:
    download_image(
        url=response.images[0].url,
        output_path=str(Path(__file__).parent.joinpath("tmp/nature.jpg")),
    )

Toolkit Params

ParameterTypeDefaultDescription
modelstr"dall-e-3"The DALL-E model to use
enable_create_imageboolTrueEnable the create image functionality
nint1Number of images to generate
sizestr"1024x1024"Image size (256x256, 512x512, 1024x1024, 1792x1024, or 1024x1792)
qualitystr"standard"Image quality (standard or hd)
styleOptional[str]NoneImage style (vivid or natural). Only sent to the API when set
api_keyOptional[str]NoneThe OpenAI API key for authentication. Uses OPENAI_API_KEY if not set
allboolFalseEnable all functionality when set to True

Toolkit Functions

FunctionDescription
create_imageGenerates an image based on a text prompt

Developer Resources