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

# 首尾帧生视频

> 给定首帧与尾帧，生成两图之间的过渡视频。

两张图片分别传 `role: first_frame` 与 `role: last_frame`。两张图的构图、主体越接近，过渡越自然；输出比例跟随输入图片，`ratio` 不生效。

> [!TIP]
>
> 想直接调试？打开 [创建视频生成任务](https://docs.dreamto.ai/api-reference/seedance-2-5-flash/create-task.md)，在请求示例下拉框中选择「首尾帧生视频」，填入 API Key 后点击 **Try it**。

## 请求示例

示例中的 `$DREAMTO_API_KEY` 为你的 API Key。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/api/v3/contents/generations/tasks" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-2.5-flash",
    "content": [
      {
        "type": "text",
        "text": "画面从第一张图自然过渡到第二张图，镜头平稳推进，光影柔和，电影感转场"
      },
      {
        "type": "image_url",
        "image_url": {
          "url": "https://example.com/frame_start.jpg"
        },
        "role": "first_frame"
      },
      {
        "type": "image_url",
        "image_url": {
          "url": "https://example.com/frame_end.jpg"
        },
        "role": "last_frame"
      }
    ],
    "duration": 5,
    "resolution": "720p"
  }'
```

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

payload = {
    "model": "seedance-2.5-flash",
    "content": [
        {
            "type": "text",
            "text": "画面从第一张图自然过渡到第二张图，镜头平稳推进，光影柔和，电影感转场"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/frame_start.jpg"
            },
            "role": "first_frame"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/frame_end.jpg"
            },
            "role": "last_frame"
        }
    ],
    "duration": 5,
    "resolution": "720p"
}

resp = requests.post(
    "https://api.dreamto.ai/api/v3/contents/generations/tasks",
    headers={"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"},
    json=payload,
    timeout=60,
)
print(resp.status_code, resp.json())  # {'id': 'task_...', 'request_id': 'req_...'}
```

```javascript Node.js theme={null}
const payload = {
  "model": "seedance-2.5-flash",
  "content": [
    {
      "type": "text",
      "text": "画面从第一张图自然过渡到第二张图，镜头平稳推进，光影柔和，电影感转场"
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/frame_start.jpg"
      },
      "role": "first_frame"
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/frame_end.jpg"
      },
      "role": "last_frame"
    }
  ],
  "duration": 5,
  "resolution": "720p"
};

const resp = await fetch("https://api.dreamto.ai/api/v3/contents/generations/tasks", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.DREAMTO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log(resp.status, await resp.json()); // { id: 'task_...', request_id: 'req_...' }
```

## 响应

创建成功返回 HTTP 200。`request_id` 与响应头 `X-Request-Id` 相同，排查问题时请提供：

```json theme={null}
{
  "id": "task_8c1d2e3f4a5b6c7d8e9f0a1b",
  "request_id": "req_3f9a1c2b7d4e5f60718293a4"
}
```

拿到任务 `id` 后，调用 [查询任务](https://docs.dreamto.ai/api-reference/seedance-2-5-flash/get-task.md) 轮询结果，`status` 为 `succeeded` 时读取 `content.video_url`。全部请求参数与取值说明见 [创建视频生成任务](https://docs.dreamto.ai/api-reference/seedance-2-5-flash/create-task.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.