> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Video Generation

> Submit and poll async video generation tasks with the Node.js SDK.

# Video Generation

## Generate a Video

`client.videos.generate` sends `POST /v1/video/generations` and returns a task object containing the task ID.

```ts
import { MeshAPI } from "meshapi-node-sdk";

const client = new MeshAPI({ baseUrl: "https://api.meshapi.ai", token: "rsk_..." });

const task = await client.videos.generate({
  model: "byteplus/dreamina-seedance-2-0",
  content: [{ type: "text", text: "A serene mountain lake at sunrise" }],
});

console.log("Task ID:", task.id);
```

## Poll Until Complete

```ts
let status = await client.videos.retrieve(task.id);

while (status.status !== "succeeded" && status.status !== "failed") {
  await new Promise(r => setTimeout(r, 5_000));
  status = await client.videos.retrieve(task.id);
  console.log("Status:", status.status);
}

if (status.status === "succeeded" && status.content) {
  for (const item of status.content) {
    if (item.type === "video_url") {
      console.log("Video URL:", item.url);
    }
  }
}
```

## List Tasks

`client.videos.list` sends `GET /v1/video/generations`.

```ts
const listing = await client.videos.list({ limit: 20 });
console.log(`${listing.total} total tasks`);
for (const t of listing.data) {
  console.log(t.id, t.status);
}
```

## Retrieve a Task

`client.videos.retrieve` sends `GET /v1/video/generations/{task_id}`.

```ts
const task = await client.videos.retrieve("task-id");
console.log(task.status);
```

## Parameters

### `VideoGenerationParams`

| Field        | Type                 | Notes                                             |
| ------------ | -------------------- | ------------------------------------------------- |
| `model`      | `string`             | Required. e.g. `"byteplus/dreamina-seedance-2-0"` |
| `content`    | `VideoContentItem[]` | Required. Prompt content items.                   |
| `duration`   | `number?`            | Duration in seconds                               |
| `resolution` | `string?`            | e.g. `"1080p"`                                    |
| `seed`       | `number?`            | Reproducibility seed                              |

### `VideoContentItem`

| Field       | Type      | Notes                               |
| ----------- | --------- | ----------------------------------- |
| `type`      | `string`  | `"text"` or `"image_url"`           |
| `text`      | `string?` | Text prompt (when `type="text"`)    |
| `image_url` | `string?` | Image URL (when `type="image_url"`) |

### `VideoTaskResponse`

| Field     | Type      | Notes                                               |
| --------- | --------- | --------------------------------------------------- |
| `id`      | `string`  | Task ID                                             |
| `status`  | `string`  | `"pending"`, `"running"`, `"succeeded"`, `"failed"` |
| `content` | `array?`  | Output items when succeeded                         |
| `error`   | `object?` | Error details when failed                           |