跳过至正文
视觉模型支持同时输入图像和文本,以便模型可以对所见内容进行描述、分类并回答相关问题。

快速开始

ollama run gemma3 ./image.png whats in this image?

在 Ollama API 中使用

提供一个 images 数组。SDK 接受文件路径、URL 或原始字节,而 REST API 则要求提供 Base64 编码的图像数据。
# 1. Download a sample image
curl -L -o test.jpg "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"

# 2. Encode the image
IMG=$(base64 < test.jpg | tr -d '\n')

# 3. Send it to Ollama
curl -X POST https://:11434/api/chat \
-H "Content-Type: application/json" \
-d '{
    "model": "gemma3",
    "messages": [{
    "role": "user",
    "content": "What is in this image?",
    "images": ["'"$IMG"'"]
    }],
    "stream": false
}'