Code

cookbook/models/ollama/image_agent_bytes.py
from pathlib import Path

from agno.agent import Agent
from agno.media import Image
from agno.models.ollama import Ollama

agent = Agent(
    model=Ollama(id="gemma3"),
    markdown=True,
)

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)],
)

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Install Ollama

Follow the installation guide and run:
ollama pull gemma3
3

Install libraries

pip install -U ollama agno
4

Add sample image

Place a sample image named sample.jpg in the same directory as your script, or update the image_path to point to your desired image.
5

Run Agent

python cookbook/models/ollama/image_agent_bytes.py