跳转到主要内容
POST
/
grok
/
v1
/
videos
/
edits
Create an xAI video edit job
curl --request POST \
  --url https://api.cometapi.com/grok/v1/videos/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "Add snow to the scene.",
  "video": {
    "url": "https://example.com/source.mp4"
  }
}
'
{
  "request_id": "e55813f7-911f-cfa8-208c-9c8e693b4d38"
}
使用此端点可通过文本指令编辑现有的 MP4。与全新生成请求相比,输出会更贴近源片段的时间节奏和构图。

发送请求前

  • 提供可访问的 video.url
  • 保持源片段简短;xAI 官方建议将编辑时长限制在约 8.7 秒以内
  • 使用聚焦的指令,描述一个明确的改动
  • 保存返回的 request_id,因为编辑与生成使用相同的轮询流程

编辑流程

1

提交编辑请求

发送源视频 URL、编辑 Prompt,以及 model: grok-imagine-video
2

轮询最终结果

调用 获取视频生成结果,直到任务完成。
3

存储编辑后的资源

下载最终输出,或将返回的 URL 转入你自己的存储流水线。

CometAPI 上有哪些变化

xAI 将视频编辑说明为与生成相同的异步生命周期,只是使用源视频而不是可选的源图像。CometAPI 保留了这一行为以及相同的轮询端点,因此你的编辑工作流仍然是:开始 -> 轮询 -> 下载。

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

请求体

application/json
prompt
string
必填

Edit instruction describing the change you want.

示例:

"Add snow to the scene."

video
object
必填

Source video to edit. xAI documents an input limit of about 8.7 seconds.

model
string
默认值:grok-imagine-video

xAI video model id.

示例:

"grok-imagine-video"

output
object

Optional output delivery configuration.

user
string

Optional end-user identifier.

响应

200 - application/json

Request accepted.

request_id
string
必填

Deferred request id used for polling.