> ## 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-Hant/models/grok-imagine/video/overview#計價)。
</Info>

## 下一步

<CardGroup cols={2}>
  <Card title="概覽" icon="film" href="/zh-Hant/models/grok-imagine/video/overview">
    三種模式、時長與解析度檔位、參考圖、音色與計價。
  </Card>

  <Card title="非同步任務 API" icon="clock" href="/zh-Hant/api/async-tasks">
    輪詢閉環、回撥，以及完整錯誤表。
  </Card>
</CardGroup>
