图片放大器
图片放大器接收一张原图,增强并输出 2K、4K 或 8K 图片。模型使用平台标准异步图片任务接口,支持任务查询、完成/失败回调、失败自动退款以及平台长期托管的结果 URL。
模型
| 模型名称 | 输入 | 输出 |
|---|---|---|
image-upscaler | 一个公网图片 URL | 一个增强后的图片 URL |
定价
每次运行固定收取 4 积分($0.02)。目标分辨率和输出格式不影响价格,已有的账户专属定价倍率仍然生效。
创建任务
curl -X POST https://api.aivideoapi.ai/v1/images/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "image-upscaler",
"callback_url": "https://your-server.com/webhook",
"input": {
"image_urls": ["https://example.com/source-image.jpg"],
"target_resolution": "4k",
"output_format": "jpeg"
}
}'
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定为 image-upscaler |
input | object | 是 | 图片放大参数 |
callback_url | string | 否 | 任务完成或失败时接收通知的 HTTP(S) 地址 |
Input 参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
image_urls | string[] | 是 | 必须且只能包含一个公网 HTTP(S) 原图 URL |
target_resolution | string | 否 | 2k、4k(默认)或 8k |
output_format | string | 否 | jpeg(默认)、png 或 webp |
不支持 enable_base64_output 和 enable_sync_mode 字段。平台始终通过异步任务返回图片 URL。
创建响应
{
"code": 200,
"msg": "success",
"data": {
"taskId": "397ce9f2-c04e-4244-ac33-3af19a7cc297"
}
}
任务受理时预扣 4 个基础积分;任务失败会自动退还积分。
查询任务
curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
-H "Authorization: Bearer sk-your-api-key"
任务状态从 pending 变为 processing,最终进入 completed 或 failed。
已完成
{
"id": "397ce9f2-c04e-4244-ac33-3af19a7cc297",
"status": "completed",
"model": "image-upscaler",
"created_at": 1785900000,
"completed_at": 1785900015,
"output": {
"urls": [
"https://file.aivideoapi.ai/images/2026/08/05/upscaled.webp"
]
}
}
已失败
{
"id": "57c8772c-f834-46f3-9b7d-81f92e104050",
"status": "failed",
"model": "image-upscaler",
"created_at": 1785900000,
"error": {
"code": "upstream_error",
"message": "Image upscaling failed"
}
}
回调(Callback)
创建任务时传入 callback_url。平台会在结果转存到平台存储后,或任务失败后,向该地址发送 POST 请求。回调正文与任务查询响应一致。
| Header | 说明 |
|---|---|
Content-Type | application/json |
X-Event | task.completed 或 task.failed |
X-Task-Id | 平台任务 ID |
X-Timestamp | Unix 秒级时间戳 |
非 2xx 响应或请求超时最多尝试 3 次:立即、3 分钟后和 10 分钟后。回调未送达时仍可通过 GET /v1/tasks/{taskId} 查询最终状态。
常见错误码
请求失败时,API 返回 JSON 格式的错误响应:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
错误码一览
| HTTP 状态码 | 错误码 | 类型 | 说明 |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | 缺少必填参数或参数无效 |
| 401 | invalid_api_key | authentication_error | API Key 无效、已禁用或已删除 |
| 402 | insufficient_credits | billing_error | 积分余额不足,请充值 |
| 403 | ip_not_allowed | permission_error | 请求 IP 不在 Key 的白名单中 |
| 404 | model_not_found | invalid_request_error | 模型不存在或已停用 |
| 404 | task_not_found | invalid_request_error | 任务 ID 不存在 |
| 429 | rate_limit_exceeded | rate_limit_error | 请求过于频繁,请降低频率 |
| 429 | spend_limit_exceeded | billing_error | 达到 Key 的消费限额(每小时/每天/总量) |
| 500 | internal_error | api_error | 服务器内部错误 |
| 503 | upstream_error | upstream_error | 上游 AI 服务返回错误 |
常见场景
invalid_request (400)
缺少必填字段或参数格式错误时返回。
{
"error": {
"code": "invalid_request",
"message": "'model' is required.",
"type": "invalid_request_error"
}
}
insufficient_credits (402)
积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。
invalid_api_key (401)
可能原因:
- Key 不以
sk-开头 - Key 已被禁用或删除
- 用户账户已被封禁
upstream_error (503)
上游 AI 服务返回错误,可能原因:
- 输入内容包含敏感或违规信息
- 上游服务暂时不可用
- 请求参数不被上游支持
因上游错误导致任务失败时,预扣积分会自动退还。