instruct() or chat() call using the images parameter.
Prerequisites: pip install mellea pillow, a vision-capable model downloaded and
running.
Backend note: The default Ollama model (granite4.1:3b) does not support image input. You must switch to a vision-capable model such asgranite3.2-visionorllava. Not all backends support vision — see backend notes below.
Basic usage with Ollama
Start a session with a vision-capable model, then pass a PillowImage object in the images list:
llava, llava-phi3, moondream, qwen2.5vl:7b.
Using ImageBlock for explicit control
For the OpenAI backend (and compatible endpoints), convert the PIL image to anImageBlock first:
ImageBlock objects are accepted in the images list. Use
ImageBlock when you need to work with an already-encoded representation or when
the PIL image is not directly available.
Multi-turn vision with ChatContext
Images passed toinstruct() or chat() are stored in the ChatContext
turn history. Subsequent calls in the same session can reference the image without
passing it again:
images=[] explicitly.
Backend support
Full example (Ollama):docs/examples/image_text_models/vision_ollama_chat.pyFull example (OpenAI backend):docs/examples/image_text_models/vision_openai_examples.py
See also: Working with Data | The Instruction Model