从写代码,到创作下一幕

探索 字节跳动 - 火山方舟 的 AI 编程与视频创作活动。

火山方舟 Agent Plan 与 Coding Plan 活动,价格 ¥9.9 起

Agent Plan & Coding Plan

一站体验多款热门模型,为 AI 编程与智能体开发提供更多选择。新用户可联系(微信: goo_lvyouyou)免费体验 9.9 agent plan。

查看套餐优惠
Seedance 2.5 视频创作活动:30 秒视频、多模态参考、局部编辑

Seedance 2.5

让创意,跃然成片。探索 30 秒视频、多模态参考与局部编辑,把脑海中的画面变成下一支作品。

探索视频创作

模型能力

图像理解

查看 Markdown

部分模型允许在输入中包含图像。模型生成响应时会考虑图像上下文。

构建消息正文:与纯文本 prompt 的区别

图像理解的请求消息与纯文本 prompt 类似。主要区别在于,纯文本输入原本如下:

JSON

[
  {
    "role": "user",
    "content": "What is in this image?"
  }
]

现在将 content 作为对象列表传入:

JSON

[
  {
    "role": "user",
    "content": [
      {
        "type": "input_image",
        "image_url": "data:image/jpeg;base64,<base64_image_string>"
      },
      {
        "type": "input_text",
        "text": "What is in this image?"
      }
    ]
  }
]

image_url 的值也可以是互联网上的公开 URL,而不是 base64 data URL。

图像理解示例

import { xai } from '@ai-sdk/xai';
import { generateText } from 'ai';

const { text, response } = await generateText({
    model: xai.responses('grok-4.7'),
    messages: [
        {
            role: 'user',
            content: [
                {
                    type: 'image',
                    image: new URL('https://science.nasa.gov/wp-content/uploads/2023/09/web-first-images-release.png'),
                },
                {
                    type: 'text',
                    text: "What's in this image?",
                },
            ],
        },
    ]
});

console.log(text);

// The response ID can be used to continue the conversation
console.log(response.id);

图像输入的一般限制

  • 最大图像大小:20MiB

  • 图像最大数量:不限

  • 支持的图像文件类型:jpg/jpeg 或 png。

  • 可接受任意图像/文本输入顺序(例如文本 prompt 可以位于图像 prompt 之前)


最后更新:2026 年 5 月 30 日