SciFig

API 參考文件

圖片產生

根據文字提示詞產生科學插圖,也可透過參考圖片引導產生。

JSON 請求體#

POST /images/generations 接受 JSON 請求體。所需權限範圍:figures:generate。

欄位類型必填預設值規則
promptstring是—3–20,000 個字元
aspect_ratiostring否1:11:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
qualitystring否standardstandard、advanced 或 premium;決定模型和價格
stylestring否—flat, 2-5d, line-art, hand-drawn, scientific, line, 3d, editorial, sketch, watercolor, auto
palette字串或陣列否—配色預設 ID,或 1–4 個 #RRGGBB 顏色值
reference_file_idsarray否—1–3 個圖片 file_id(上傳檔案或此前的輸出)

未知欄位會被拒絕,回傳 400 INVALID_REQUEST;details.issues 列出各項問題。部分模型、參考圖片和寬高比需要付費方案,否則回傳 403 PLAN_REQUIRED。

點數#

quality點數
standard50
advanced75
premium100

建立任務時預留點數,成功後僅扣除一次,失敗時全額返還。響應回傳任務;欄位和狀態請參閱任務與有限等待,錯誤請參閱錯誤。

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())