Image To Image
Transform images using agent-driven processing.
Image To Image.
1"""2Image To Image3=============================45Image To Image.6"""78from kern.agent import Agent9from kern.models.openai import OpenAIResponses10from kern.tools.fal import FalTools1112# ---------------------------------------------------------------------------13# Create Agent14# ---------------------------------------------------------------------------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)2829# ---------------------------------------------------------------------------30# Run Agent31# ---------------------------------------------------------------------------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 repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/12_multimodal45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python image_to_image.py