Code
Copy
Ask AI
from pathlib import Path
from agno.agent import Agent
from agno.media import Image
from agno.models.openai import OpenAIResponses
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
id="image-to-text",
name="Image to Text Agent",
markdown=True,
debug_mode=True,
instructions=[
"You are an AI agent that can generate text descriptions based on an image.",
"You have to return a text response describing the image.",
],
)
image_path = Path(__file__).parent.joinpath("sample.jpg")
agent.print_response(
"Write a 3 sentence fiction story about the image",
images=[Image(filepath=image_path)],
stream=True,
)
Usage
1
Set up your virtual environment
Copy
Ask AI
uv venv --python 3.12
source .venv/bin/activate
2
Set your API key
Copy
Ask AI
export OPENAI_API_KEY=xxx
3
Install dependencies
Copy
Ask AI
uv pip install -U openai agno
4
Run Agent
Copy
Ask AI
python cookbook/agent_basics/multimodal/image_to_text_agent.py