说明:下文的 https://接口地址为占位符,请替换成我们提供给你的实际接口地址。
/v1/chat/completions 调用,它走 Google 的 Interactions API,端点是 /v1beta/interactions。既能文本对话,也能文生视频。| 项目 | 值 |
|---|---|
| 接口地址 | https://接口地址 |
| 请求端点 | POST /v1beta/interactions |
| 完整 URL | https://接口地址/v1beta/interactions |
| 模型名 | gemini-omni-flash-preview |
| 内容类型 | Content-Type: application/json |
/v1/chat/completions 或 :generateContent 调用,会返回错误 only supported in the Interactions API,换成 /v1beta/interactions 端点即可。| 方式 | 写法 |
|---|---|
| 请求头(推荐) | 加请求头 Authorization: Bearer 你的Key |
| URL 参数 | 把 key 拼到地址后面 ?key=你的Key,不用带请求头 |
input 字段,不是 messages。返回结构(已精简):{
"id": "9YZZav-...",
"status": "completed",
"model": "gemini-omni-flash-preview",
"usage": { "total_tokens": 416, "total_input_tokens": 5, "total_output_tokens": 11 },
"steps": [
{ "type": "thought", "summary": [ { "text": "模型的思考过程...", "type": "text" } ] },
{ "type": "model_output", "content": [ { "text": "我是一个由 Google 训练的大型语言模型。", "type": "text" } ] }
]
}steps 数组里 type == "model_output" 那一项的 content[].text。type == "thought" 是思考过程。| 参数 | 说明 |
|---|---|
| response_format.type | 填 "video" 表示生成视频 |
| response_format.aspect_ratio | 画面比例,已测通 "16:9" |
{
"status": "completed",
"usage": { "total_tokens": 58393,
"output_tokens_by_modality": [ { "modality": "video", "tokens": 57920 } ] },
"steps": [
{ "type": "thought" },
{ "type": "model_output", "content": [
{ "type": "video", "mime_type": "video/mp4", "data": "<base64 视频数据>" }
] }
]
}steps 里 type == "model_output" 的 content[].data,是一段 base64 编码的 mp4,解码保存成 .mp4 文件即可播放。本次测试生成的文件为 3.1 MB,经 file 校验为标准 ISO Media MP4。"background": true,接口立即返回一个任务 id 和 in_progress 状态,之后凭 id 轮询查结果。{
"id": "video-970e6feb-4abd-4a63-ad53-89479924ada4",
"status": "in_progress",
"object": "interaction"
}status 为 in_progress 表示还在生成,隔几秒再查;变为 completed 后,返回结构与同步调用一致,视频在 steps 里 type=="model_output" 的 content[].data(base64 的 mp4)。本次实测轮询约 30 秒完成,取回文件 2.5 MB。