Multimodal Agent
Send a local image to an Ollama gemma3 agent that writes a 3 sentence fiction story about it.
Code
from pathlib import Path
from agno.agent import Agent
from agno.media import Image
from agno.models.ollama import Ollama
agent = Agent(
model=Ollama(host="http://localhost:11434", api_key=None, 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
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateStart the local Ollama service
Install Ollama and start its desktop app or service on http://localhost:11434. If you start it manually with ollama serve, keep that process running in a separate terminal.
In the terminal where you will pull models and run Python, select that server and clear the direct-cloud key. The native Ollama client also reads this key independently of Agno.
export OLLAMA_HOST=http://localhost:11434
unset OLLAMA_API_KEYPull the model
ollama pull gemma3Install dependencies
uv pip install -U ollama agnoAdd 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.
Run Agent
python multimodal_agent.py