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

# Luma

> 使用 Luma Dream Machine API 生成视频

> 更新日期：2026-06-06

# Luma

Luma Dream Machine 提供高质量的视频生成能力。官方文档：[docs.lumalabs.ai](https://docs.lumalabs.ai/docs/video-generation)

## 创建视频

```
POST /luma/generations
```

### 请求参数

| 参数              | 类型      | 必填 | 说明                        |
| --------------- | ------- | -- | ------------------------- |
| `user_prompt`   | string  | 是  | 视频描述提示词                   |
| `model_name`    | string  | 否  | 模型名称：`ray-v1`、`ray-v2`    |
| `duration`      | string  | 否  | 视频时长（秒）                   |
| `resolution`    | string  | 否  | 分辨率：`540p`、`720p`、`1080p` |
| `expand_prompt` | boolean | 否  | 是否自动扩展提示词                 |
| `image_url`     | string  | 否  | 首帧参考图片 URL                |
| `image_end_url` | string  | 否  | 尾帧参考图片 URL                |

### 请求示例

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.crazyrouter.com/luma/generations \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -d '{
      "user_prompt": "A drone shot flying over a tropical island with crystal clear water",
      "model_name": "ray-v2",
      "duration": "5",
      "resolution": "720p",
      "expand_prompt": true
    }'
  ```

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

  response = requests.post(
      "https://api.crazyrouter.com/luma/generations",
      headers={
          "Content-Type": "application/json",
          "Authorization": "Bearer YOUR_API_KEY"
      },
      json={
          "user_prompt": "A drone shot flying over a tropical island",
          "model_name": "ray-v2",
          "duration": "5",
          "resolution": "720p"
      }
  )

  print(response.json())
  ```
</CodeGroup>

### 响应示例

```json theme={null}
{
  "id": "luma_gen_abc123",
  "state": "queued",
  "created_at": "2024-03-01T12:00:00Z"
}
```

***

## 图生视频

传入 `image_url` 作为首帧：

```json theme={null}
{
  "user_prompt": "The person in the image starts walking forward",
  "model_name": "ray-v2",
  "image_url": "https://example.com/portrait.jpg"
}
```

首尾帧模式：

```json theme={null}
{
  "user_prompt": "Smooth transition between two scenes",
  "model_name": "ray-v2",
  "image_url": "https://example.com/start.jpg",
  "image_end_url": "https://example.com/end.jpg"
}
```

***

## 查询任务

```
GET /luma/generations/{task_id}
```

```bash cURL theme={null}
curl https://api.crazyrouter.com/luma/generations/luma_gen_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### 响应示例

```json theme={null}
{
  "id": "luma_gen_abc123",
  "state": "completed",
  "created_at": "2024-03-01T12:00:00Z",
  "video": {
    "url": "https://storage.cdn-luma.com/...",
    "download_url": "https://storage.cdn-luma.com/..."
  }
}
```

***

## 延长视频

```
POST /luma/generations/{task_id}/extend
```

延长已完成的视频。

```bash cURL theme={null}
curl -X POST https://api.crazyrouter.com/luma/generations/luma_gen_abc123/extend \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "user_prompt": "Continue the drone shot, camera pans to reveal a beach resort"
  }'
```

### 任务状态

| 状态          | 说明  |
| ----------- | --- |
| `queued`    | 排队中 |
| `dreaming`  | 生成中 |
| `completed` | 已完成 |
| `failed`    | 失败  |
