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}'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 文档