Image To Text
Image to Text Example.
1"""2Image To Text3=============================45Image to Text Example.6"""78from pathlib import Path910from kern.agent import Agent11from kern.media import Image12from kern.models.openai import OpenAIResponses1314# ---------------------------------------------------------------------------15# Create Agent16# ---------------------------------------------------------------------------17agent = Agent(18 model=OpenAIResponses(id="gpt-5.2"),19 markdown=True,20)2122image_path = Path(__file__).parent.joinpath("sample.jpg")2324# ---------------------------------------------------------------------------25# Run Agent26# ---------------------------------------------------------------------------27if __name__ == "__main__":28 agent.print_response(29 "Write a 3 sentence fiction story about the image",30 images=[Image(filepath=image_path)],31 )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_text.py