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 文件