图片处理 API
已接入图片矢量化和九种图片放大接口。所有接口由本站统一鉴权、转发、按次扣费。
POST
multipart/form-data / JSON
国内稳定线路
按次扣费
渠道可改价
调用时必须使用已开通图片处理权限的站内 API Key。成功请求会按图片处理渠道里对应工具的按次价格扣费。
接口列表
| 功能 | Endpoint | 计费 | 说明 |
|---|---|---|---|
| 图片矢量化 | POST /image-tools/vectorize | 读取中... | 位图转 SVG,平均 10-20 秒。 |
| 图片放大 | POST /image-tools/upscale | 读取中... | Real-ESRGAN,平均 8-10 秒。 |
| 图片放大 V2 | POST /image-tools/upscale-v2 | 读取中... | GFPGAN,平均 8-10 秒。 |
| 图片放大 V3 | POST /image-tools/upscale-v3 | 读取中... | ESRGAN,平均 8-10 秒。 |
| 图片放大 V4(快速放大v4) | POST /image-tools/upscale-v4 | 读取中... | GigaGAN,平均 8-10 秒。 |
| 图片放大 V5 | POST /image-tools/upscale-v5 | 读取中... | SeedVR,JSON 请求,平均 8-10 秒。 |
| 图片放大 V6 | POST /image-tools/upscale-v6 | 读取中... | JSON 请求,平均 15-30 秒。 |
| 快速图片放大 | POST /image-tools/upscale-fast | 读取中... | JSON 请求,平均 15-30 秒。 |
| 超级图片放大 | POST /image-tools/super-upscale | 读取中... | AI 补充细节,适合低清图片高清化,平均 10-30 秒。 |
| 查询超级图片放大任务 | GET /image-tools/tasks/{task_id} | 不单独扣费 | 使用提交接口返回的任务 ID 查询任务状态和输出结果;兼容 /image-tools/super-upscale/tasks/{task_id}/fetch。 |
| 超级图片放大 V2 | POST /image-tools/super-upscale-v2 | 读取中... | JSON 请求,AI 补充细节,适合低清图片高清化,平均 10-30 秒。 |
请求参数
通用 Header
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
Authorization | Header | 是 | Bearer YOUR_API_KEY,使用已开通图片处理权限的本站 API Key。 |
图片矢量化
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
file | Form Data | 是 | 要矢量化的图片文件,建议 PNG/JPG。 |
response_format | Form Data | 否 | url 或 b64_json,建议传 url。 |
Upscale
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
image | Form Data | 是 | 要放大的图片文件。 |
scale | Form Data | 否 | 0-10,默认 4。 |
face_enhance | Form Data | 否 | 人脸增强,默认开。 |
Upscale-V2
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
img | Form Data | 是 | 要放大的图片文件。 |
scale | Form Data | 否 | 0-10,默认 4。 |
Upscale-V3
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
image_url | Form Data | 是 | 上传图片文件或图片 URL 字符串,字段名沿用上游接口。 |
face | Form Data | 是 | 是否包含人脸。 |
scale | Form Data | 是 | 放大倍数,例如 4。 |
Upscale-V4(快速放大v4)
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
image_url | Form Data | 是 | 上传图片文件或图片 URL 字符串。 |
checkpoint | Form Data | 否 | 版本,可传 v1 或 v2,默认建议 v2。 |
upscaling_factor | Form Data | 否 | 放大倍数,只能为 4。 |
Upscale-V5
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
Content-Type | Header | 是 | application/json。 |
image_url | JSON Body | 是 | 图片 URL 字符串。 |
upscale_factor | JSON Body | 是 | 放大倍数,1-4。 |
Upscale-V6
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
Content-Type | Header | 是 | application/json。 |
image_url | JSON Body | 是 | 图片 URL 字符串。 |
scale_factor | JSON Body | 是 | 放大倍数,1-4。 |
快速图片放大
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
Content-Type | Header | 是 | application/json。 |
image_url | JSON Body | 是 | 图片 URL 字符串。 |
scale | JSON Body | 是 | 放大倍数,1-4。 |
超级图片放大
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
image | Form Data | 是 | 要超级放大的图片文件。 |
scale_factor | Form Data | 否 | 放大倍数,默认 2。 |
prompt | Form Data | 否 | 画面提示词,用于引导补充细节。 |
negative_prompt | Form Data | 否 | 不希望出现在画面的提示词。 |
dynamic | Form Data | 否 | HDR 效果,3-9,默认 6。 |
creativity | Form Data | 否 | AI 想象空间,0.3-0.9,默认 0.35。 |
resemblance | Form Data | 否 | 与原图相似度,0.3-1.6,默认 0.6。 |
查询超级图片放大任务
超级图片放大可能先返回 starting。提交响应会包含 status_url、result_url 和 fetch_url,前端按 status_url 轮询即可。
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
task_id | Path | 是 | 提交超级图片放大接口返回的任务 ID。 |
超级图片放大 V2
| 字段 | 位置 | 必填 | 说明 |
|---|---|---|---|
Content-Type | Header | 是 | application/json。 |
model_type | JSON Body | 是 | 模型类型,例如 SDXL。 |
image_url | JSON Body | 是 | 图片 URL 字符串。 |
scale | JSON Body | 是 | 放大倍数,例如 3。 |
creativity | JSON Body | 是 | AI 想象空间,例如 0.2。 |
detail | JSON Body | 是 | 细节强度,例如 2。 |
shape_preservation | JSON Body | 是 | 形状保留强度,例如 0.1。 |
prompt_suffix | JSON Body | 是 | 追加提示词。 |
negative_prompt | JSON Body | 是 | 不希望出现在画面的提示词。 |
guidance_scale | JSON Body | 是 | 提示词引导强度,例如 7.5。 |
num_inference_steps | JSON Body | 是 | 推理步数,例如 20。 |
override_size_limits | JSON Body | 是 | 是否覆盖尺寸限制,布尔值。 |
cURL 示例
# 图片矢量化
curl https://ai.cozesf.cc/image-tools/vectorize \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@image.png" \
-F "response_format=url"
# Upscale
curl https://ai.cozesf.cc/image-tools/upscale \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image=@image.png" \
-F "scale=4" \
-F "face_enhance=true"
# Upscale-V2
curl https://ai.cozesf.cc/image-tools/upscale-v2 \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "img=@image.png" \
-F "scale=4"
# Upscale-V3
curl https://ai.cozesf.cc/image-tools/upscale-v3 \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image_url=@image.png" \
-F "face=true" \
-F "scale=4"
# Upscale-V4(快速放大v4)
curl https://ai.cozesf.cc/image-tools/upscale-v4 \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image_url=@image.png" \
-F "checkpoint=v2" \
-F "upscaling_factor=4"
# Upscale-V5
curl https://ai.cozesf.cc/image-tools/upscale-v5 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_url":"https://example.com/image.png","upscale_factor":4}'
# Upscale-V6
curl https://ai.cozesf.cc/image-tools/upscale-v6 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_url":"https://example.com/image.png","scale_factor":4}'
# 快速图片放大
curl https://ai.cozesf.cc/image-tools/upscale-fast \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_url":"https://example.com/image.png","scale":4}'
# 超级图片放大
curl https://ai.cozesf.cc/image-tools/super-upscale \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image=@image.png" \
-F "scale_factor=2" \
-F "prompt=restore details, clean texture" \
-F "negative_prompt=blur, noise" \
-F "dynamic=6" \
-F "creativity=0.35" \
-F "resemblance=0.6"
# 查询超级图片放大任务
curl https://ai.cozesf.cc/image-tools/tasks/17807270155465 \
-H "Authorization: Bearer YOUR_API_KEY"
# 超级图片放大 V2
curl https://ai.cozesf.cc/image-tools/super-upscale-v2 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_type":"SDXL",
"image_url":"https://example.com/image.png",
"scale":3,
"creativity":0.2,
"detail":2,
"shape_preservation":0.1,
"prompt_suffix":" high quality, highly detailed, high resolution, sharp",
"negative_prompt":"blurry, low resolution, bad, ugly, low quality, pixelated, interpolated, compression artifacts, noisey, grainy",
"guidance_scale":7.5,
"num_inference_steps":20,
"override_size_limits":true
}'
JavaScript 示例
const form = new FormData();
form.append("image", fileInput.files[0]);
form.append("scale", "4");
form.append("face_enhance", "true");
const response = await fetch("https://ai.cozesf.cc/image-tools/upscale", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`
},
body: form
});
const result = await response.json();
console.log(result.output);
成功响应
{
"completed_at": "2026-05-27T00:00:00Z",
"created_at": "2026-05-27T00:00:00Z",
"error": "",
"id": "task-id",
"model": "upscale",
"output": "https://...",
"started_at": "2026-05-27T00:00:00Z",
"status": "succeeded"
}
// Upscale-V3 可能返回:
{
"image": {
"url": "https://...",
"content_type": "image/png",
"file_size": 1040977,
"width": 1024,
"height": 1024
}
}
错误码
| 状态码 | 含义 | 处理方式 |
|---|---|---|
401 | 没有传 Authorization | 补充 Authorization: Bearer YOUR_API_KEY。 |
403 | API Key 未开通图片处理权限 | 在后台创建或切换到图片处理专用 Key。 |
402 | API Key 额度不足 | 给对应 Key 增加额度,或检查分组/渠道价格设置。 |
400 | 上游参数校验失败 | 确认上传了有效图片,并按对应接口传字段名。 |
504 | 上游处理或上传超时 | 压缩图片后重试,或稍后再试。 |
502 | 图片处理服务请求失败 | 稍后重试,或联系管理员检查服务状态。 |