# Video Generation & Quality Enhancement Cascade

This platform supports a **Video Generation + Automatic Quality Enhancement** cascade invocation mode (e.g., generating a video through the Volcengine Doubao video model and automatically routing the output video stream to Volcengine MediaKit for 60fps + 1080p quality enhancement). Developers can complete complex audio/video production workflows with a single API call.

### 1. How it Works
In cascade mode, your request is automatically split into two asynchronous processing stages by the gateway:
* **Stage 1**: Submits the base video generation task to the base model (e.g., `doubao-seedance-1-0-pro-fast`) to generate the raw video file.
* **Stage 2**: Once the base video is generated, the gateway automatically retrieves the direct video URL and submits it as an input to the Volcengine MediaKit enhancement model, returning the final super-resolution video.

> [!TIP]
> The cascade task status remains `processing` until Stage 2 is completed. If Stage 1 or Stage 2 fails, the system will automatically handle the refund billing for the corresponding stage.

### 2. How to Request
* **Endpoint**: `/v1/video/generations` (OpenAI Compatible Video API)
* **Method**: `POST`

Simply add the following extended fields to your video generation request payload:

#### Request Parameters (Extended Fields)
| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `version` | `string` | No | Version of cascade enhancement. Options:<br>• `"fast"`: Fast enhancement (corresponds to `vve-ft`)<br>• `"standard"`: Standard enhancement (corresponds to `vve-sd`, default)<br>• `"pro"`: Professional enhancement (corresponds to `vve-pf`)<br>• `"ai"`: Large Model-based AI enhancement (corresponds to `vve-gt`) |
| `resolution` | `string` | No | Target resolution. Options: `"720p"`, `"1080p"`, `"2k"`, `"4k"`. <br>**Note**: The large model-based AI version (`"ai"`) does not support `2k` and `4k` resolutions. |

> [!NOTE]
> **Automatic Base Resolution Optimization**: <br>
> To save generation cost and minimize waiting time, the gateway automatically truncates the generation resolution of the Stage 1 base video (e.g., if the target is `1080p`, the base model generates at `720p`; if the target is `2k`/`4k`, it generates at `1080p`, and the fast version is limited to `720p`). The video is then scaled up to your target `resolution` in Stage 2 by the quality enhancement model.

#### Curl Request Example
```bash
curl -X POST https://www.roookey.com/v1/video/generations \
  -H "Authorization: Bearer sk-your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-1-0-pro-fast",
    "prompt": "European classical castle in a sea of clouds, 4k details",
    "resolution": "1080p",
    "duration": 5,
    "version": "pro"
  }'
```

### 3. Billing and Refund
1. **Pre-deduction**: When a task is submitted, the system pre-deducts and freezes quota based on the **base model single price** + **estimated price of cascade enhancement**.
2. **Final Settlement**: When Stage 2 enhancement succeeds and returns the final video, the system settles the exact billing based on the actual duration of the base video and final resolution/fps of the enhanced video.
