> ## 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.

# First and last frame

> Generate the transition between a first and a last frame.

Pass two images with `role: first_frame` and `role: last_frame`. The closer their composition and subject, the smoother the transition; the output follows the input ratio and `ratio` has no effect.

> [!TIP]
>
> Want to try it? Open [Create video task](https://docs.dreamto.ai/en/api-reference/seedance-2-5-flash/create-task.md), pick "First and last frame" in the request example dropdown, enter your API Key and click **Try it**.

## Request

`$DREAMTO_API_KEY` is your 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": "Smoothly transition from the first image to the second, steady push-in, soft light, cinematic transition"
      },
      {
        "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": "Smoothly transition from the first image to the second, steady push-in, soft light, cinematic transition"
        },
        {
            "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": "Smoothly transition from the first image to the second, steady push-in, soft light, cinematic transition"
    },
    {
      "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_...' }
```

## Response

On success the API returns HTTP 200. `request_id` equals the `X-Request-Id` header; include it when contacting support:

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

With the task `id`, poll [Get task](https://docs.dreamto.ai/en/api-reference/seedance-2-5-flash/get-task.md); when `status` is `succeeded`, read `content.video_url`. See [Create video task](https://docs.dreamto.ai/en/api-reference/seedance-2-5-flash/create-task.md) for every parameter and value.


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