> 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 Go SDK.

# Video Generation

## Generate a Video

`client.Videos.Generate` sends `POST /v1/video/generations` and returns a `*CreateVideoGenerationResponse` containing the task ID.

```go
import (
    "fmt"
    meshapi "github.com/aifiesta/meshapi-go-sdk"
)

text := "A serene mountain lake at sunrise"

task, err := client.Videos.Generate(ctx, meshapi.VideoGenerationParams{
    Model: "byteplus/dreamina-seedance-2-0",
    Content: []meshapi.VideoContentItem{
        {Type: "text", Text: &text},
    },
})
if err != nil {
    log.Fatal(err)
}

fmt.Println("Task ID:", task.ID)
```

## Poll Until Complete

```go
import "time"

for {
    status, err := client.Videos.Retrieve(ctx, task.ID)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("Status:", status.Status)
    if status.Status == "succeeded" || status.Status == "failed" {
        break
    }
    time.Sleep(5 * time.Second)
}
```

## List Tasks

`client.Videos.List` sends `GET /v1/video/generations`.

```go
limit := 20
listing, err := client.Videos.List(ctx, &meshapi.ListVideoGenerationsParams{
    Limit: &limit,
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("%d total tasks\n", listing.Total)
for _, t := range listing.Data {
    fmt.Println(t.ID, t.Status)
}
```

## Retrieve a Task

`client.Videos.Retrieve` sends `GET /v1/video/generations/{task_id}`.

```go
task, err := client.Videos.Retrieve(ctx, "task-id")
if err != nil {
    log.Fatal(err)
}
fmt.Println(task.Status)
```

## Parameters

### `VideoGenerationParams`

| Field        | Type                 | Notes                                             |
| ------------ | -------------------- | ------------------------------------------------- |
| `Model`      | `string`             | Required. e.g. `"byteplus/dreamina-seedance-2-0"` |
| `Content`    | `[]VideoContentItem` | Required. Prompt content items.                   |
| `Duration`   | `*int`               | Duration in seconds                               |
| `Resolution` | `*string`            | e.g. `"1080p"`                                    |
| `Seed`       | `*int`               | Reproducibility seed                              |

### `VideoContentItem`

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

### `VideoTaskResponse`

| Field     | Type                 | Notes                                               |
| --------- | -------------------- | --------------------------------------------------- |
| `ID`      | `string`             | Task ID                                             |
| `Status`  | `string`             | `"pending"`, `"running"`, `"succeeded"`, `"failed"` |
| `Content` | `[]VideoTaskContent` | Output items when succeeded                         |
| `Error`   | `*VideoTaskError`    | Error details when failed                           |