> ## Documentation Index
> Fetch the complete documentation index at: https://docs.widerouter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Playground

> 直接在页面里提交一个真实的 Grok Imagine 视频任务，再用返回的任务 ID 轮询结果。

填入你的 API Key 和提示词，然后发送。这里打的是线上接口，和你代码里调的是同一个，
也是够到视频模型的唯一方式。

<Warning>
  **从这个页面发出的请求是真实的，会计入你的 Key。**
  视频按秒计价：一秒的 `480p` 约 \$0.05 到 \$0.08，而十五秒的 `1080p` 要几美元。
  先从短的试。
</Warning>

## 参数

<ParamField body="model" type="string" required>
  用哪个模型。接受 `grok-imagine-video` 或 `grok-imagine-video-1.5`，精确匹配。
  只有 `grok-imagine-video` 能编辑和延长现成片段，
  只有 `grok-imagine-video-1.5` 能到 `1080p` 和用预设音色。
</ParamField>

<ParamField body="input" type="object" required>
  生成参数。下面没列出的键一律以 `invalid_params` 拒绝。

  <Expandable title="input">
    <ParamField body="input.prompt" type="string" required>
      要生成什么，或者编辑时要改成什么样。
    </ParamField>

    <ParamField body="input.mode" type="string" default="generate">
      `generate`、`edit` 或 `extend`。后两个都需要 `input.video`，
      而且只在 `grok-imagine-video` 上可用。
    </ParamField>

    <ParamField body="input.duration" type="integer">
      时长秒数，1 到 15。`extend` 模式下上游把范围收窄到 2 到 10，
      而且这条是在任务入队之后才判，不是提交时。`edit` 不用它，输出跟随源片长度。
    </ParamField>

    <ParamField body="input.resolution" type="string" default="480p">
      `480p`、`720p`，`1080p` 仅 `grok-imagine-video-1.5`。
      `edit` 模式下会被拒；用了 `input.reference_images` 则封顶 `720p`。
    </ParamField>

    <ParamField body="input.aspect_ratio" type="string" default="16:9">
      取 `1:1` `16:9` `9:16` `4:3` `3:4` `3:2` `2:3` 之一。
      这里没有 `auto`，和图像模型不同。
    </ParamField>

    <ParamField body="input.images" type="string[]">
      恰好一张图，作为片子的**首帧**。`https` URL 或 base64 data URI。
      不能与 `input.reference_images` 同时给。
    </ParamField>

    <ParamField body="input.video" type="string">
      `edit` 与 `extend` 的源片。`https` URL 或 base64 视频 data URI，
      且至少 2 秒长。按秒作为输入计费。
    </ParamField>

    <ParamField body="input.reference_images" type="string[]">
      最多 3 张，模型从中取风格与主体。会把输出封顶在 `720p`。
      不能与 `input.images` 同时给。
    </ParamField>

    <ParamField body="input.voice_ids" type="string[]">
      最多 3 个预设音色，仅 `grok-imagine-video-1.5`。
      取值在提交时不校验，所以名字写错要等任务失败才知道。
    </ParamField>

    <ParamField body="input.generate_audio" type="boolean" default="true">
      传 `false` 出静音片段。不影响价格。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="callback_url" type="string">
  任务结束后把结果 POST 到这个地址，省掉轮询。
  视频要 20 到 50 秒，回调值得接一下。
</ParamField>

## 会返回什么

提交立刻返回，一秒都用不到。片子**不在**这个响应里——生成是在后台进行的。

| 字段           | 类型      | 说明               |
| ------------ | ------- | ---------------- |
| `id`         | string  | 任务 ID，后面每一步都要用它。 |
| `status`     | string  | 新任务是 `queued`。   |
| `created_at` | integer | Unix 秒，UTC。      |

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "task_IIISyUlKs0fJDptkSCLbcJvXWZLpECKM",
    "status": "queued",
    "created_at": 1788189046
  }
  ```
</ResponseExample>

## 然后轮询取结果

这个 Playground 只覆盖创建调用。拿上面响应里的 `id` 去读任务，
直到 `status` 变成 `completed` 或 `failed`——按长度和分辨率不同，20 到 50 秒。

```bash theme={null}
curl https://api.widerouter.com/v1/task/$TASK_ID \
  -H "Authorization: Bearer $WIDEROUTER_API_KEY"
```

完成的任务带一个 `outputs` 数组，里面是一个 MP4：

```json theme={null}
{
  "id": "task_IIISyUlKs0fJDptkSCLbcJvXWZLpECKM",
  "model": "grok-imagine-video",
  "status": "completed",
  "created_at": 1788189046,
  "completed_at": 1788189065,
  "expires_at": 1788275465,
  "outputs": ["https://r2cdn.agisuitepro.com/o/2026/08/31/task_IIISyUlKs0fJDptkSCLbcJvXWZLpECKM_0.mp4"],
  "counts": { "requested": 1, "succeeded": 1, "failed": 0 },
  "usage": { "cost_in_usd_ticks": 500000000 }
}
```

文件以 `video/mp4` 交付，可以内联播放。时长比你要的多约 0.04 秒。

<Info>
  产物 URL 不鉴权，并且在任务完成 24 小时后失效。
  `usage.cost_in_usd_ticks` 是**原价**，实际扣费是它乘以你所在分组的倍率——
  见[计价](/zh/models/grok-imagine/video/overview#计价)。
</Info>

## 下一步

<CardGroup cols={2}>
  <Card title="概览" icon="film" href="/zh/models/grok-imagine/video/overview">
    三种模式、时长与分辨率档位、参考图、音色与计价。
  </Card>

  <Card title="异步任务 API" icon="clock" href="/zh/api/async-tasks">
    轮询闭环、回调，以及完整错误表。
  </Card>
</CardGroup>
