LogoLogoAPI 文件
LogoLogoAPI 文件
首頁
總覽驗證與冪等性影像生成影像編輯影像轉換圖表生成任務與限時等待點數錯誤速率限制與併發API 變更紀錄
API 文件

影像編輯

以自然語言指令編輯上傳的影像

POST /api/v1/images/edits 接受 multipart/form-data。所需權限範圍: images:edit。

表單欄位

欄位型別必填預設值規則
imagefile是—PNG、JPEG 或 WebP;最大 10 MiB,解碼後最多 4,000 萬像素
promptstring是—編輯指令,5–2,000 字元
aspect_ratiostring否依來源影像而定與生成相同的公開比例
resolutionstring否2K2K 或 4K
countinteger否11–4

檔案簽章的檢查獨立於宣告的 MIME 類型。無效、超出大小或不安全的影像會回傳 400 INVALID_REQUEST,或以相同公開錯誤碼回傳 HTTP 413。

點數

解析度每張輸出點數
2K10
4K20

cURL

影像生成

建立文字生成影像的任務

影像轉換

將影像轉為 SVG、PPTX、PNG、PDF 或 TIFF

目錄

表單欄位
點數
cURL
JavaScript
Python
輸出尺寸
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_ratio2K4K
1:12048×20482880×2880
16:92560×14403840×2160
9:161440×25602160×3840
4:32304×17283264×2448
3:41728×23042448×3264
3:22496×16643504×2336
2:31664×24962336×3504
5:42240×17923200×2560
4:51792×22402560×3200
21:93136×13443808×1632