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

# Video Upscaler API：提升单个视频的分辨率

> APIXO 视频升级 API 用于增强单视频分辨率：升级剪辑，同时保留运动和细节质量。

## 概览

Video Upscaler 是异步视频到视频 API，用于将一个源视频增强到更高的目标分辨率。计费基于目标分辨率和计费视频时长。

| 功能 | 值 |
| - | - |
| 模型 ID | `video-upscaler` |
| 模式 | `video-to-video` |
| 输入视频 | 恰好 1 个公开视频 URL |
| 公开的计费分辨率层级 | `720p`, `1080p`, `2k`, `4k` |
| 最低计费时长 | 最低 3 秒，输入视频时长向上取整到整秒 |
| 计费 | 每秒，按输出分辨率 |

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/video-upscaler` | 提交视频放大任务 |
| `GET` | `/statusTask/video-upscaler?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

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

提交任务时，还需要设置以下请求头：

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

## 异步请求示例

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/video-upscaler" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "video-to-video",
      "video_urls": [
        "https://example.com/input.mp4"
      ],
      "resolution": "2k"
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/video-upscaler?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/upscaled-video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 请求体

```json theme={null}
{
  "request_type": "async",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "video-to-video",
    "video_urls": [
      "https://example.com/input.mp4"
    ],
    "resolution": "4k"
  }
}
```

## 参数

**request\_type** `string` *required* (default: async)

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当`request_type`为`callback`时需要。必须是可以接收最终任务负载的回调URL。请参阅 [Webhooks](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

Video Upscaler 的输入参数。

**属性**

**mode** `string` (default: video-to-video)

升级模式。唯一支持的公共值是 `video-to-video`。如果省略，则后端默认为 `video-to-video`。

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

源视频 URL。必须恰好包含 1 个非空公共 MP4、MOV 或 WEBM 视频 URL。输入视频不得超过 600 秒。

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

目标分辨率层。公共计费值：`720p`、`1080p`、`2k`、`4k`。值不区分大小写。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/video-upscaler` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

JSON 字符串，包含放大视频的 URL，位于 `resultUrls` 字段中。当 `state` 为 `success` 时出现。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理耗时，以毫秒为单位。有计时数据时返回。

## Webhook 回调模式

如果希望服务端自动收到最终结果，可以使用回调模式，无需轮询。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/video-upscaler" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "video-to-video",
      "video_urls": [
        "https://example.com/input.mp4"
      ],
      "resolution": "1080p"
    }
  }'
```

Webhook 接收要求和重试规则见 [Webhook 文档](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

Video Upscaler按目标分辨率和输入视频时长计费。输入持续时间向上舍入到下一整秒，最小费用为 **3 秒**。短于 3 秒的视频将被接受并按 3 秒计费。最大输入持续时间为 600 秒。

| 分辨率 | APIXO 价格 |
| - | - |
| `720p` | `$0.012 / second` |
| `1080p` | `$0.018 / second` |
| `2k` | `$0.024 / second` |
| `4k` | `$0.032 / second` |

计费行为：

```text theme={null}
billable_seconds = max(3, ceil(actual_input_video_seconds))
total_price = billable_seconds * unit_price_for_resolution
```

例如，一个 3.2 秒的输入在 `1080p` 分辨率下被计费为 4 秒：`4 × $0.018 = $0.072`。一个 3.0004 秒的输入也被计费为 4 秒。

有关当前 APIXO 价格，请参阅 [API 定价](https://apixo.ai/pricing/api)。

## 延迟与轮询

Video Upscaler 任务是异步的。实际延迟因源视频持续时间、文件下载速度、目标分辨率和队列负载而异。

| 使用案例 | 建议首次查询时间 | 轮询间隔 |
| - | - | - |
| 短视频 | 任务创建 30 秒后 | 10s-20s |
| 更长或更高分辨率的视频 | 优先使用回调模式 | 如果轮询，请使用 20s 或更长时间 |

> [!TIP]
>
> 对于制作队列或较长的视频，请使用回调模式以避免频繁轮询。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、模式、视频 URL 形状或分辨率无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `404` | 未找到任务 | 验证 `taskId` 和模型 ID |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误或未知任务失败 | 逐步延长间隔后重试 |
| `502` | 模型服务错误 | 逐步延长间隔后重试 |
| `504` | 模型服务超时 | 重试；耗时较长的任务可改用回调模式 |

### 请求验证

| 条件 | 后端行为 |
| - | - |
| 缺少 `input` | 返回`The required parameter {{input}} is missing.` |
| `mode` 无效 | 返回`Invalid mode type. Supported: video-to-video` |
| 缺少 `video_urls` | 返回`The required parameter {{video_urls}} is missing.` |
| `video_urls` 不是数组 | 返回`The parameter {{video_urls}} must be Array type.` |
| `video_urls`长度不是1 | 返回`The parameter {{video_urls}} must contain exactly 1 video.` |
| `video_urls[0]` 不是字符串 | 返回`The parameter {{video_urls}} Array elements must be String type.` |
| `video_urls[0]` 为空 | 返回`The parameter {{video_urls}} cannot contain empty string.` |
| 公开的 `resolution` 无效 | 使用公共计费等级之一：`720p`、`1080p`、`2k`、`4k`。 |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/video-upscaler.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `video_urls`。请保留用户指定的文件顺序。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [视频模型](https://apixo.ai/docs/zh/models/video)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [API定价](https://apixo.ai/pricing/api)


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