跳轉到主要內容
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.