Skip to main content
Orux AIOruxAI

AI 视频生成:从提示词到 MP4

通过异步 API 提交视频生成任务、查询状态并读取生成结果。

ai 视频生成 api

当前可用模型

查看完整目录

你将实现什么

提交视频生成任务、保存任务 ID、轮询任务状态并读取完成结果。提示词、图片、时长和分辨率等输入字段因模型而异。

1. 选择模型

打开视频模型目录,在模型详情页查看输入结构、输出设置和当前价格,再到Keys创建 API Key。

2. 提交生成任务

const headers = {
  Authorization: "Bearer " + process.env.ORUX_API_KEY,
  "Content-Type": "application/json",
}

const response = await fetch("https://orux.top/api/v1/tasks", {
  method: "POST",
  headers,
  body: JSON.stringify({
    model: "YOUR_VIDEO_MODEL_ALIAS",
    input: { prompt: "一只纸船在雨天的街边水沟里漂流" },
  }),
})

if (!response.ok) throw new Error(await response.text())
const { task_id } = await response.json()
Swipe horizontally to view the full content

请求字段请以所选模型详情页为准。

3. 轮询并读取结果

let task
do {
  await new Promise((resolve) => setTimeout(resolve, 10000))
  task = await fetch("https://orux.top/api/v1/tasks/" + task_id, { headers }).then((r) => r.json())
} while (task.status === "QUEUED" || task.status === "RUNNING")

if (task.status !== "SUCCESS") throw new Error(task.error?.message ?? task.status)
console.log(task.result)
Swipe horizontally to view the full content

持久化任务 ID,进程重启后可以接着轮询,避免重复提交相同请求。失败或过期的任务不会扣费。

成本控制

  • 时长等输出设置可能影响总费用;提交前先查看所选模型的当前价格和可选值。
  • 用户确认任务前,先向其展示预估费用。

下一步

在视频模型目录中对比模型,查看价格页和API 快速开始。

← 全部应用场景