---
name: sophnet-video-generate
description: "Generate videos from text prompts or images using Sophnet API. Supports text-to-video (T2V) and image-to-video (I2V) generation with models including Seedance-2.0 (default), Seedance-2.0-Fast, happyhorse-1.0-t2v/i2v, Wan2.6-T2V/I2V, ViduQ2-pro, Seedance-1.5-Pro, and any model name documented for the Sophnet video API. Use when users request video generation, ask to create videos from descriptions, convert images to videos, or specify video generation models. "
---

# Video Generator

Generate videos using Sophnet's video generation API with support for both text-to-video and image-to-video workflows.

## Supported Models

- **Seedance-2.0**: Default model (works for both text-to-video and image-to-video)
- **Seedance-2.0-Fast**: Lower latency Seedance variant
- **happyhorse-1.0-t2v / happyhorse-1.0-i2v**: Optional HappyHorse models
- **Wan2.6-T2V / Wan2.6-I2V**: Example alternatives when the user names them explicitly
- **ViduQ2-pro**: Supports both T2V and I2V
- **Seedance-1.5-Pro**: Supports both T2V and I2V

## Prerequisites

- **Python Environment**: Use `uv` to run Python scripts

## Workflow

### 1. Extract Image Path from Logs (if applicable)

When users upload images in chat channels, files are usually saved under `media/inbound/images/` in the workspace. Use Media Understanding logs to get exact resolved paths.

Typical log pattern:

```
[Media Understanding] Resolved relative path: "media/inbound/images/xxx.jpg" -> "/absolute/path/to/workspace/media/inbound/images/xxx.jpg"
```

Use the absolute path for the `--first-frame` argument.

### 2. Select Model

- If user didn't specify model → use Seedance-2.0
- If user specifies model → pass `--model` through to the API as given (no forced switch to default model). Exception: if they use `happyhorse-1.0-t2v` with `--first-frame`, the script uses `happyhorse-1.0-i2v`; `Wan2.6-T2V` with a first frame is adjusted to `Wan2.6-I2V` when building the request (modality only).

### 3. Run Generation Script

```bash
uv run python {baseDir}/scripts/gen_video.py \
  --prompt "Your video description" \
  --model "Seedance-2.0" \
  --size "1280*720" \
  --duration 5 \
  --first-frame "/absolute/path/to/image.jpg"
```

**Parameters:**

- `--prompt`: Video description (required)
- `--model`: Model name (optional, auto-selected based on input)
- `--size`: Resolution, default "1280\*720"
- `--duration`: Duration in seconds, default 5
- `--first-frame`: Path to image file or URL (optional, for I2V)

### 4. Output

The script will:

1. Upload local images to OSS if needed
2. Submit the video generation request
3. Poll the API until completion
4. Display the final video URL and local save path
5. Prompt the user to download the video
6. Lists other common models in console output; any documented Sophnet video model name can be passed via `--model`.

Example output:

```
📹 **您的视频提示词为**: [prompt]
✅ **视频生成成功**: <video controls width="100%" src="https://www.sophnet.com/api/open-apis/projects/download/xyz789"></video>
📥 **视频本地保存路径**: /path/to/xyz789.mp4
💬 **提示**:
    ⚠️ 本内容有AI生成，视频保存24小时，请及时下载保存！
    🤖 当前使用的模型为 [model]，还支持 [other models]
    🧠 如果想要指定模型，可以直接对我说：使用 [模型名称] 模型，生成 [视频描述]
```

Present this information to the user in a clear format.

## Examples

**Text-to-video:**

```bash
uv run python {baseDir}/scripts/gen_video.py \
  --prompt "A serene lake at sunset with swans swimming"
```

**Image-to-video:**

```bash
uv run python {baseDir}/scripts/gen_video.py \
  --prompt "Camera slowly zooms in" \
  --first-frame "/workspace/media/inbound/images/photo.jpg"
```

**Specify model:**

```bash
uv run python {baseDir}/scripts/gen_video.py \
  --prompt "A cat playing with yarn" \
  --model "Seedance-2.0"
```

## Notes

- Video generation typically takes 1-3 minutes
- Videos are stored for 24 hours on Sophnet servers
- Local copies saved to `~/.openclaw/workspace/media/inbound/videos/`
- Generation typically takes 1-5 minutes depending on model and duration
- Script automatically polls for completion with 5-minute timeout
