SciFig

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