> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shuyou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Video generation

# Video Generation

ShuYou supports calling video generation models via the Vertex AI protocol. This guide explains how to generate videos with ShuYou.

<Tip title="💡 About Video Generation">
  Video generation models can automatically produce high-quality video content from text descriptions. ShuYou aggregates leading video generation models such as Google Veo and ByteDance Seedance, allowing you to call them easily through a unified API interface.
</Tip>

## API reference

* [Doubao Seedance 2.0](/en/api-reference/video-series/seedance/doubao-seedance-2.0-video-generate) — `POST /v1/predictions`
* [Doubao Seedance 2.0 Fast](/en/api-reference/video-series/seedance/doubao-seedance-2.0-fast-video-generate) — `POST /v1/predictions`
* [HappyHorse 1.0 T2V](/en/api-reference/video-series/happyhorse/happyhorse-1.0-t2v-video-generate) — `POST /v1/predictions`
* [HappyHorse 1.0 R2V](/en/api-reference/video-series/happyhorse/happyhorse-1.0-r2v-video-generate) — `POST /v1/predictions`
* [HappyHorse 1.0 I2V](/en/api-reference/video-series/happyhorse/happyhorse-1.0-i2v-video-generate) — `POST /v1/predictions`
* [HappyHorse 1.0 Video Edit](/en/api-reference/video-series/happyhorse/happyhorse-1.0-video-edit-video-generate) — `POST /v1/predictions`
* Task status: [Get a prediction](/en/api-reference/task-management/get-prediction)

## Supported Models

The currently supported video generation models in the API reference include (continuously updated):

* `doubao-seedance-2.0` — ByteDance Seedance 2.0
* `doubao-seedance-2.0-fast` — ByteDance Seedance 2.0 Fast
* `happyhorse-1.0-t2v` — HappyHorse 1.0 T2V
* `happyhorse-1.0-r2v` — HappyHorse 1.0 R2V
* `happyhorse-1.0-i2v` — HappyHorse 1.0 I2V
* `happyhorse-1.0-video-edit` — HappyHorse 1.0 Video Edit

<Tip title="📚 More Models">
  Visit the [ShuYou model list](https://shuyou.ai/models) to search and view all available video generation models.
</Tip>

## Text-to-Video

Generate videos directly from a text prompt using an asynchronous workflow: submit a generation request first, then poll until generation completes, and finally retrieve the result.

```Python title="Google Veo 3.1" theme={null}
from google import genai
from google.genai import types
import time

client = genai.Client(
    api_key="$ShuYou_API_KEY",  # Replace with your API Key
    vertexai=True,
    http_options=types.HttpOptions(
        api_version="v1",
        base_url="https://api.shuyou.ai"
    )
)

# Step 1: Submit a video generation request
operation = client.models.generate_videos(
    model="google/veo-3.1-generate-001",  # [!code highlight]
    prompt="A golden retriever running on the beach at sunset"
)

# Step 2: Poll until generation is complete
while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)

# Step 3: Retrieve the generated results
for video in operation.response.generated_videos:
    print(video)
```

```Python title="Seedance 1.5 Pro" theme={null}
from google import genai
from google.genai import types
import time

client = genai.Client(
    api_key="$ShuYou_API_KEY",  # Replace with your API Key
    vertexai=True,
    http_options=types.HttpOptions(
        api_version="v1",
        base_url="https://api.shuyou.ai"
    )
)

# Step 1: Submit a video generation request
operation = client.models.generate_videos(
    model="volcengine/doubao-seedance-1.5-pro",  # [!code highlight]
    prompt="A golden retriever running on the beach at sunset"
)

# Step 2: Poll until generation is complete
while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)

# Step 3: Retrieve the generated results
for video in operation.response.generated_videos:
    print(video)
```

```Python title="Seedance 2" theme={null}
from google import genai
from google.genai import types
import time

client = genai.Client(
    api_key="$ShuYou_API_KEY",  # Replace with your API Key
    vertexai=True,
    http_options=types.HttpOptions(
        api_version="v1",
        base_url="https://api.shuyou.ai"
    )
)

# Step 1: Submit a video generation request
operation = client.models.generate_videos(
    model="volcengine/doubao-seedance-2",  # [!code highlight]
    prompt="A golden retriever running on the beach at sunset"
)

# Step 2: Poll until generation is complete
while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)

# Step 3: Retrieve the generated results
for video in operation.response.generated_videos:
    print(video)
```

## Image-to-Video

In addition to text-to-video, ShuYou also supports passing an image as the starting frame and generating a video using a text prompt. Provide the image data via the `image` parameter.

```Python title="Google Veo 3.1" theme={null}
from google import genai
from google.genai import types
import time

client = genai.Client(
    api_key="$ShuYou_API_KEY",  # Replace with your API Key
    vertexai=True,
    http_options=types.HttpOptions(
        api_version="v1",
        base_url="https://api.shuyou.ai"
    )
)

# Read a local image
with open("input_image.png", "rb") as f:
    image_bytes = f.read()

# Step 1: Submit an image-to-video request
operation = client.models.generate_videos(
    model="google/veo-3.1-generate-001",  # [!code highlight]
    image=types.Image(image_bytes=image_bytes, mime_type="image/png"),  # [!code highlight]
    prompt="The dog stands up and runs toward the ocean waves"
)

# Step 2: Poll until generation is complete
while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)

# Step 3: Retrieve the generated results
for video in operation.response.generated_videos:
    print(video)
```

```Python title="Seedance 1.5 Pro" theme={null}
from google import genai
from google.genai import types
import time

client = genai.Client(
    api_key="$ShuYou_API_KEY",  # Replace with your API Key
    vertexai=True,
    http_options=types.HttpOptions(
        api_version="v1",
        base_url="https://api.shuyou.ai"
    )
)

# Read a local image
with open("input_image.png", "rb") as f:
    image_bytes = f.read()

# Step 1: Submit an image-to-video request
operation = client.models.generate_videos(
    model="volcengine/doubao-seedance-1.5-pro",  # [!code highlight]
    image=types.Image(image_bytes=image_bytes, mime_type="image/png"),  # [!code highlight]
    prompt="The dog stands up and runs toward the ocean waves"
)

# Step 2: Poll until generation is complete
while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)

# Step 3: Retrieve the generated results
for video in operation.response.generated_videos:
    print(video)
```

```Python title="Seedance 2" theme={null}
from google import genai
from google.genai import types
import time

client = genai.Client(
    api_key="$ShuYou_API_KEY",  # Replace with your API Key
    vertexai=True,
    http_options=types.HttpOptions(
        api_version="v1",
        base_url="https://api.shuyou.ai"
    )
)

# Read a local image
with open("input_image.png", "rb") as f:
    image_bytes = f.read()

# Step 1: Submit an image-to-video request
operation = client.models.generate_videos(
    model="volcengine/doubao-seedance-2",  # [!code highlight]
    image=types.Image(image_bytes=image_bytes, mime_type="image/png"),  # [!code highlight]
    prompt="The dog stands up and runs toward the ocean waves"
)

# Step 2: Poll until generation is complete
while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)

# Step 3: Retrieve the generated results
for video in operation.response.generated_videos:
    print(video)
```

<Tip title="💡 Image-to-Video Notes">
  * The `image` parameter is passed via `types.Image`, which supports `image_bytes` (binary data) and `mime_type` (e.g., `image/png`, `image/jpeg`).
  * The `prompt` parameter is optional and is used to describe how the content in the image should move or change.
  * The image will be used as the starting frame of the video, and the model will generate subsequent animation based on the image content and the prompt.
</Tip>

## Configuration

### Required Parameters

* **api\_key**: Your ShuYou API key
* **vertexai**: Must be set to `true` to enable the Vertex AI protocol
* **base\_url**: ShuYou Vertex AI endpoint `https://api.shuyou.ai`
* **model**: The video generation model name, such as `google/veo-3.1-generate-001`
* **prompt**: A text prompt describing the video content to generate

### Optional Parameters

You can customize video properties such as aspect ratio, duration, and audio via the `config` parameter:

| Parameter         | Type   | Description               | Example Values              |
| ----------------- | ------ | ------------------------- | --------------------------- |
| `aspectRatio`     | `str`  | Video aspect ratio        | `"16:9"`, `"9:16"`, `"1:1"` |
| `resolution`      | `str`  | Video resolution          | `"720p"`, `"1080p"`         |
| `durationSeconds` | `int`  | Video duration (seconds)  | `5`, `8`, `10`              |
| `generateAudio`   | `bool` | Whether to generate audio | `True`, `False`             |

**Configuration example:**

```python theme={null}
operation = client.models.generate_videos(
    model="google/veo-3.1-generate-001",
    prompt="A cat playing piano in a cozy room with warm lighting",
    config=types.GenerateVideosConfig(
        aspectRatio="16:9",       # Landscape 16:9  # [!code highlight]
        resolution="720p",        # 720p resolution  # [!code highlight]
        durationSeconds=8,        # 8-second video duration  # [!code highlight]
        generateAudio=True,       # Generate a video with audio  # [!code highlight]
    )
)
```

<Tip title="💡 Parameter Support Notes">
  Support for optional parameters may vary by model. If you pass a parameter value that the model does not support, the API will return an error. We recommend testing with default parameters first, then adjusting gradually.
</Tip>

### Call Flow

Video generation is an asynchronous process with three steps:

1. **Submit request** (`generate_videos`): Send a video generation request and receive an `operation` object
2. **Poll status** (`operations.get`): Check generation status periodically; a 15-second interval is recommended
3. **Retrieve results**: When `operation.done` is `True`, get the videos from `operation.response.generated_videos`

<Warning title="⚠️ Generation Time">
  Video generation typically takes a while (from tens of seconds to several minutes). Please be patient while polling completes, and avoid setting the polling interval too short.
</Warning>

## Best Practices

1. **Prompt optimization**: Use clear, specific scene descriptions, including subject, actions, environment, lighting, and other key elements
2. **Polling interval**: Use a 15-second polling interval to avoid overly frequent requests
3. **Error handling**: Add exception handling and a timeout mechanism to prevent infinite polling
4. **Model selection**: Choose the right model for your needs — Veo 3.1 excels at high-quality general video generation, while the Seedance family has unique strengths in specific scenarios
