Image To Image

Transform images using agent-driven processing.

Image To Image.

1"""
2Image To Image
3=============================
4
5Image To Image.
6"""
7
8from kern.agent import Agent
9from kern.models.openai import OpenAIResponses
10from kern.tools.fal import FalTools
11
12# ---------------------------------------------------------------------------
13# Create Agent
14# ---------------------------------------------------------------------------
15agent = Agent(
16 model=OpenAIResponses(id="gpt-5.2"),
17 id="image-to-image",
18 name="Image to Image Agent",
19 tools=[FalTools()],
20 markdown=True,
21 instructions=[
22 "You have to use the `image_to_image` tool to generate the image.",
23 "You are an AI agent that can generate images using the Fal AI API.",
24 "You will be given a prompt and an image URL.",
25 "You have to return the image URL as provided, don't convert it to markdown or anything else.",
26 ],
27)
28
29# ---------------------------------------------------------------------------
30# Run Agent
31# ---------------------------------------------------------------------------
32if __name__ == "__main__":
33 agent.print_response(
34 "a cat dressed as a wizard with a background of a mystic forest. Make it look like 'https://fal.media/files/koala/Chls9L2ZnvuipUTEwlnJC.png'",
35 stream=True,
36 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/12_multimodal
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python image_to_image.py