> ## 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 & last frame to video

> Give a first and a last frame and get the transition between them.

Send one `first_frame` and one `last_frame`. The closer the two images are in composition and subject, the smoother the transition; the prompt describes the motion and camera in between. Frame mode takes no audio input and cannot be mixed with reference media.

> [!TIP]
>
> Want to try it right away? Open [Create video generation task](https://docs.dreamto.ai/en/api-reference/wan-3-0-prime/create-video-synthesis.md), pick "First and last frame" in the request example menu, enter your API key and click **Try it**.

## Request

`$DREAMTO_API_KEY` in the examples is your API key.

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/api/v1/services/aigc/video-generation/video-synthesis" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-DashScope-Async: enable" \
  -d '{
    "model": "wan3.0-video-prime",
    "input": {
      "prompt": "The character walks from the window to the door; the camera follows.",
      "media": [
        {
          "type": "first_frame",
          "url": "https://your-cdn.example.com/first-frame.jpg"
        },
        {
          "type": "last_frame",
          "url": "https://your-cdn.example.com/last-frame.jpg"
        }
      ]
    },
    "parameters": {
      "resolution": "720P",
      "duration": 6
    }
  }'
```

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

payload = {
    "model": "wan3.0-video-prime",
    "input": {
        "prompt": "The character walks from the window to the door; the camera follows.",
        "media": [
            {
                "type": "first_frame",
                "url": "https://your-cdn.example.com/first-frame.jpg"
            },
            {
                "type": "last_frame",
                "url": "https://your-cdn.example.com/last-frame.jpg"
            }
        ]
    },
    "parameters": {
        "resolution": "720P",
        "duration": 6
    }
}

resp = requests.post(
    "https://api.dreamto.ai/api/v1/services/aigc/video-generation/video-synthesis",
    headers={
        "Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}",
        "X-DashScope-Async": "enable",
    },
    json=payload,
    timeout=60,
)
print(resp.status_code, resp.json())  # {'request_id': '...', 'output': {'task_id': '...', 'task_status': 'PENDING'}}
```

```javascript Node.js theme={null}
const payload = {
  "model": "wan3.0-video-prime",
  "input": {
    "prompt": "The character walks from the window to the door; the camera follows.",
    "media": [
      {
        "type": "first_frame",
        "url": "https://your-cdn.example.com/first-frame.jpg"
      },
      {
        "type": "last_frame",
        "url": "https://your-cdn.example.com/last-frame.jpg"
      }
    ]
  },
  "parameters": {
    "resolution": "720P",
    "duration": 6
  }
};

const resp = await fetch("https://api.dreamto.ai/api/v1/services/aigc/video-generation/video-synthesis", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.DREAMTO_API_KEY}`,
    "Content-Type": "application/json",
    "X-DashScope-Async": "enable",
  },
  body: JSON.stringify(payload),
});
console.log(resp.status, await resp.json()); // { request_id: '...', output: { task_id: '...', task_status: 'PENDING' } }
```

## Response

A successful create returns HTTP 200 and the task is queued. Quote `request_id` when you report a problem:

```json theme={null}
{
  "request_id": "7d2c3a51-8f0e-4b6a-9c1d-2e3f4a5b6c7d",
  "output": {
    "task_id": "0385dc79-5ff8-4d82-bcb6-bc5ae0ed7a4f",
    "task_status": "PENDING"
  }
}
```

With `output.task_id`, call [Query task](https://docs.dreamto.ai/en/api-reference/wan-3-0-prime/query-task.md) about every 15 seconds; when `task_status` is `SUCCEEDED`, download the video from `output.video_url`. All request parameters and their values are in [Create video generation task](https://docs.dreamto.ai/en/api-reference/wan-3-0-prime/create-video-synthesis.md).


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