Animate the reference as one quiet continuous six-second wildlife shot. The same pangolin slowly raises its small head to sniff the damp air; its long scaled tail makes a slight natural movement without changing shape. One droplet falls from a bamboo leaf near it. Preserve the pangolin's anatomy, scale pattern, position and the bamboo forest composition. Subtle breathing and gentle background leaf motion, soft overcast light, locked camera, no walking away, no extra limbs, no transformation, no cuts or text.
Grok Imagine Video Image to Video API
xai/grok-imagine-video/image-to-videoGrok Imagine Video Image to Video 将静态图转为短片,结合文字引导的主体动作与运镜。参考图建立场景外观,动作提示词引导画面在时长内展开,让素材成为动画起点。
获取 API Key
继续使用
示例
REST API
快速开始
提交请求并保存 task_id,在任务完成后读取生成文件。
连接 Vidgo API
在服务端保存 API Key,通过 Authorization: Bearer VIDGO_API_KEY 发送。
- 端点
- POST
https://api.vidgo.ai/api/generate/submit - 认证
- Authorization: Bearer VIDGO_API_KEY
提交生成任务
在请求顶层设置 model 和 callback_url,将下列字段放入 input。
curl --request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-imagine-video/image-to-video",
"input": {
"prompt": "杯子保持居中,蒸汽缓缓上升,镜头逐渐靠近。",
"duration": 6,
"mode": "normal",
"image_urls": [
"https://example.com/reference.png"
]
}
}'获取结果
状态为 not_started 或 running 时,每 2–5 秒查询一次;finished 和 failed 为终态。
查询状态
GET https://api.vidgo.ai/api/generate/status/{task_id}状态为 not_started 或 running 时,每 2–5 秒查询一次;finished 和 failed 为终态。
not_startedrunningfinishedfailed{
"code": 200,
"data": {
"task_id": "example-task-id",
"status": "not_started",
"created_time": "2026-09-27T10:00:00Z"
}
}{
"code": 200,
"data": {
"task_id": "example-task-id",
"status": "finished",
"created_time": "2026-09-27T10:00:00Z",
"files": [
{
"file_url": "https://example.com/result.mp4",
"file_type": "video"
}
]
}
}完整轮询示例
提交请求并保存 task_id,在任务完成后读取生成文件。
set -euo pipefail
: "${VIDGO_API_KEY:?Set VIDGO_API_KEY in your environment}"
REQUEST_BODY=$(cat <<'JSON'
{
"model": "xai/grok-imagine-video/image-to-video",
"input": {
"prompt": "杯子保持居中,蒸汽缓缓上升,镜头逐渐靠近。",
"duration": 6,
"mode": "normal",
"image_urls": [
"https://example.com/reference.png"
]
}
}
JSON
)
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
--request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data "$REQUEST_BODY")
TASK_ID=$(printf '%s' "$SUBMIT_RESPONSE" | jq -r '.data.task_id // .task_id // empty')
if [ -z "$TASK_ID" ]; then
printf 'Submit response did not include task_id:
%s
' "$SUBMIT_RESPONSE" >&2
exit 1
fi
while true; do
STATUS_RESPONSE=$(curl --silent --show-error --fail-with-body \
--url "https://api.vidgo.ai/api/generate/status/$TASK_ID" \
--header "Authorization: Bearer $VIDGO_API_KEY")
STATUS=$(printf '%s' "$STATUS_RESPONSE" | jq -r '.data.status // .status // empty')
case "$STATUS" in
finished)
printf '%s' "$STATUS_RESPONSE" | jq -r '(.data.files // .files // [])[]?.file_url'
break
;;
failed)
printf '%s' "$STATUS_RESPONSE" | jq -r '.data.error_message // .error_message // "Generation failed"' >&2
exit 1
;;
not_started|running)
sleep 2
;;
*)
printf 'Unexpected task status: %s
' "$STATUS" >&2
exit 1
;;
esac
done请求参数
在请求顶层设置 model 和 callback_url,将下列字段放入 input。
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| input.prompt | string | 是 | – | 描述场景与动作,长度为 1–5,000 个字符。 |
| input.image_urls | string[] | 是 | – | 提供包含一个公开 HTTP(S) 图片 URL 的数组。 |
| input.mode | string | 否 | – | 生成风格,可选 fun、normal、spicy。 |
| input.duration | integer | 否 | 6 | 视频时长,单位为秒,可选整数 6、10;默认 6。 |
响应字段
提交响应返回 task_id,状态响应返回生成文件或任务错误。
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 业务返回码,0 或 200 表示成功。 |
| data.task_id | string | 用于查询状态的任务标识。 |
| data.status | string | not_started, running, finished, failed |
| data.created_time | string | 任务创建时间。 |
| data.files[].file_url | string | 生成文件的 URL。 |
| data.files[].file_type | string | video |
| data.error_message | string | null | 任务失败原因。 |
任务生命周期
状态为 not_started 或 running 时,每 2–5 秒查询一次;finished 和 failed 为终态。
not_started已接收,等待执行。
running正在生成。
finished读取生成文件。
failed读取 error_message 并结束轮询。
轮询与错误处理
- 轮询状态为 not_started 或 running 时,每 2–5 秒查询一次;finished 和 failed 为终态。
- 重试状态查询遇到 429 或临时服务错误时延长间隔,再查询同一 task_id。
- 回调在请求顶层提供公开 callback_url,接收任务完成通知。
模型规格
| 规格 | 取值 | 说明 |
|---|---|---|
| 输入 | Prompt + Image | 描述场景与动作,长度为 1–5,000 个字符。 |
| 输出 | video | 6 秒或 10 秒视频。 |
| mode | fun · normal · spicy | 生成风格,可选 fun、normal、spicy。 |
| duration | 6 · 10 | 视频时长,单位为秒,可选整数 6、10;默认 6。 |
相关模型
Grok Imagine Video Image to Video API 常见问题
Grok Imagine Video Image to Video API 是什么?
Grok Imagine Video Image to Video 是 xAI 用于通过文字指令为静态图制作动画的模型。它生成 6 秒或 10 秒短片,结合动作提示词与可选生成模式。参考图建立主体和场景,提示词则引导从这一视觉起点增加的动作与镜头运动。你可以通过 API 调用,也可以在“体验”标签中在线试用。
Grok Imagine Video Image to Video 如何准备参考图?
选择一张主体清晰、环境容易辨认的图片,在 image_urls 中提供该图的单个 URL,或在体验区上传图片,再描述希望从画面中展开的运动。
Grok Imagine Video Image to Video 如何描述画面运动?
点明需要运动的主体,并单独说明镜头的作用。例如:“杯子保持居中,蒸汽缓缓上升,镜头逐渐靠近。”这样可以将原图外观与需要增加的运动区分开。
Grok Imagine Video Image to Video 可以制作产品图片动画吗?
可以。产品图提供参考场景,提示词描述镜头运动或周围环境的变化。明确点名产品及预期动作,让短片围绕一个清晰的展示重点展开。
Grok Imagine Video Image to Video 的短片有多长?
通过 duration 选择 6 秒或 10 秒,省略时默认为 6 秒。可根据希望从参考图中展开的动作过程选择长度。
Grok Imagine Video Image to Video 可以使用哪些模式?
mode 可选 fun、normal、spicy。比较不同模式时保持参考图与动作提示词一致,以观察它们对同一场景的处理。
何时应选择 Grok Imagine Video Image to Video 而非 Grok Imagine Video Text to Video?
已有照片或插画,并希望由它建立场景时,选择 Grok Imagine Video Image to Video;以文字描述建立场景时,选择 Grok Imagine Video Text to Video。
Grok Imagine Video Image to Video 的图片动画如何计费?
6 秒视频每条为 30 credits,即 $0.150;10 秒视频每条为 40 credits,即 $0.200。每次生成按所选时长对应的单条价格计费。















