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

# Grok Imagine 1.5 Preview

> 使用 `POST /v1/videos` 调用 `grok-imagine-video-1.5-preview` 提交 JSON 视频生成任务。

# Grok Imagine 1.5 Preview

`grok-imagine-video-1.5-preview` 是 Grok Imagine 线路的 1.5 Preview 模型。本模型使用 `application/json` 请求体，参考图通过顶层 `image` 字段传递。

* 接口路径是 `POST /v1/videos`。
* 请求格式是 `application/json`。
* 文生视频只需要 `model`、`prompt`、`seconds`、`aspect_ratio`、`resolution`。
* 图生视频使用单张 `image`。
* 当前 1.5 规范按单张参考图请求，使用 `image` 字段即可。
* `resolution` 支持 `480P`、`720P` 和 `1080P`。
* `prompt` 最多支持 `4096` 个字符；过长或过密的提示词可能导致上游没有返回任务 ID。

## 方法与路径

```http theme={null}
POST /v1/videos
```

<RequestExample>
  ```bash 文生视频 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "grok-imagine-video-1.5-preview",
      "prompt": "雨夜霓虹街头，一辆复古跑车驶过湿润路面",
      "seconds": "4",
      "aspect_ratio": "16:9",
      "resolution": "1080P"
    }'
  ```

  ```bash 单图生视频 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "grok-imagine-video-1.5-preview",
      "prompt": "让参考图中的人物缓慢转身，背景光线自然流动",
      "seconds": "4",
      "aspect_ratio": "16:9",
      "resolution": "1080P",
      "image": "https://example.com/reference.png"
    }'
  ```

  ```python Python theme={null}
  import requests

  resp = requests.post(
      "https://magic666.top/v1/videos",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      json={
          "model": "grok-imagine-video-1.5-preview",
          "prompt": "让参考图中的人物向镜头微笑，头发和衣摆轻微摆动",
          "seconds": "4",
          "aspect_ratio": "16:9",
          "resolution": "1080P",
          "image": "https://example.com/reference.png",
      },
      timeout=60,
  )

  print(resp.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://magic666.top/v1/videos", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "grok-imagine-video-1.5-preview",
      prompt: "让参考图中的人物向镜头微笑，头发和衣摆轻微摆动",
      seconds: "4",
      aspect_ratio: "16:9",
      resolution: "1080P",
      image: "https://example.com/reference.png",
    }),
  });

  console.log(await response.json());
  ```
</RequestExample>

## 响应示例

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "task_abc123",
    "task_id": "task_abc123",
    "object": "video",
    "model": "grok-imagine-video-1.5-preview",
    "status": "queued",
    "progress": 0,
    "created_at": 1735689600,
    "seconds": "4",
    "size": "1920x1080"
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "message": "prompt is required",
      "type": "new_api_error",
      "param": "prompt",
      "code": "invalid_request"
    }
  }
  ```
</ResponseExample>

## 认证

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Body

<ParamField body="model" type="string" required>
  固定传 `grok-imagine-video-1.5-preview`。
</ParamField>

<ParamField body="prompt" type="string" required>
  视频生成提示词。最多 `4096` 个字符。
</ParamField>

<ParamField body="seconds" type="string">
  目标秒数。建议按字符串传入，例如 `"4"`。
</ParamField>

<ParamField body="aspect_ratio" type="string">
  宽高比。支持常见预设 `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`，也支持 `数字:数字` 的自定义比例。
</ParamField>

<ParamField body="resolution" type="string">
  输出清晰度。支持 `480P`、`720P`、`1080P`。
</ParamField>

<ParamField body="image" type="string">
  单张参考图 URL。请传入上游可访问的图片地址，例如 `https://example.com/reference.png`。
</ParamField>

## 请求构造规则

| 场景    | 字段组合                                                   |
| ----- | ------------------------------------------------------ |
| 文生视频  | `model`、`prompt`、`seconds`、`aspect_ratio`、`resolution` |
| 单图生视频 | 在文生字段基础上追加 `image`                                     |

`image` 应传入上游可访问的图片 URL，不要把本地文件路径直接作为 JSON 字段提交。

## Response

<ResponseField name="id" type="string">
  任务 ID。后续用 `GET /v1/videos/{id}` 查询结果。
</ResponseField>

<ResponseField name="task_id" type="string">
  任务 ID。部分响应会同时返回 `id` 与 `task_id`，两者可指向同一个任务。
</ResponseField>

<ResponseField name="object" type="string">
  对象类型，通常为 `video`。
</ResponseField>

<ResponseField name="model" type="string">
  任务对应的模型名。该字段用于展示和排查，不应用作任务 ID。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态，常见值有 `queued`、`processing`、`completed`、`failed`、`cancelled`。
</ResponseField>

<ResponseField name="progress" type="integer">
  任务进度百分比。
</ResponseField>

<ResponseField name="video_url" type="string">
  任务完成后的视频地址。也可以使用 `GET /v1/videos/{task_id}/content` 下载结果。
</ResponseField>

## 错误处理建议

如果创建任务返回 `5xx`，且错误信息包含 `task_id is empty`，通常表示上游没有接受本次任务。常见触发原因包括提示词过长、分镜描述过密或上游临时拒绝创建任务。建议客户端记录当前 `prompt` 的字符数与字节数，并在重试前压缩提示词。

## 相关接口

* [Grok 视频概览](./overview)
* [Grok Imagine Video](./grok-imagine-video)
* [Grok 任务查询](./query)
