API 參考文件
點數
API 使用你的 SciFig 點數:網站、API 和 MCP 共用一個餘額。
讀取餘額#
GET /credits(權限範圍 figures:read)回傳餘額、執行中任務預留的點數、方案及其任務限制:
{
"balance": 2950,
"reserved": 100,
"granted_scopes": ["figures:read", "figures:generate"],
"plan": "plus",
"plan_level": 2,
"limits": { "concurrent_tasks": 5, "tasks_per_hour": 200 },
"top_up_url": "https://scifig.ai/pricing?utm_source=api"
}plan為free、starter、plus或pro。點數包餘額大於零的帳戶,在餘額耗盡前按pro處理。- 所有方案的
tasks_per_hour均為 200;concurrent_tasks取決於方案。 - 直接向 API 傳送的請求,其
top_up_url攜帶utm_source=api;透過 MCP 伺服器發出的請求攜帶utm_source=mcp。 granted_scopes列出當前憑證的權限:figures:read,以及獲准時的figures:generate。
GET /pricing 無需驗證即可回傳所有價格;這些頁面的價格取自同一張表。沒有單獨的 API 方案:可在價格頁面購買點數或訂閱。
預留點數生命週期#
- 建立任務時原子性地預留其費用,兩個請求不會消耗同一筆點數。
- 點數不足時,回傳
402 INSUFFICIENT_CREDITS和details.top_up_url:不預留點數,也不執行任務。被拒絕的請求以包含該錯誤的失敗任務保留在GET /jobs中,重放其金鑰會回傳相同響應。 - 成功任務僅扣除一次預留點數;失敗或取消任務全額返還。內部重試不會再次預留,重放
Idempotency-Key會複用原預留記錄。 - 每個任務報告從賬本讀取的
credits.reserved、credits.charged和credits.refunded。 - 點數消耗順序與網站相同:先使用最早到期的點數,最後使用永不過期的點數包點數。
cURL#
curl https://scifig.ai/api/v1/credits \
-H "Authorization: Bearer $SCIFIG_API_KEY"JavaScript#
const response = await fetch('https://scifig.ai/api/v1/credits', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
},
});
const result = await response.json();
console.log(response.status, result);Python#
import os
import requests
headers = {
"Authorization": f"Bearer {os.environ['SCIFIG_API_KEY']}",
}
response = requests.get(
"https://scifig.ai/api/v1/credits",
headers=headers,
timeout=60,
)
print(response.status_code, response.json())