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

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

# 视频放大

> 在 Venice 异步视频队列上使用 topaz-video-upscale 模型增强视频分辨率与质量，支持 1 倍、2 倍或 4 倍放大。

视频放大让您可以将现有视频提升至更高分辨率，同时改善视觉质量。**Topaz Video Upscale** 模型使用 AI 驱动的放大技术将分辨率提升 2 倍或 4 倍，或在原分辨率（1 倍）上进行质量增强。

## 工作原理

视频放大使用与视频生成相同的异步队列系统：

1. **排队** —— 使用 `topaz-video-upscale` 模型将视频提交至 `/video/queue`
2. **轮询** —— 使用 `model` 和返回的 `queue_id` 调用 `/video/retrieve`。作业运行期间，它返回包含 `"status": "PROCESSING"` 的 JSON。作业完成后，响应体就是放大后的 MP4（`Content-Type: video/mp4`），因此请将其保存为文件。不会提供输出 URL。
3. **清理（可选）** —— 保存文件后，调用 `/video/complete` 删除存储的输出

服务器会自动从上传的文件中检测输入视频的时长、帧率和尺寸。您无需提供这些值 —— 计费根据实际视频元数据计算。

## 放大倍数

| `upscale_factor` | 输出分辨率 | 用例 |
| - | - | - |
| `1` | 与输入相同 | 仅质量增强（降噪、锐化） |
| `2`（默认） | 输入尺寸的 2 倍 | 标准放大 —— 720p 输入变为 1440p 输出 |
| `4` | 输入尺寸的 4 倍 | 最大放大 —— 480p 输入变为 1920p 输出 |

> [!NOTE]
>
> 对于放大模型，`upscale_factor` 参数取代了 `resolution`。传入 `resolution` 将返回错误。这是因为输出分辨率取决于输入视频的尺寸 —— 对 720p 视频进行 `2x` 放大与对 480p 视频进行 `2x` 放大会产生不同的结果。

## 支持的输入格式

* **格式**：MP4、MOV、WebM
* **输入方式**：HTTPS URL 或 `data:video/...;base64,...` data URL
* **最长时长**：300 秒（5 分钟）

## API 使用

### 排队一个放大作业

```bash cURL theme={"system"}
curl https://api.venice.ai/api/v1/video/queue \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "topaz-video-upscale",
    "video_url": "https://example.com/input-video.mp4",
    "upscale_factor": 2
  }'
```

```python Python theme={"system"}
import requests

response = requests.post(
    "https://api.venice.ai/api/v1/video/queue",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model": "topaz-video-upscale",
        "video_url": "https://example.com/input-video.mp4",
        "upscale_factor": 2,
    },
)

data = response.json()
queue_id = data["queue_id"]
download_url = data.get("download_url")
print(f"Queued: {queue_id}")
```

```javascript Node.js theme={"system"}
const response = await fetch("https://api.venice.ai/api/v1/video/queue", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "topaz-video-upscale",
    video_url: "https://example.com/input-video.mp4",
    upscale_factor: 2,
  }),
});

const { queue_id, download_url } = await response.json();
console.log(`Queued: ${queue_id}`);
```

响应包含用于跟踪作业的 `queue_id`：

```json theme={"system"}
{
  "model": "topaz-video-upscale",
  "queue_id": "abc123-def456-..."
}
```

### 轮询并保存结果

```bash cURL theme={"system"}
curl https://api.venice.ai/api/v1/video/retrieve \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "topaz-video-upscale", "queue_id": "abc123-def456-..."}' \
  -o upscaled.mp4 \
  -w '%{content_type}\n'
```

```python Python theme={"system"}
import time

while True:
    result = requests.post(
        "https://api.venice.ai/api/v1/video/retrieve",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={"model": "topaz-video-upscale", "queue_id": queue_id},
    )
    result.raise_for_status()

    if "video/mp4" in result.headers.get("Content-Type", ""):
        with open("upscaled.mp4", "wb") as f:
            f.write(result.content)
        break

    if result.json().get("status") == "COMPLETED" and download_url:
        with open("upscaled.mp4", "wb") as f:
            f.write(requests.get(download_url).content)
        break

    time.sleep(5)

print("Saved upscaled.mp4")
```

```javascript Node.js theme={"system"}
import { writeFile } from "node:fs/promises";

const poll = async (queueId, downloadUrl) => {
  while (true) {
    const res = await fetch("https://api.venice.ai/api/v1/video/retrieve", {
      method: "POST",
      headers: {
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ model: "topaz-video-upscale", queue_id: queueId }),
    });
    if (!res.ok) {
      throw new Error(`${res.status}: ${await res.text()}`);
    }

    if (res.headers.get("Content-Type")?.includes("video/mp4")) {
      await writeFile("upscaled.mp4", Buffer.from(await res.arrayBuffer()));
      return;
    }

    const data = await res.json();
    if (data.status === "COMPLETED" && downloadUrl) {
      const video = await fetch(downloadUrl);
      await writeFile("upscaled.mp4", Buffer.from(await video.arrayBuffer()));
      return;
    }

    await new Promise((r) => setTimeout(r, 5000));
  }
};

await poll(queue_id, download_url);
console.log("Saved upscaled.mp4");
```

放大完成后的结果就是响应体本身，而不是某个 JSON 字段，因此请在解析之前检查 `Content-Type`。cURL 示例会打印每个响应的内容类型：重复执行，直到它打印出 `video/mp4`，此时 `upscaled.mp4` 中保存的就是视频。如果排队响应中包含 `download_url`，retrieve 会改为返回包含 `"status": "COMPLETED"` 的 JSON，您需要从该 URL 下载文件。请参阅[私有下载链接](https://docs.venice.ai/zh/guides/media/video-generation.md#私有下载链接)。

### 清理（可选）

保存 MP4 之后，您可以调用 `/video/complete` 删除存储的输出。它不会返回视频或 URL。

```bash theme={"system"}
curl https://api.venice.ai/api/v1/video/complete \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "topaz-video-upscale", "queue_id": "abc123-def456-..."}'
```

***

## API 参数

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `model` | string | **是** | 必须为 `topaz-video-upscale` |
| `video_url` | string | **是** | 输入视频 URL 或 data URL。支持的格式：MP4、MOV、WebM。 |
| `upscale_factor` | number | 否 | `1`、`2`（默认）或 `4`。控制放大倍数。 |

### 放大模型不使用的参数

以下参数对 `topaz-video-upscale` **不接受**，如果提供将返回错误：

| 字段 | 原因 |
| - | - |
| `resolution` | 改用 `upscale_factor`。输出分辨率取决于输入尺寸。 |
| `prompt` | 放大不使用文本 prompt。会自动设置为空字符串。 |

`duration` 参数也会被忽略 —— 服务器直接从视频文件检测时长以确保计费准确。

***

## 定价

定价基于**时长**、**输出分辨率等级**和**帧率**。输出分辨率等级由输入视频的高度乘以放大倍数决定。

### 输出分辨率等级

| 等级 | 输出高度 | 每秒费率 |
| - | - | - |
| 720p | ≤ 720px | \~\$0.013 |
| 1080p | 721–1080px | \~\$0.025 |
| 4K | > 1080px | \~\$0.10 |

> [!NOTE]
>
> 帧率超过 48fps 的视频费用为每秒费率的 2 倍。

### 定价示例

| 输入 | 放大倍数 | 输出 | 时长 | 预估费用 |
| - | - | - | - | - |
| 480p, 30fps | 2x | 960p（1080p 等级） | 10s | \~\$0.25 |
| 720p, 30fps | 2x | 1440p（4K 等级） | 10s | \~\$1.00 |
| 1080p, 30fps | 2x | 2160p（4K 等级） | 30s | \~\$3.00 |
| 360p, 24fps | 4x | 1440p（4K 等级） | 10s | \~\$1.00 |
| 480p, 60fps | 2x | 960p（1080p 等级） | 10s | \~\$0.50 |

使用 [Video Quote API](https://docs.venice.ai/api-reference/endpoint/video/quote.md) 在提交作业前获得准确定价。

### 获取报价

```bash theme={"system"}
curl https://api.venice.ai/api/v1/video/quote \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "topaz-video-upscale",
    "video_url": "https://example.com/input.mp4",
    "upscale_factor": 2
  }'
```

对于放大模型的报价，`video_url` 是**必填**的 —— 报价端点会获取文件并从字节中检测时长、FPS 和高度，因此无需另行提供这些信息。省略它会返回 `400` 及 *"video\_url is required for quotes on this model"*。

放大模型的报价需要 API 密钥。不带 API 密钥的请求会返回 `403`。

向 `/video/quote` 传入与您将发送到 `/video/queue` 相同的 `upscale_factor`（`1`、`2` 或 `4`），以使报价与作业一致。对于放大模型，报价端点也接受 `resolution`（`"2x"` 或 `"4x"`）作为已弃用的别名；如果两者同时发送，以 `upscale_factor` 为准。

***

## 故障排查

| 问题 | 可能原因 | 解决方法 |
| - | - | - |
| `"Use upscale_factor instead of resolution"` | 请求中传入了 `resolution` | 移除 `resolution`，改用 `upscale_factor` |
| 费用高于预期 | 输入视频分辨率或 FPS 较高 | 使用 quote 端点检查输入尺寸。720p+ 输入加 2x 放大会落入 4K 定价等级。 |
| 作业耗时较长 | 视频较大或较长 | 放大是计算密集型操作。视频越长、放大倍数越高，耗时按比例增加。 |
| `"Insufficient balance"` | 账户余额不足 | 在 [venice.ai/settings/api](https://venice.ai/settings/api?utm_source=venice-api-documentation) 充值 |


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