Image To Image Transformation

Demonstrates collaborative style planning and image transformation.

image_to_image_transformation.py
"""
Image To Image Transformation
=============================

Demonstrates collaborative style planning and image transformation.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.fal import FalTools

# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
style_advisor = Agent(
    name="Style Advisor",
    role="Analyze and recommend artistic styles and transformations",
    model=OpenAIResponses(id="gpt-5.2"),
    instructions=[
        "Analyze the input image and transformation request",
        "Provide style recommendations and enhancement suggestions",
        "Consider artistic elements like composition, lighting, and mood",
    ],
)

image_transformer = Agent(
    name="Image Transformer",
    role="Transform images using AI tools",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[FalTools()],
    instructions=[
        "Use the `image_to_image` tool to generate transformed images",
        "Apply the recommended styles and transformations",
        "Return the image URL as provided without markdown conversion",
    ],
)

# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
transformation_team = Team(
    name="Image Transformation Team",
    model=OpenAIResponses(id="gpt-5.2"),
    members=[style_advisor, image_transformer],
    instructions=[
        "Transform images with artistic style and precision.",
        "Style Advisor: First analyze transformation requirements and recommend styles.",
        "Image Transformer: Apply transformations using AI tools with style guidance.",
    ],
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    transformation_team.print_response(
        "a cat dressed as a wizard with a background of a mystic forest. Make it look like 'https://fal.media/files/koala/Chls9L2ZnvuipUTEwlnJC.png'",
        stream=True,
    )

Before running

Replace FalTools() with FalTools(enable_generate_media=False, enable_image_to_image=True). The default toolkit exposes media generation but does not expose the image_to_image tool requested by these instructions.

Agno reads FAL_API_KEY, while the underlying Fal client reads FAL_KEY; export both as shown below.

The image URL in the prompt is text. To let the style advisor inspect its pixels, import Image from agno.media and pass the same URL with images=[Image(url="https://fal.media/files/koala/Chls9L2ZnvuipUTEwlnJC.png")] to print_response(). The Fal transformation still needs the URL as its image_url tool argument. Use an accessible replacement image if this sample URL is unavailable.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno fal-client openai

Export your API keys

export FAL_API_KEY="your_fal_api_key_here"
export FAL_KEY="$FAL_API_KEY"
export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as image_to_image_transformation.py, then run:

python image_to_image_transformation.py

Full source: cookbook/03_teams/19_multimodal/image_to_image_transformation.py