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

# omni-fast-v2v 参考视频生成

> 使用 `POST /v1/videos` 调用 `omni-fast-v2v` 做参考视频编辑、延长或重生成。

# omni-fast-v2v

`omni-fast-v2v` 使用 JSON 请求体提交异步视频任务，适合把已有 MP4 作为参考视频进行编辑、延长或重生成。

* 异步处理模式，提交后返回 `id` 或 `task_id`。
* 参考视频字段支持 `video`、`video_url` 和 `input_video`。
* 参考视频支持公网 MP4 URL 或 `data:video/mp4;base64,...`。
* 参考视频最大 15MB。
* 不需要参考视频时，优先使用 `omni-fast`。

## 方法与路径

```http theme={null}
POST /v1/videos
```

## 请求示例

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://www.token-nova.com/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "omni-fast-v2v",
      "prompt": "Edit the attached video into a visibly new version while preserving the original camera path, timing, subject motion, and shot continuity. Add a rainy cinematic night look with neon reflections. Output a newly generated video, not the uploaded source clip or its preview.",
      "video": "https://example.com/source.mp4",
      "seconds": "8",
      "aspect_ratio": "16:9",
      "resolution": "720p"
    }'
  ```

  ```bash video_url 别名 cURL theme={null}
  curl -X POST https://www.token-nova.com/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "omni-fast-v2v",
      "prompt": "Extend this clip into a new cinematic shot with the same camera path.",
      "video_url": "https://example.com/source.mp4",
      "seconds": "8",
      "aspect_ratio": "16:9",
      "resolution": "720p"
    }'
  ```

  ```bash input_video 别名 cURL theme={null}
  curl -X POST https://www.token-nova.com/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "omni-fast-v2v",
      "prompt": "Regenerate the attached clip with brighter lighting and smoother motion.",
      "input_video": "https://example.com/source.mp4",
      "seconds": "8",
      "aspect_ratio": "16:9",
      "resolution": "720p"
    }'
  ```

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

  resp = requests.post(
      "https://www.token-nova.com/v1/videos",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      json={
          "model": "omni-fast-v2v",
          "prompt": "Edit the attached video into a visibly new version while preserving the original camera path. Output a newly generated video, not the uploaded source clip.",
          "video": "https://example.com/source.mp4",
          "seconds": "8",
          "aspect_ratio": "16:9",
          "resolution": "720p",
      },
      timeout=120,
  )
  print(resp.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://www.token-nova.com/v1/videos", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "omni-fast-v2v",
      prompt:
        "Edit the attached video into a visibly new version while preserving the original camera path. Output a newly generated video, not the uploaded source clip.",
      video: "https://example.com/source.mp4",
      seconds: "8",
      aspect_ratio: "16:9",
      resolution: "720p",
    }),
  });

  console.log(await response.json());
  ```

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

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

  func main() {
  	payload := map[string]any{
  		"model":        "omni-fast-v2v",
  		"prompt":       "Edit the attached video into a visibly new version while preserving the original camera path. Output a newly generated video, not the uploaded source clip.",
  		"video":        "https://example.com/source.mp4",
  		"seconds":      "8",
  		"aspect_ratio": "16:9",
  		"resolution":   "720p",
  	}
  	body, _ := json.Marshal(payload)

  	req, _ := http.NewRequest("POST", "https://www.token-nova.com/v1/videos", bytes.NewReader(body))
  	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
  	req.Header.Set("Content-Type", "application/json")

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

  	respBody, _ := io.ReadAll(resp.Body)
  	fmt.Println(string(respBody))
  }
  ```

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

  public class Main {
      public static void main(String[] args) throws Exception {
          String json = """
          {
            "model": "omni-fast-v2v",
            "prompt": "Edit the attached video into a visibly new version while preserving the original camera path. Output a newly generated video, not the uploaded source clip.",
            "video": "https://example.com/source.mp4",
            "seconds": "8",
            "aspect_ratio": "16:9",
            "resolution": "720p"
          }
          """;

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://www.token-nova.com/v1/videos"))
              .header("Authorization", "Bearer YOUR_API_KEY")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(json))
              .build();

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

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

  ```php PHP theme={null}
  <?php
  $payload = [
      'model' => 'omni-fast-v2v',
      'prompt' => 'Edit the attached video into a visibly new version while preserving the original camera path. Output a newly generated video, not the uploaded source clip.',
      'video' => 'https://example.com/source.mp4',
      'seconds' => '8',
      'aspect_ratio' => '16:9',
      'resolution' => '720p',
  ];

  $ch = curl_init('https://www.token-nova.com/v1/videos');
  curl_setopt_array($ch, [
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer YOUR_API_KEY',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
      CURLOPT_RETURNTRANSFER => true,
  ]);

  $response = curl_exec($ch);
  curl_close($ch);
  echo $response;
  ```
</RequestExample>

## 响应示例

<ResponseExample>
  ```json 200 - 提交成功 theme={null}
  {
    "id": "video_abc123",
    "task_id": "video_abc123",
    "object": "video",
    "model": "omni-fast-v2v",
    "status": "queued",
    "progress": 0,
    "created_at": 1735689600,
    "video_url": ""
  }
  ```

  ```json 200 - 任务查询成功 theme={null}
  {
    "id": "video_abc123",
    "task_id": "video_abc123",
    "object": "video",
    "model": "omni-fast-v2v",
    "status": "completed",
    "progress": 100,
    "created_at": 1735689600,
    "completed_at": 1735689900,
    "video_url": "https://example.com/results/omni-fast-v2v.mp4"
  }
  ```

  ```json 200 - 任务失败 theme={null}
  {
    "id": "video_abc123",
    "task_id": "video_abc123",
    "object": "video",
    "model": "omni-fast-v2v",
    "status": "failed",
    "progress": 100,
    "error": {
      "message": "upstream task failed",
      "code": "task_failed"
    }
  }
  ```

  ```json 400 - 参数错误 theme={null}
  {
    "error": {
      "message": "video is required for V2V generation",
      "type": "invalid_request_error",
      "param": "video",
      "code": "invalid_request_error"
    }
  }
  ```

  ```json 401 - 认证失败 theme={null}
  {
    "error": {
      "message": "invalid token",
      "type": "invalid_request_error",
      "code": "invalid_api_key"
    }
  }
  ```

  ```json 402 - 额度不足 theme={null}
  {
    "error": {
      "message": "insufficient quota",
      "type": "insufficient_quota",
      "code": "insufficient_quota"
    }
  }
  ```

  ```json 413 - 请求体过大 theme={null}
  {
    "error": {
      "message": "request body too large",
      "type": "invalid_request_error",
      "code": "request_body_too_large"
    }
  }
  ```

  ```json 429 - 请求过多 theme={null}
  {
    "error": {
      "message": "rate limit exceeded",
      "type": "rate_limit_error",
      "code": "rate_limit_exceeded"
    }
  }
  ```

  ```json 500 - 服务端错误 theme={null}
  {
    "error": {
      "message": "internal server error",
      "type": "server_error",
      "code": "server_error"
    }
  }
  ```
</ResponseExample>

## 认证

使用 Bearer Token 鉴权：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

所有请求示例都需要携带 `Authorization` Header。JSON 请求还需要携带：

```http theme={null}
Content-Type: application/json
```

## Body

<ParamField body="model" type="string" required>
  固定传 `omni-fast-v2v`。示例：`"omni-fast-v2v"`。
</ParamField>

<ParamField body="prompt" type="string" required>
  视频编辑或生成提示词。建议说明保留哪些运动、镜头或主体，并明确要求输出新视频。示例：`"Edit the attached video into a visibly new version"`。
</ParamField>

<ParamField body="video" type="string">
  参考视频。支持公网 MP4 URL 或 `data:video/mp4;base64,...`。与 `video_url`、`input_video` 任选其一。示例：`"https://example.com/source.mp4"`。
</ParamField>

<ParamField body="video_url" type="string">
  `video` 的兼容字段。未传 `video` 时可使用。示例：`"https://example.com/source.mp4"`。
</ParamField>

<ParamField body="input_video" type="string">
  `video` 的兼容字段。未传 `video` 和 `video_url` 时可使用。示例：`"https://example.com/source.mp4"`。
</ParamField>

<ParamField body="seconds" type="string">
  输出时长。建议传字符串；推荐范围为 `4` 到 `30` 秒。示例：`"8"`。
</ParamField>

<ParamField body="aspect_ratio" type="string">
  画面比例。示例值：`"16:9"`、`"9:16"`。
</ParamField>

<ParamField body="resolution" type="string">
  分辨率字段。示例值：`"720p"`、`"1080p"`、`"2k"`、`"4k"`。
</ParamField>

<ParamField body="first_image_url" type="string">
  兼容 `omni-fast` 的首帧图字段。没有参考视频时，建议直接使用 `omni-fast`。示例：`"https://example.com/first-frame.jpg"`。
</ParamField>

<ParamField body="images" type="array<string>">
  兼容 `omni-fast` 的多参考图字段，最多 5 张。没有参考视频时，建议直接使用 `omni-fast`。
</ParamField>

## Response

<ResponseField name="id" type="string">
  视频任务 ID。后续可用于 `GET /v1/videos/{task_id}` 查询。
</ResponseField>

<ResponseField name="task_id" type="string">
  视频任务 ID 的兼容字段。通常与 `id` 相同。
</ResponseField>

<ResponseField name="object" type="string">
  对象类型，通常为 `video`。
</ResponseField>

<ResponseField name="model" type="string">
  本次任务使用的模型，例如 `omni-fast-v2v`。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态。常见值为 `queued`、`in_progress`、`completed`、`failed`。
</ResponseField>

<ResponseField name="progress" type="number">
  任务进度，常见范围为 `0` 到 `100`。
</ResponseField>

<ResponseField name="video_url" type="string">
  完成后的视频地址。
</ResponseField>

<ResponseField name="error" type="object">
  任务失败或接口错误时返回的错误对象，通常包含 `message` 和 `code`。
</ResponseField>

## 使用场景

### 公网 MP4 参考视频

```json theme={null}
{
  "model": "omni-fast-v2v",
  "prompt": "Extend this clip into a new cinematic shot with the same camera path.",
  "video": "https://example.com/source.mp4",
  "seconds": "8",
  "aspect_ratio": "16:9",
  "resolution": "720p"
}
```

### 本地 MP4 转 data URI

```python theme={null}
import base64
from pathlib import Path

source = Path("source.mp4")
if source.stat().st_size > 15 * 1024 * 1024:
    raise ValueError("参考视频最大 15MB")

video = "data:video/mp4;base64," + base64.b64encode(source.read_bytes()).decode("ascii")
```

### 使用 `input_video` 别名

```json theme={null}
{
  "model": "omni-fast-v2v",
  "prompt": "Regenerate the attached clip with brighter lighting and smoother motion.",
  "input_video": "https://example.com/source.mp4",
  "seconds": "8",
  "aspect_ratio": "16:9",
  "resolution": "720p"
}
```

## 注意事项

* `omni-fast` 不支持参考视频；V2V 必须使用 `omni-fast-v2v`。
* 参考视频最大 15MB，过大时建议先压缩或转为公网 URL。
* `video`、`video_url`、`input_video` 是同一类参考视频输入，推荐优先使用 `video`。
* 对于 `data:video/mp4;base64,...`，实际请求体会变大，请预留网络超时时间。
* 完成后从返回的 `video_url` 获取生成的 MP4。

## 相关接口

* [omni-fast](./omni-fast)
* [Omni 视频模型概览](./overview)
* [OpenAI 视频兼容接口](/zh/videos/openai-videos)
* [任务状态接口](/zh/tasks/task-status)
