跳到主要内容

视觉理解

SpAk 模型支持视觉理解能力:在对话中传入图片(URL 或 Base64),模型可以理解图片内容并基于图片回答问题。

使用方法​

在 messages 中以 image_url 形式传入图片即可,支持 image/png、image/jpeg、image/webp 等常见格式。

from openai import OpenAI

client = OpenAI(
api_key="<your api key>",
base_url="https://yuansuo.top",
)

response = client.chat.completions.create(
model="SpAk-Aster-V1-MOE",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "这张图片里有什么?"},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image.png"},
},
],
}
],
)

print(response.choices[0].message.content)

注意事项​

  1. 单次请求最多传入 8 张图片。
  2. 单张图片大小不超过 10MB,Base64 编码后不超过 12MB。
  3. 视觉理解与思考模式可以同时使用。