Skip to content

Gemini Omni Flash 视频 API

Gemini Omni Flash 是高性能多模态模型,适合快速视频生成、视频编辑和电影化控制。它可以同时理解文本、图片、音频和视频,通过 Interactions API 支持对话式编辑,并结合 Gemini 的世界知识处理物理场景和叙事细节。

调用方式

接口与鉴权

使用 Gemini 兼容的 Interactions 接口:

text
POST https://api.exchangetoken.ai/v1beta/interactions

使用 Exchange Token API Key,支持以下任一鉴权 Header:

http
x-goog-api-key: YOUR_API_KEY
http
Authorization: Bearer YOUR_API_KEY

Content-Type Header:

http
Content-Type: application/json

Request Body

请求体遵循 Interactions create schema。下方示例主要使用这些字段:

字段类型必填说明
modelstring模型名称。使用 gemini-omni-flash-preview
inputstring、content object 或 content arrayinteraction 的主输入内容。文生视频可直接传字符串;图生视频或视频编辑传多模态数组。
input[].typestring条件必填内容项类型,例如 textimagevideouser_input
input[].textstring条件必填typetext 时传入文本提示词。
input[].datastring条件必填图片或视频输入的 base64 编码媒体内容。
input[].mime_typestring条件必填媒体输入的 MIME 类型,例如 image/jpegimage/pngvideo/mp4
input[].contentarray条件必填使用 user_input 包装时传入的嵌套内容数组。
response_formatobject输出格式配置。视频输出可传 {"type":"video"}
response_format.typestring输出类型。该模型使用 video
response_format.aspect_ratiostring视频画面比例。示例中使用 16:99:16
generation_configobject生成配置。
generation_config.video_config.taskstring可选的视频任务提示。支持 text_to_videoimage_to_videoreference_to_videoedit

Response Body

常见字段:

字段类型说明
idstringinteraction 的唯一标识
objectstring资源类型标识,通常为 interaction
statusstring当前 interaction 状态,例如 in_progresscompletedfailed
rolestring响应载荷对应的角色,通常为 model
createdstringinteraction 的 ISO 8601 创建时间
updatedstringinteraction 的 ISO 8601 更新时间
modelstring本次 interaction 使用的模型名称
stepsarrayinteraction 返回的有序步骤对象
usageobject上游返回时附带的 token usage 汇总信息

常见的 steps 字段:

字段类型说明
typestring步骤类型,例如 model_output
contentarray该步骤携带的内容项

示例:

json
{
  "id": "v1_...",
  "status": "completed",
  "role": "model",
  "created": "2026-05-27T06:15:03Z",
  "updated": "2026-05-27T06:15:03Z",
  "steps": [
    {
      "content": [
        {
          "text": "",
          "type": "text"
        }
      ],
      "type": "model_output"
    },
    {
      "content": [
        {
          "mime_type": "video/mp4",
          "data": "AAAAIGZ0eXBpc29t...",
          "type": "video"
        }
      ],
      "type": "model_output"
    }
  ],
  "object": "interaction",
  "model": "gemini-omni-flash-preview"
}

文生视频

根据文本提示词生成带音频的视频。建议在提示词里写清楚场景、镜头运动、光线、氛围和关键动作。

bash
curl -X POST "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": "A marble rolling fast on a chain reaction style track, continuous smooth shot."
  }'

控制画面比例

设置 response_format.aspect_ratio9:16 可生成竖屏视频。默认是横屏 16:9

bash
curl -X POST "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": "A futuristic city with neon lights and flying cars, cyberpunk style",
    "response_format": {
      "type": "video",
      "aspect_ratio": "9:16"
    }
  }'

图生视频

可以把参考图和文本提示词一起传入。模型会根据提示词判断如何使用图片,适合让产品图、插画或照片动起来。

bash
curl -X POST "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": [
      { "type": "image", "data": "'"$BASE64_IMAGE"'", "mime_type": "image/jpeg" },
      { "type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video" }
    ]
  }'

TIP

图生视频建议使用高清图片,并写清楚运动方式。像“让它动起来”这类笼统提示,通常不如明确描述镜头、主体动作和环境变化效果好。

主体参考

你可以传入多张图片作为主体参考。例如,传入猫和毛线球两张图片,生成猫玩毛线球的视频。

bash
curl -X POST "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": [
      { "type": "image", "data": "'"$CAT_B64"'", "mime_type": "image/png" },
      { "type": "image", "data": "'"$YARN_B64"'", "mime_type": "image/png" },
      { "type": "text", "text": "A cat playfully batting at a ball of yarn." }
    ]
  }'

task 参数

使用 generation_config.video_config.task 可以明确告诉模型你要执行的任务。如果不传,模型会根据提示词自动判断。

可选值:

  • text_to_video
  • image_to_video
  • reference_to_video
  • edit
bash
curl -X POST "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": [
      { "type": "image", "data": "'"$BASE64_IMAGE"'", "mime_type": "image/jpeg" },
      { "type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video" }
    ],
    "generation_config": {
      "video_config": {
        "task": "image_to_video"
      }
    }
  }'

编辑自己的视频

传入或上传已有视频后,可以要求 Gemini Omni Flash 进行编辑。

bash
VIDEO_B64=$(base64 -w 0 "$VIDEO_FILE")

curl -sS -w "\n[HTTP %{http_code}]\n" "https://api.exchangetoken.ai/v1beta/interactions" \
  -H "x-goog-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": [
      {
        "type": "user_input",
        "content": [
          {
            "type": "video",
            "mime_type": "video/mp4",
            "data": "'"$VIDEO_B64"'"
          },
          {
            "type": "text",
            "text": "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person arm turns into reflective mirror material"
          }
        ]
      }
    ],
    "response_format": { "type": "video" }
  }'