API 文档
图片编辑
使用自然语言指令编辑上传图片
POST /api/v1/images/edits 使用 multipart/form-data。所需权限:images:edit。
表单字段
| 字段 | 类型 | 必填 | 默认值 | 规则 |
|---|---|---|---|---|
image | file | 是 | — | PNG、JPEG 或 WebP;最大 10 MiB,解码后不超过 4,000 万像素 |
prompt | string | 是 | — | 编辑指令,5–2,000 字符 |
aspect_ratio | string | 否 | 根据源图 | 与生成接口相同的公开比例 |
resolution | string | 否 | 2K | 2K 或 4K |
count | integer | 否 | 1 | 1–4 |
系统会独立校验文件签名,不信任声明的 MIME。无效、超大或不安全图片返回
400 INVALID_REQUEST;超过传输大小限制时 HTTP 状态为 413,公开错误码仍相同。
积分
| 分辨率 | 每个结果积分 |
|---|---|
2K | 10 |
4K | 20 |
cURL
curl https://sci-draw.com/api/v1/images/edits \
-H 'Authorization: Bearer sd_YOUR_KEY' \
-H 'Idempotency-Key: revise-figure-7-v2' \
-F 'image=@figure.png;type=image/png' \
-F 'prompt=Move the legend below the diagram and increase label contrast' \
-F 'resolution=2K' \
-F 'count=1'JavaScript
const form = new FormData();
form.set('image', file);
form.set('prompt', 'Move the legend below the diagram');
const response = await fetch('https://sci-draw.com/api/v1/images/edits', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}`, 'Idempotency-Key': crypto.randomUUID() },
body: form,
});Python
with open("figure.png", "rb") as image:
response = requests.post(
"https://sci-draw.com/api/v1/images/edits",
headers={"Authorization": f"Bearer {api_key}", "Idempotency-Key": str(uuid.uuid4())},
files={"image": ("figure.png", image, "image/png")},
data={"prompt": "Move the legend below the diagram"},
)上传图片只作为私有任务输入,不会出现在任务或日志响应中。重复幂等上传会被丢弃, 已接受的源图在任务进入终态后清理。
输出尺寸
2K 和 4K 是尺寸档位,不代表固定边长。下表为实际输出像素。不支持的比例会在创建任务或预扣积分前返回 HTTP 400(INVALID_REQUEST)。编辑时若不传 aspect_ratio,原图比例须介于 1:3–3:1 且满足所选尺寸档位(4K 至少 600 万像素);否则请明确指定支持的输出比例。
aspect_ratio | 2K | 4K |
|---|---|---|
| 1:1 | 2048×2048 | 2880×2880 |
| 16:9 | 2560×1440 | 3840×2160 |
| 9:16 | 1440×2560 | 2160×3840 |
| 4:3 | 2304×1728 | 3264×2448 |
| 3:4 | 1728×2304 | 2448×3264 |
| 3:2 | 2496×1664 | 3504×2336 |
| 2:3 | 1664×2496 | 2336×3504 |
| 5:4 | 2240×1792 | 3200×2560 |
| 4:5 | 1792×2240 | 2560×3200 |
| 21:9 | 3136×1344 | 3808×1632 |

API 文档