Skip to main content
Mellea supports multimodal input: pass images alongside your text prompt to any 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 as granite3.2-vision or llava. Not all backends support vision — see backend notes below.

Basic usage with Ollama

Start a session with a vision-capable model, then pass a Pillow Image object in the images list:
Other vision-capable Ollama models: llava, llava-phi3, moondream, qwen2.5vl:7b.

Using ImageBlock for explicit control

For the OpenAI backend (and compatible endpoints), convert the PIL image to an ImageBlock first:
Both PIL images and 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 to instruct() or chat() are stored in the ChatContext turn history. Subsequent calls in the same session can reference the image without passing it again:
To remove images from context on the next turn, pass images=[] explicitly.

Backend support

Full example (Ollama): docs/examples/image_text_models/vision_ollama_chat.py Full example (OpenAI backend): docs/examples/image_text_models/vision_openai_examples.py

See also: Working with Data | The Instruction Model