# Video Generation (/docs/video)


Endpoint [#endpoint]

```
POST /v1/videos/generations
```

Request [#request]

```json
{
  "model": "model-id",
  "prompt": "A drone flyover of a tropical beach at golden hour",
  "duration": 5,
  "resolution": "1080p"
}
```

Parameters [#parameters]

| Parameter    | Type    | Required | Description               |
| ------------ | ------- | -------- | ------------------------- |
| `model`      | string  | Yes      | Video model ID            |
| `prompt`     | string  | Yes      | Text description          |
| `duration`   | integer | No       | Video duration in seconds |
| `resolution` | string  | No       | Output resolution         |
| `fps`        | integer | No       | Frames per second         |

Response [#response]

Video generation is typically asynchronous. The API returns a task ID:

```json
{
  "id": "video_abc123",
  "status": "processing",
  "created_at": 1709251200
}
```

Check Status [#check-status]

```
GET /v1/videos/generations/{id}
```

```json
{
  "id": "video_abc123",
  "status": "completed",
  "video_url": "https://api.yuhuanstudio.com/v1/temp-images/video_abc123.mp4"
}
```

Available Models [#available-models]

<Callout type="info">
  For a list of available video models and their capabilities, please use the [Models API](/docs/models-api) with `GET /v1/models?type=video_generation`.
</Callout>

Example [#example]

```python
import httpx
import time

# Submit generation request
response = httpx.post(
    "https://api.yuhuanstudio.com/v1/videos/generations",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model": "model-id",
        "prompt": "Ocean waves crashing on a rocky shore, cinematic",
        "duration": 5
    }
)

task = response.json()
task_id = task["id"]

# Poll for completion
while True:
    status = httpx.get(
        f"https://api.yuhuanstudio.com/v1/videos/generations/{task_id}",
        headers={"Authorization": "Bearer YOUR_API_KEY"}
    ).json()

    if status["status"] == "completed":
        print(f"Video ready: {status['video_url']}")
        break
    elif status["status"] == "failed":
        print(f"Generation failed: {status.get('error')}")
        break

    time.sleep(5)
```

<Callout type="info">
  Video generation availability depends on your subscribed providers. Check the Dashboard for available video models.
</Callout>
