API 文件
影像生成
建立文字生成影像的任務
POST /api/v1/images/generations 依文字描述產生 1 至 4 張影像。所需權限範圍:
images:generate。
JSON 請求主體
| 欄位 | 型別 | 必填 | 預設值 | 規則 |
|---|---|---|---|---|
prompt | string | 是 | — | 去除前後空白後 5–2,000 字元 |
aspect_ratio | string | 否 | 1:1 | 1:1、16:9、9:16、4:3、3:4、3:2、2:3、5:4、4:5、21:9 |
resolution | string | 否 | 2K | 2K 或 4K |
count | integer | 否 | 1 | 1–4 |
未知欄位一律拒絕。公開請求不提供任何能力路由選項。
點數
| 解析度 | 每張點數 |
|---|---|
2K | 5 |
4K | 20 |
預留總量為每張成本乘上 count。點數在任務被受理時以不可分割的方式預留,成功時
結算,進入終態失敗時釋放。
cURL
curl https://sci-draw.com/api/v1/images/generations \
-H 'Authorization: Bearer sd_YOUR_KEY' \
-H 'Idempotency-Key: manuscript-42-panel-a' \
-H 'Prefer: wait=10' \
-H 'Content-Type: application/json' \
-d '{"prompt":"A labeled plant cell diagram","aspect_ratio":"4:3","resolution":"2K","count":1}'JavaScript
const response = await fetch('https://sci-draw.com/api/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SCIDRAW_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt: 'A labeled plant cell diagram' }),
});
const body = await response.json();Python
import os, uuid, requests
response = requests.post(
"https://sci-draw.com/api/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['SCIDRAW_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={"prompt": "A labeled plant cell diagram", "resolution": "2K"},
)
job = response.json()["data"]任務排隊或處理中時回傳 202;若在等待期間內進入終態則回傳 200。回應結構與輪詢
流程請見任務。
輸出尺寸
2K 和 4K 是尺寸等級,不代表固定邊長。下表為實際輸出像素。不支援的比例會在建立任務或預扣點數前回傳 HTTP 400(INVALID_REQUEST)。
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 文件