> ## 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。**
  一张图按模型和档位不同约 \$0.02 到 \$0.08。这里没有沙箱，也没有 mock。
</Warning>

## 参数

<ParamField body="model" type="string" required>
  用哪个模型。接受 `grok-imagine-image`、`grok-imagine-image-2.0` 或
  `grok-imagine-image-quality`，精确匹配，没有别名。
</ParamField>

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

  <Expandable title="input">
    <ParamField body="input.prompt" type="string" required>
      要生成什么。不能为空，最长 32000 字节。
    </ParamField>

    <ParamField body="input.resolution" type="string" default="1k">
      `1k` 或 `2k`，小写——大写会被拒。
    </ParamField>

    <ParamField body="input.quality" type="string" default="low">
      `low` 或 `medium`。**只有 `grok-imagine-image-2.0` 接受**，
      另外两个模型上它会被当成未知字段。
    </ParamField>

    <ParamField body="input.aspect_ratio" type="string">
      取 `auto` `1:1` `16:9` `9:16` `4:3` `3:4` `3:2` `2:3` `2:1` `1:2`
      `19.5:9` `9:19.5` `20:9` `9:20` `21:9` `5:2` 之一。
      不传则用该模型自己的默认画幅。
    </ParamField>

    <ParamField body="input.n" type="integer" default="1">
      出几张图，1 到 4。每一张在 `outputs` 里是独立一项，也各自计费。
    </ParamField>

    <ParamField body="input.images" type="string[]">
      用来编辑或合成的参考图，最多 3 张。每一项是 `https` URL 或 base64 data URI，
      每张另加约 \$0.01。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="callback_url" type="string">
  任务结束后把结果 POST 到这个地址，省掉轮询。必须是 `https`，
  其他形式在提交时就会被拒。
</ParamField>

## 会返回什么

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

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

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

## 然后轮询取结果

这个 Playground 只覆盖创建调用。拿上面响应里的 `id` 去读任务，
直到 `status` 变成 `completed` 或 `failed`——大约 7 到 10 秒。

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

完成的任务带一个 `outputs` 数组：

```json theme={null}
{
  "id": "task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF",
  "model": "grok-imagine-image",
  "status": "completed",
  "created_at": 1788189088,
  "completed_at": 1788189094,
  "expires_at": 1788275494,
  "outputs": ["https://r2cdn.agisuitepro.com/o/2026/08/31/task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF_0.jpg"],
  "counts": { "requested": 1, "succeeded": 1, "failed": 0 },
  "usage": { "cost_in_usd_ticks": 200000000 }
}
```

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

## 下一步

<CardGroup cols={2}>
  <Card title="概览" icon="image" href="/zh/models/grok-imagine/image/overview">
    全部参数、分辨率与质量的组合，以及实测时延。
  </Card>

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