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

# SkyReels V4 视频生成

>  - 提供 Fast（速度优先）和 Std（质量优先）两档模型
- 支持文生视频（T2V）、图生视频（I2V）、多模态参考（Omni）三种模式，由传参自动路由
- 支持 480p / 720p / 1080p 分辨率，3 ~ 15 秒时长
- 支持首帧/尾帧/关键帧、参考图、参考视频、拼贴图、视频扩展、声纹同步等高阶能力
- 异步处理模式，返回任务 ID 用于后续查询 

```bash cURL theme={null}
curl --request POST \
  --url https://api.apimart.ai/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "skyreels-v4-fast",
    "prompt": "A serene forest at sunset with golden light filtering through the trees.",
    "duration": 5,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "prompt_optimizer": true
  }'
```

```python Python theme={null}
import requests

url = "https://api.apimart.ai/v1/videos/generations"

payload = {
    "model": "skyreels-v4-fast",
    "prompt": "A serene forest at sunset with golden light filtering through the trees.",
    "duration": 5,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "prompt_optimizer": True
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript JavaScript theme={null}
const url = "https://api.apimart.ai/v1/videos/generations";

const payload = {
  model: "skyreels-v4-fast",
  prompt: "A serene forest at sunset with golden light filtering through the trees.",
  duration: 5,
  resolution: "1080p",
  aspect_ratio: "16:9",
  prompt_optimizer: true
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
```

```go Go theme={null}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://api.apimart.ai/v1/videos/generations"

    payload := map[string]interface{}{
        "model":            "skyreels-v4-fast",
        "prompt":           "A serene forest at sunset with golden light filtering through the trees.",
        "duration":         5,
        "resolution":       "1080p",
        "aspect_ratio":     "16:9",
        "prompt_optimizer": true,
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer <token>")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={null}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://api.apimart.ai/v1/videos/generations";

        String payload = """
        {
          "model": "skyreels-v4-fast",
          "prompt": "A serene forest at sunset with golden light filtering through the trees.",
          "duration": 5,
          "resolution": "1080p",
          "aspect_ratio": "16:9",
          "prompt_optimizer": true
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("Authorization", "Bearer <token>")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
```

```php PHP theme={null}
<?php

$url = "https://api.apimart.ai/v1/videos/generations";

$payload = [
    "model" => "skyreels-v4-fast",
    "prompt" => "A serene forest at sunset with golden light filtering through the trees.",
    "duration" => 5,
    "resolution" => "1080p",
    "aspect_ratio" => "16:9",
    "prompt_optimizer" => true
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

```ruby Ruby theme={null}
require 'net/http'
require 'json'
require 'uri'

url = URI("https://api.apimart.ai/v1/videos/generations")

payload = {
  model: "skyreels-v4-fast",
  prompt: "A serene forest at sunset with golden light filtering through the trees.",
  duration: 5,
  resolution: "1080p",
  aspect_ratio: "16:9",
  prompt_optimizer: true
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json

response = http.request(request)
puts response.body
```

```swift Swift theme={null}
import Foundation

let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

let payload: [String: Any] = [
    "model": "skyreels-v4-fast",
    "prompt": "A serene forest at sunset with golden light filtering through the trees.",
    "duration": 5,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "prompt_optimizer": true
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print("Error: \(error)")
        return
    }

    if let data = data, let responseString = String(data: data, encoding: .utf8) {
        print(responseString)
    }
}

task.resume()
```

```csharp C# theme={null}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var url = "https://api.apimart.ai/v1/videos/generations";

        var payload = @"{
            ""model"": ""skyreels-v4-fast"",
            ""prompt"": ""A serene forest at sunset with golden light filtering through the trees."",
            ""duration"": 5,
            ""resolution"": ""1080p"",
            ""aspect_ratio"": ""16:9"",
            ""prompt_optimizer"": true
        }";

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

        var content = new StringContent(payload, Encoding.UTF8, "application/json");
        var response = await client.PostAsync(url, content);
        var result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}
```

```json 200 theme={null}
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KPEY5H3NQ2W8D7T6VB3F9GR4"
    }
  ]
}
```

```json 400 theme={null}
{
  "error": {
    "code": 400,
    "message": "请求参数无效",
    "type": "invalid_request_error"
  }
}
```

```json 401 theme={null}
{
  "error": {
    "code": 401,
    "message": "身份验证失败，请检查您的API密钥",
    "type": "authentication_error"
  }
}
```

```json 402 theme={null}
{
  "error": {
    "code": 402,
    "message": "账户余额不足，请充值后再试",
    "type": "payment_required"
  }
}
```

```json 422 theme={null}
{
  "error": {
    "code": 422,
    "message": "参数互斥或取值非法（例如同时传入 I2V 与 Omni 字段）",
    "type": "invalid_request_error"
  }
}
```

```json 429 theme={null}
{
  "error": {
    "code": 429,
    "message": "请求过于频繁，请稍后再试",
    "type": "rate_limit_error"
  }
}
```

```json 500 theme={null}
{
  "error": {
    "code": 500,
    "message": "服务器内部错误，请稍后重试",
    "type": "server_error"
  }
}
```

## 认证

**Authorization** `string` *required*

所有接口均需要使用 Bearer Token 进行认证

获取 API Key：

访问 [API Key 管理页面](https://apimart.ai/keys) 获取您的 API Key

使用时在请求头中添加：

```
Authorization: Bearer YOUR_API_KEY
```

## 生成模式

SkyReels V4 通过请求字段自动路由到对应模式，**无需指定 `mode` 字段**：

| 模式 | 触发条件 | 能力 |
| - | - | - |
| **T2V**（文生视频） | 只传 `prompt` 及通用字段 | 纯文本驱动生成 |
| **I2V**（图生视频） | 传入 `first_frame_image` / `end_frame_image` / `mid_frame_images` 任一 | 首帧、尾帧、关键帧控制 |
| **Omni**（多模态参考） | 传入 `ref_images` / `ref_videos` 任一 | 主体参考、拼贴图、动作参考、视频扩展、声纹同步 |

> [!WARNING]
>
> **严格互斥**：I2V 字段（`first_frame_image` / `end_frame_image` / `mid_frame_images`）与 Omni 字段（`ref_images` / `ref_videos`）不能同时出现，否则返回 422。

> [!NOTE]
>
> **`@tag` 机制**：当使用 `mid_frame_images` / `ref_images` / `ref_videos` 时，每个元素需声明一个以 `@` 开头的 `tag`（如 `@image1`、`@Actor-1`、`@video1`），并且 `tag` **必须出现在 `prompt` 中**。
>
> 可以把 `prompt` 理解为"剧本"，`tag` 则是指向具体素材（图片 / 视频）的"角色指针"—— 例如 prompt 写 `"@Actor-1 走进 @video1 的场景"`，系统据此将 `@Actor-1` 对应的参考图主体和 `@video1` 对应的动作参考注入到生成过程。

## 请求参数

### 通用字段

**model** `string` *required*

支持以下两个档位：

| 模型 | 定位 | 适用场景 |
| - | - | - |
| `skyreels-v4-fast` | 速度优先 | 快速预览、批量生成、日常内容 |
| `skyreels-v4-std` | 质量优先（价格较 Fast 高 25\~30%） | 关键画面、细节要求高、正式交付 |

> [!WARNING]
>
> **必须显式传递 `model` 字段，无默认值。**

> [!TIP]
>
> **计费与分辨率、是否使用 `ref_videos` 强相关**：1080p 价格显著高于 480p / 720p；传入 `ref_videos`（带视频输入）的档位约为无视频输入的 1.5 \~ 2 倍。暂不支持音频和视频同时输出。

**nsfw\_check** `boolean` (default: false)

是否在提交视频任务前执行内容审核。

* `true`：使用 `omni-moderation-latest` 审核提示词和输入图片
* `false` 或不传：不发起审核请求，不增加审核成本与延迟（默认）

**prompt** `string` *required*

文本提示词，最长 **1280 tokens**

建议详细描述场景、主体、动作、风格等，以获得更好的生成效果。

使用 `ref_images` / `ref_videos` / `mid_frame_images` 时，`prompt` 中**必须包含** 对应的 `@tag`（如 `@Actor-1`、`@video1`、`@image1`）。

示例：`"@Actor-1 walks through a neon-lit street at night."`

**duration** `integer` (default: 5)

输出视频时长（秒）

* 取值范围：`[3, 15]`
* 默认值：`5`

> [!WARNING]
>
> 当传入 `ref_videos.type=reference` 时，`duration` 会被参考视频长度覆盖（上限 10 秒）。

**resolution** `string` (default: 1080p)

视频分辨率

可选值：

* `480p`
* `720p`
* `1080p`（默认）

**aspect\_ratio** `string` (default: 16:9)

宽高比

可选值：

* `16:9`（默认）
* `4:3`
* `1:1`
* `9:16`
* `3:4`

> [!WARNING]
>
> **I2V 模式下 `aspect_ratio` 会被忽略**（输出比例由输入图决定）；Omni 带 `ref_videos` 时同样忽略。

**prompt\_optimizer** `boolean` (default: true)

是否自动优化 prompt

启用后，系统会自动优化您的提示词以获得更好的生成效果。

### I2V 专用字段

**first\_frame\_image** `string`

视频起始帧图片 URL（jpg / jpeg / png / gif / bmp）

传入后将以该图片作为视频的**起始画面**。

**end\_frame\_image** `string`

视频结束帧图片 URL（jpg / jpeg / png / gif / bmp）

传入后将以该图片作为视频的**结束画面**，可与 `first_frame_image` 组合实现首尾帧控制。

**mid\_frame\_images** `object[]`

中间关键帧列表，最多 **6 个**。每个元素结构如下：

**mid\_frame\_images 元素**

**tag** `string` *required*

以 `@` 开头，且必须出现在 `prompt` 中，如 `@image1`

**image\_url** `string` *required*

图片 URL（jpg / jpeg / png / gif / bmp）

**time\_stamp** `integer` (default: -1)

出现时间戳（秒）。默认 `-1`（不指定）；指定时必须满足 `0 < time_stamp < duration`。

### Omni 专用字段

**ref\_images** `object[]`

参考图列表（所有元素 `type` 必须一致）。每个元素结构如下：

**ref\_images 元素**

**tag** `string` *required*

以 `@` 开头，且必须出现在 `prompt` 中，如 `@Actor-1`

**type** `string` *required*

参考类型：

* `image` - 常规参考图（列表长度 1~~3；每项 `image_urls` 长度 1~~5）
* `grid` - 拼贴图，即多张图合并为一张的网格图（如 4 宫格、9 宫格）；列表长度必须 = 1，`image_urls` 必须 1 张

**image\_urls** `string[]` *required*

图片 URL 数组

**audio\_url** `string`

声纹音频 URL（**仅 `type=image` 支持**，音频时长 ≤ 15 秒）

**ref\_videos** `object[]`

参考视频列表，**最多 1 个**。每个元素结构如下：

**ref\_videos 元素**

**tag** `string` *required*

以 `@` 开头，且必须出现在 `prompt` 中，如 `@video1`

**type** `string` *required*

参考类型：

* `reference` - 动作/主体参考，**会覆盖 `duration`**（跟随参考视频长度，最长 10 秒），默认带入输入视频音频；**可与 `ref_images.type=image` 组合**
* `extend` - 视频扩展，按请求 `duration` 计费；**不能与 `ref_images` 组合**

**video\_url** `string` *required*

视频 URL（MP4 / MOV，时长 ≤ 15 秒）

## 支持的生成场景

以下场景 `skyreels-v4-fast` 和 `skyreels-v4-std` **均支持**：

| 场景 | 模式 | 必填参数 | 典型用例 |
| - | - | - | - |
| 文生视频 | T2V | `prompt` | 纯文本描述驱动，快速生成概念镜头 |
| 图生视频 - 首帧 | I2V | `first_frame_image` | 静图转视频，指定起始画面 |
| 图生视频 - 尾帧 | I2V | `end_frame_image` | 指定视频收束画面 |
| 图生视频 - 关键帧 | I2V | `mid_frame_images`（1 \~ 6） | 首 + 尾 + 中间关键帧，精准控制分镜节奏 |
| Omni 单/多主体参考 | Omni | `ref_images`（`type=image`） | 角色一致性、多主体同框 |
| Omni 拼贴图 | Omni | `ref_images`（`type=grid`，1 张） | 分步流程视频（教程、菜谱、操作示范） |
| Omni 动作参考 | Omni | `ref_videos`（`type=reference`） | 复刻参考视频的动作、主体或风格 |
| Omni 视频扩展 | Omni | `ref_videos`（`type=extend`） | 从已有视频续写后续剧情 |
| Omni 声纹同步 | Omni | `ref_images`（`type=image`）+ `audio_url` | 数字人口播、音频驱动对口型 |

## 参数约束

以下约束违反时请求将被拒绝并返回 **422**，且 **不产生计费**：

| 参数 | 约束 |
| - | - |
| `prompt` | 最长 1280 tokens |
| `duration` | `[3, 15]` 秒；带 `ref_videos.type=reference` 时被参考视频长度覆盖（上限 10 秒） |
| `resolution` | 仅 `480p` / `720p` / `1080p` |
| `aspect_ratio` | `16:9` / `4:3` / `1:1` / `9:16` / `3:4`；I2V 忽略；Omni 带 `ref_videos` 时忽略 |
| `mid_frame_images` | 最多 6 个；`time_stamp` 必须为 `-1` 或落在 `(0, duration)` 区间 |
| `ref_images` 整体 | 列表内 `type` 必须一致；不能与 I2V 字段同时出现 |
| `ref_images.type=grid` | 列表长度必须 = 1；`image_urls` 必须为 1 张 |
| `ref_images.type=image` | 列表长度 1 \~ 3；每项 `image_urls` 长度 1 \~ 5 |
| `ref_images.audio_url` | 仅 `type=image` 支持，音频 ≤ 15 秒 |
| `ref_videos` | 最多 1 个；`video_url` MP4 / MOV，≤ 15 秒 |
| `ref_videos.type=reference` | 覆盖请求 `duration`（最长 10 秒），可与 `ref_images.type=image` 组合，默认带入输入视频音频 |
| `ref_videos.type=extend` | 按请求 `duration` 计费；**不能与 `ref_images` 组合** |
| `tag` 字段 | 必须以 `@` 开头且出现在 `prompt` 中 |
| I2V / Omni 互斥 | I2V 字段与 Omni 字段不能同时出现 |

## 响应

**code** `integer`

响应状态码，成功时为 200

**data** `array`

返回数据数组

**数组元素**

**status** `string`

任务状态，初始提交时为 `submitted`

**task\_id** `string`

任务唯一标识符，用于查询任务状态和结果

## 请求示例

### 场景 1：文生视频（最简）

```json theme={null}
{
  "model": "skyreels-v4-fast",
  "prompt": "A serene forest at sunset with golden light filtering through the trees."
}
```

### 场景 2：文生视频（完整参数）

```json theme={null}
{
  "model": "skyreels-v4-std",
  "prompt": "A serene forest at sunset.",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "prompt_optimizer": true
}
```

### 场景 3：图生视频 - 首帧

```json theme={null}
{
  "model": "skyreels-v4-fast",
  "prompt": "Slowly pull the camera back to reveal the entire scene.",
  "first_frame_image": "https://example.com/start.png",
  "duration": 5
}
```

### 场景 4：图生视频 - 首尾帧 + 中间关键帧

```json theme={null}
{
  "model": "skyreels-v4-std",
  "prompt": "The King summons a flying dragon. @image1 The dragon lowers. The King mounts and flies away.",
  "duration": 8,
  "resolution": "1080p",
  "first_frame_image": "https://example.com/k2v_0.png",
  "end_frame_image":   "https://example.com/k2v_2.png",
  "mid_frame_images": [
    { "tag": "@image1", "image_url": "https://example.com/k2v_1.png", "time_stamp": 3 }
  ]
}
```

### 场景 5：Omni - 单主体参考

```json theme={null}
{
  "model": "skyreels-v4-fast",
  "prompt": "@Actor-1 walks through a neon-lit street at night.",
  "ref_images": [
    { "tag": "@Actor-1", "type": "image", "image_urls": ["https://example.com/actor.jpg"] }
  ]
}
```

### 场景 6：Omni - 多主体 + 视频动作参考

```json theme={null}
{
  "model": "skyreels-v4-fast",
  "prompt": "The man from @image_1 imitates the move on the left in @video_1. The woman from @image_2 imitates the right side.",
  "duration": 5,
  "ref_images": [
    { "tag": "@image_1", "type": "image", "image_urls": ["https://example.com/a.png"] },
    { "tag": "@image_2", "type": "image", "image_urls": ["https://example.com/b.png"] }
  ],
  "ref_videos": [
    { "tag": "@video_1", "type": "reference", "video_url": "https://example.com/motion.mp4" }
  ]
}
```

> [!WARNING]
>
> 此场景使用 `ref_videos.type=reference`，**请求的 `duration` 会被参考视频实际长度覆盖**（上限 10 秒）。即便此处传 `"duration": 5`，最终视频长度以参考视频为准。

### 场景 7：Omni - 拼贴图（grid）

```json theme={null}
{
  "model": "skyreels-v4-fast",
  "prompt": "Create a video showing how to make tomato and egg noodles based on @image1.",
  "ref_images": [
    { "tag": "@image1", "type": "grid", "image_urls": ["https://example.com/recipe_grid.png"] }
  ]
}
```

### 场景 8：Omni - 视频扩展（extend）

```json theme={null}
{
  "model": "skyreels-v4-fast",
  "prompt": "Video extended @video1, someone walks over and sits on the sofa.",
  "duration": 8,
  "ref_videos": [
    { "tag": "@video1", "type": "extend", "video_url": "https://example.com/source.mp4" }
  ]
}
```

### 场景 9：Omni - 带声纹（语音同步）

```json theme={null}
{
  "model": "skyreels-v4-std",
  "prompt": "@Actor-1 speaks with a calm tone.",
  "ref_images": [
    {
      "tag": "@Actor-1",
      "type": "image",
      "image_urls": ["https://example.com/actor.jpg"],
      "audio_url":  "https://example.com/voice.mp3"
    }
  ]
}
```

> [!NOTE]
>
> **查询任务结果**
>
> 视频生成为异步任务，提交后会返回 `task_id`。使用 [获取任务状态](https://docs.apimart.ai/cn/api-reference/tasks/status.md) 接口查询生成进度和结果。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.