promptstring必填
Text prompt describing the video to generate. Use @Image1, @Image2, etc. to reference specific images from reference_image_urls in order.
xai/grok-imagine-video/reference-to-videoGrok Imagine Video is xAI's image-to-video AI model. Bring static images to life with fluid animation, consistent character motion, and professional-grade video output.
试用该模型
PNG, JPEG, WebP, or GIF · 20 MiB maximum each · up to 7
下一步想做什么?
选择一个示例,将其输入和结果加载到 playground 中。
{
"prompt": "A @Image1 running through a sunlit meadow, cinematic slow motion",
"reference_image_urls": [
"https://static.sandbase.ai/examples/1d487450-78ff-4d5a-87b2-0abdacea87d7/input/1bb4adf0-cb56-4abf-8133-5b627a7fd3ef.png"
]
}Grok Imagine Video reference-to-video: up to 7 reference images keep characters and objects consistent in a 1–10 second clip.
| Field | Type | Default | Notes |
|---|---|---|---|
prompt | string, required | — | Up to 4,096 characters. |
aspect_ratio | 16:9 / 4:3 / 3:2 / 1:1 / 2:3 / 3:4 / 9:16 | 16:9 | Output frame shape. |
resolution | 480p / 720p | 720p | Sets the per-second rate. |
duration | integer 1–10 | 8 | Output length in seconds. |
reference_image_urls | image URL[] (≤7), required | — | Reference images, up to 7. |
$0.07 per output second at 720p and $0.05 at 480p, plus $0.002 per request.
| Output | 480p | 720p |
|---|---|---|
| 6s | $0.302 | $0.422 |
| 8s (default) | $0.402 | $0.562 |
| 10s | $0.502 | $0.702 |
Failed runs are not charged.
Other Grok Imagine Video endpoints: xai/grok-imagine-video/text-to-video, xai/grok-imagine-video/image-to-video, xai/grok-imagine-video/video-edit, xai/grok-imagine-video/video-extend, xai/grok-imagine-video/1.5/text-to-video (1.5, newer).
开始构建
通过 SandBase Unified Run API 提交此模型。
# The quoted heredoc keeps Unicode and shell metacharacters unchanged.
result=$(curl --fail-with-body --silent \
-X POST "https://api.sandbase.ai/v1/run" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'SANDBASE_JSON'
{
"model": "xai/grok-imagine-video/reference-to-video",
"prompt": "A @Image1 running through a sunlit meadow, cinematic slow motion",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9",
"reference_image_urls": [
"https://static.sandbase.ai/examples/xai/grok-imagine-video/reference-to-video/input_reference_image_urls_0.png"
]
}
SANDBASE_JSON
)
run_id=$(printf '%s' "$result" | jq -r .id)
for attempt in $(seq 1 120); do
status=$(printf '%s' "$result" | jq -r .status)
case "$status" in completed|failed|timeout) break ;; esac
sleep 2
result=$(curl --fail-with-body --silent \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
"https://api.sandbase.ai/v1/run/$run_id")
done
status=$(printf '%s' "$result" | jq -r .status)
[ "$status" = completed ] || { echo "Generation ended: $status" >&2; exit 1; }
printf '%s\n' "$result"创建一个 SandBase API 密钥,并将其设置到服务器环境中。所有请求都使用 Bearer 身份验证。
export SANDBASE_API_KEY="YOUR_API_KEY"请将密钥保存在服务器端。不要在浏览器代码中暴露它,也不要提交到仓库。
使用此模型 ID 及其输入向 /v1/run 发送 POST 请求。上方的请求示例包含提交和轮询。
使用返回的运行 ID 轮询,直到状态为 completed、failed 或 timeout。仅在 completed 后读取输出。
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"在模型的 image、video 或 audio 字段中传入一个可公开访问的文件 URL。支持的格式和限制显示在每个 Playground 输入项旁边。
在 Playground 中支持的图片字段上使用上传或替换控件。视频 URL 字段接受托管的 driving video;这并不表示支持视频上传。
promptstring必填Text prompt describing the video to generate. Use @Image1, @Image2, etc. to reference specific images from reference_image_urls in order.
durationintegerVideo duration in seconds.
默认值:8
最小值:1
最大值:10
resolutionstringResolution of the output video.
默认值:"720p"
可选值:"480p", "720p"
aspect_ratiostringThe aspect ratio of the generated image.
默认值:"16:9"
可选值:"16:9", "4:3", "3:2", "1:1", "2:3", "3:4", "9:16"
reference_image_urlsarray必填One or more reference image URLs to guide the video generation as style and content references. Reference in prompt as @Image1, @Image2, etc. Maximum 7 images.
{
"model": "xai/grok-imagine-video/reference-to-video",
"prompt": "A @Image1 running through a sunlit meadow, cinematic slow motion",
"duration": 8,
"resolution": "720p",
"aspect_ratio": "16:9",
"reference_image_urls": [
"https://static.sandbase.ai/examples/xai/grok-imagine-video/reference-to-video/input_reference_image_urls_0.png"
]
}已完成的运行会在输出中展示结果。以下内容是该模型保存的示例,而不是新的生成结果。
[
{
"poster": "https://static.sandbase.ai/examples/posters/008e2a60f15ea4813552.jpg",
"source": "xAI schema mirror",
"source_url": "https://docs.x.ai/",
"url": "https://static.sandbase.ai/examples/1d487450-78ff-4d5a-87b2-0abdacea87d7/output/a93d9668-7b65-41f8-9c74-3792eb4dc43e.mp4"
}
]