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_KEYhttp
Authorization: Bearer YOUR_API_KEYContent-Type Header:
http
Content-Type: application/jsonRequest Body
请求体遵循 Interactions create schema。下方示例主要使用这些字段:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称。使用 gemini-omni-flash-preview。 |
input | string、content object 或 content array | 是 | interaction 的主输入内容。文生视频可直接传字符串;图生视频或视频编辑传多模态数组。 |
input[].type | string | 条件必填 | 内容项类型,例如 text、image、video、user_input。 |
input[].text | string | 条件必填 | 当 type 为 text 时传入文本提示词。 |
input[].data | string | 条件必填 | 图片或视频输入的 base64 编码媒体内容。 |
input[].mime_type | string | 条件必填 | 媒体输入的 MIME 类型,例如 image/jpeg、image/png、video/mp4。 |
input[].content | array | 条件必填 | 使用 user_input 包装时传入的嵌套内容数组。 |
response_format | object | 否 | 输出格式配置。视频输出可传 {"type":"video"}。 |
response_format.type | string | 否 | 输出类型。该模型使用 video。 |
response_format.aspect_ratio | string | 否 | 视频画面比例。示例中使用 16:9 和 9:16。 |
generation_config | object | 否 | 生成配置。 |
generation_config.video_config.task | string | 否 | 可选的视频任务提示。支持 text_to_video、image_to_video、reference_to_video、edit。 |
Response Body
常见字段:
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | interaction 的唯一标识 |
object | string | 资源类型标识,通常为 interaction |
status | string | 当前 interaction 状态,例如 in_progress、completed、failed |
role | string | 响应载荷对应的角色,通常为 model |
created | string | interaction 的 ISO 8601 创建时间 |
updated | string | interaction 的 ISO 8601 更新时间 |
model | string | 本次 interaction 使用的模型名称 |
steps | array | interaction 返回的有序步骤对象 |
usage | object | 上游返回时附带的 token usage 汇总信息 |
常见的 steps 字段:
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 步骤类型,例如 model_output |
content | array | 该步骤携带的内容项 |
示例:
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_ratio 为 9: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_videoimage_to_videoreference_to_videoedit
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" }
}'