API 參考文件
圖片產生
根據文字提示詞產生科學插圖,也可透過參考圖片引導產生。
JSON 請求體#
POST /images/generations 接受 JSON 請求體。所需權限範圍:figures:generate。
| 欄位 | 類型 | 必填 | 預設值 | 規則 |
|---|---|---|---|---|
| prompt | string | 是 | — | 3–20,000 個字元 |
| aspect_ratio | string | 否 | 1:1 | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
| quality | string | 否 | standard | standard、advanced 或 premium;決定模型和價格 |
| style | string | 否 | — | flat, 2-5d, line-art, hand-drawn, scientific, line, 3d, editorial, sketch, watercolor, auto |
| palette | 字串或陣列 | 否 | — | 配色預設 ID,或 1–4 個 #RRGGBB 顏色值 |
| reference_file_ids | array | 否 | — | 1–3 個圖片 file_id(上傳檔案或此前的輸出) |
未知欄位會被拒絕,回傳 400 INVALID_REQUEST;details.issues 列出各項問題。部分模型、參考圖片和寬高比需要付費方案,否則回傳 403 PLAN_REQUIRED。
點數#
cURL#
curl -X POST https://scifig.ai/api/v1/images/generations \
-H "Authorization: Bearer $SCIFIG_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Prefer: wait=25" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Schematic of CRISPR-Cas9 gene editing: guide RNA, Cas9, target DNA and the double-strand break, labelled",
"aspect_ratio": "4:3",
"quality": "standard"
}'JavaScript#
const response = await fetch('https://scifig.ai/api/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
Prefer: 'wait=25',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"prompt": "Schematic of CRISPR-Cas9 gene editing: guide RNA, Cas9, target DNA and the double-strand break, labelled",
"aspect_ratio": "4:3",
"quality": "standard"
}),
});
const result = await response.json();
console.log(response.status, result);Python#
import os
import uuid
import requests
headers = {
"Authorization": f"Bearer {os.environ['SCIFIG_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
"Prefer": "wait=25",
}
response = requests.post(
"https://scifig.ai/api/v1/images/generations",
headers=headers,
json={
"prompt": "Schematic of CRISPR-Cas9 gene editing: guide RNA, Cas9, target DNA and the double-strand break, labelled",
"aspect_ratio": "4:3",
"quality": "standard"
},
timeout=60,
)
print(response.status_code, response.json())