跳转到主要内容
视觉模型可以在处理文本提示的同时分析图片。可用于图像理解、信息提取、分类、视觉问答以及多模态推理。 Venice 支持与 OpenAI 兼容的多模态聊天消息。将文本块和图片块放入同一条用户消息中,然后把请求发送给具备视觉能力的模型即可。

基本用法

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VENICE_API_KEY"],
    base_url="https://api.venice.ai/api/v1",
)

response = client.chat.completions.create(
    model="qwen3-vl-235b-a22b",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Describe this image in three bullets."},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://www.gstatic.com/webp/gallery/1.jpg"
                    },
                },
            ],
        }
    ],
)

print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.VENICE_API_KEY,
  baseURL: "https://api.venice.ai/api/v1",
});

const response = await client.chat.completions.create({
  model: "qwen3-vl-235b-a22b",
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Describe this image in three bullets." },
        {
          type: "image_url",
          image_url: {
            url: "https://www.gstatic.com/webp/gallery/1.jpg",
          },
        },
      ],
    },
  ],
});

console.log(response.choices[0].message.content);
curl https://api.venice.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-vl-235b-a22b",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "Describe this image in three bullets."},
          {
            "type": "image_url",
            "image_url": {
              "url": "https://www.gstatic.com/webp/gallery/1.jpg"
            }
          }
        ]
      }
    ]
  }'

使用 Base64 图片

当图片位于本地或属于私有内容时,你也可以传入 base64 数据 URL:
{
  "type": "image_url",
  "image_url": {
    "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  }
}

选择视觉模型

可在 文本模型 页面或通过 Models API 查找支持视觉的模型。模型能力列表中会标明其是否支持视觉。
对于类文档类的输入,如果希望 Venice 从文件中提取文本,请使用 文件输入。当视觉版式或图像内容本身很重要时,才使用视觉能力。

提示词建议

  • 明确告诉模型关注的重点:物体、文字、版式、安全性、缺陷或差异等。
  • 如果你的应用需要可解析的字段,请要求模型给出结构化输出。
  • 保证图片 URL 对 API 可访问,或对私有图片使用 base64 数据 URL。
  • 若图片会与较长指令一起使用,请选择具有足够上下文长度的模型。

相关资源