按能力

视频

视频都按任务处理:提交后查结果或等回调。时长越长、清晰度越高越贵。

#1. 选模型

grok-imagine-video$0.044/秒 起限制和状态

这个能力有 14 个在线模型,切换后下面的代码会跟着变。

#2. 复制请求

把 YOUR_API_KEY 换成你的密钥再运行。显示的选项都是这个模型支持的。

POSThttps://www.aisplice.store/v1/videosBearer API key异步任务

选项这里只展示当前模型已公开支持的选项。

# Requires curl and jq
API_KEY="${API_KEY:-YOUR_API_KEY}"

# 1. Submit once
SUBMITTED=$(curl --fail-with-body -sS https://www.aisplice.store/v1/videos \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: model-docs-$(date +%s)-$$" \\
  -d '{
  "model": "Grok Imagine Video",
  "prompt": "A cinematic scene with careful composition",
  "duration": 8,
  "resolution": "480p",
  "size": "auto",
  "nsfw_check": false
}')
TASK_ID=$(printf '%s' "$SUBMITTED" | jq -r '.task_id // .id // empty')
if [ -z "$TASK_ID" ]; then
  printf '%s\n' "$SUBMITTED" >&2
  exit 1
fi
echo "task_id=$TASK_ID"

# 2. Poll until terminal
while true; do
  STATUS_JSON=$(curl --fail-with-body -sS \
    "https://www.aisplice.store/v1/videos/$TASK_ID" \
    -H "Authorization: Bearer $API_KEY")
  STATUS=$(printf '%s' "$STATUS_JSON" | jq -r '.status // empty' | tr '[:upper:]' '[:lower:]')
  echo "status=$STATUS"
  case "$STATUS" in
    completed|succeeded|success) break ;;
    failed|failure|cancelled|canceled)
      printf '%s\n' "$STATUS_JSON" | jq .
      exit 1
      ;;
  esac
  sleep 5
done

# 3. Fetch the final result
curl --fail-with-body -sS \
  "https://www.aisplice.store/v1/videos/$TASK_ID/content" \
  -H "Authorization: Bearer $API_KEY" | jq .

该模型要求使用公网媒体地址。 先上传本地文件,再把 public_url 放入模型请求;避免发送大体积 Base64 请求体。

查看上传指南

全部参数

这个模型支持的全部字段和可选值。

model
string必填

本次请求使用的精确模型标识。

grok-imagine-video
prompt
string必填

What to make; for an edit, what to change and what must stay the same. Up to 8000 characters.

duration
integer可选

Output seconds, 1 to 15; at most 10 with 2 or more pictures. Not used for an edit: the output is as long as the source video.

resolution
string可选

480p ($0.044 per second) or 720p ($0.0616 per second). Not used for an edit: the output keeps the source video's resolution, up to 720p.

480p720p
size
string可选

Aspect ratio. With one picture the clip takes the picture's shape. Not used for an edit: the output keeps the source video's.

auto16:99:161:14:33:43:22:3
images
string[]可选

Up to 7 public picture URLs, $0.00176 each. One picture is the first frame; 2 to 7 are references for a clip of at most 10 seconds. Not together with videos.

videos
string[]可选

Edit a video: one public mp4 URL of at most 8.7 seconds. You get the same clip back with the change the prompt asks for, at $0.0704 per second of the source video. Not together with images.

响应流程

查看任务状态、终态和结果响应示例。

提交
{
  "id": "task_xxx",
  "task_id": "task_xxx",
  "object": "video",
  "model": "Grok Imagine Video",
  "status": "queued"
}

等待中

queued · submitted · in_progress · processing

成功

completed · succeeded · success

失败

failed · failure · cancelled · canceled

全部字段:见 API 参考里的 /v1/videos →

#3. 拿到结果

提交后马上返回 task_id。每隔几秒查一次,直到 status 变成 completed;也可以传 webhook_url,完成后我们回调你。

GET https://www.aisplice.store/v1/videos/{task_id}

GET https://www.aisplice.store/v1/videos/{task_id}/content

时长和分辨率决定价格档位。运行中的任务可以取消,见 API 参考。

成功才扣费

失败或取消的任务自动退款,请求日志里能看到每个任务的最终费用。

状态值和查询方式 →改用回调,不用反复查询 →

#出错了怎么办

  • 400 并提示某个字段:这个模型不支持该选项,用第 2 步列出的取值。
  • 参考图或视频被拒:必须是模型能下载的公开地址。
  • 内容被模型拒绝:换个说法重写提示词;被拒绝的请求不扣费。
  • 402:余额不够这次请求,到「钱包」充值后重试。
  • 429:请求太快,按 Retry-After 给的秒数等一下再试。
  • 503 model_not_found:模型名写错了或模型暂时下线,从第 1 步重新选一个。

查其他报错 →

#首尾帧、参考图和参考视频

支持的模型会在第 2 步显示这些字段:首帧、尾帧、参考图或参考视频。填公开地址,本地文件先上传。

有的模型拿到视频是去改它,而不是当参考:grok-imagine-video 会把同一段视频按你的要求改好返回。第 2 步的参数说明里会写清楚。

怎么上传本地文件 →

做进你的产品里先给你的用户放哪些选项,哪些以后再加。
先给用户放哪些选项先放提示词和一个影响价格的选项,基础流程跑通后再加其他的。+

创作意图

像 prompt 这样的字段应该出现在 UI 中,因为用户能直接理解它会改变什么结果。

成本倍率项

像 duration、resolution、size、count 这样的字段,只有在价格已经能被清楚解释时才应引入。

模式切换项

像 image、mask 或 continuation ID 这类字段会改变整个工作流本身,只应出现在专门模式中。

系统接线项

像 webhook_secret 这样的字段是给集成方用的,不是给日常创作者用的,所以应从默认 UI 中移除。

  • prompt
    何时暴露
    始终暴露。它定义场景内容或运动方向。
    推荐默认值
    在 UI 中设为必填。
    为什么重要
    没有它,用户就无法控制视频意图。
  • image / images
    何时暴露
    仅在参考素材驱动或图生视频产品中暴露。
    推荐默认值
    在纯 prompt 流程中隐藏。
    为什么重要
    它会改变创作模式,因此应是明确的产品决策,而不是默认暴露。
  • duration
    何时暴露
    只有在基础异步流程稳定、价格展示清晰后再暴露。
    推荐默认值
    从模型支持的最短时长起步。
    为什么重要
    它是视频生成里最主要的成本和延迟放大项之一。
  • resolution
    何时暴露
    只有当用户明确会比较 720p、1080p 或 4K 输出时再暴露。
    推荐默认值
    先在服务端固定一个推荐分辨率。
    为什么重要
    更高分辨率会提高成本、排队时间和失败敏感度。
  • webhook_url / webhook_secret
    何时暴露
    只给后端集成方使用,不给普通终端用户暴露。
    推荐默认值
    在 UI 产品中优先采用轮询。
    为什么重要
    它们解决的是系统集成问题,不是终端用户创作问题,所以不应进入面向用户的控制区。
recommended-rollout.txt
Phase 1
- prompt
- one size or one duration default
- submit -> poll -> content

Phase 2
- one quality or resolution selector
- clear pricing hint

Phase 3
- advanced controls such as reference media, continuation, webhook, or vendor-specific tuning

结果只保留一个真源

任务完成后,让应用统一围绕 /content 返回的平台 URL 运作。这样既能隐藏供应商细节,也能让历史回放更稳定。

还是没解决?

把请求 ID 或报错信息发给我们,我们来查。