DalleTools, whose supported DALL-E models are deprecated. Migrate the image path to GPT Image 2 before use.
generate_images.py
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Legacy DalleTools example that generates an image and reads its URL from the run output.
DalleTools, whose supported DALL-E models are deprecated. Migrate the image path to GPT Image 2 before use.
"""
Openai Generate Images
======================
Cookbook example for `openai/chat/generate_images.py`.
"""
from agno.agent import Agent, RunOutput
from agno.models.openai import OpenAIChat
from agno.tools.dalle import DalleTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
image_agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[DalleTools()],
description="You are an AI agent that can generate images using DALL-E.",
instructions="When the user asks you to create an image, use the `create_image` tool to create the image.",
markdown=True,
)
image_agent.print_response("Generate an image of a white siamese cat")
# Retrieve and display generated images using get_last_run_output
run_response = image_agent.get_last_run_output()
if run_response and isinstance(run_response, RunOutput) and run_response.images:
for image_response in run_response.images:
image_url = image_response.url
print(image_url)
else:
print("No images found in run response")
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
pass
Was this page helpful?