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'
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']}"
任務排隊或處理中時回傳 202;若在等待期間內進入終態則回傳 200。回應結構與輪詢
流程請見任務。

API 文件