API リファレンス
フローチャートの生成と編集
科学的なフローチャートやワークフロー図を SVG で作成し、追加の指示で変更できます。
JSON 本文#
POST /flowcharts/generations。必要なスコープ:figures:generate。
| フィールド | 型 | 必須 | 既定値 | 規則 |
|---|---|---|---|---|
| prompt | string | はい | — | 1~8,000 文字 |
| aspect_ratio | string | いいえ | auto | auto, 16:9, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 21:9 |
| attachment_file_ids | array | いいえ | — | 用途 flowchart_attachment でアップロードしたファイルを最大 8 個(手順書や原稿など) |
100 クレジット。成功したジョブは、編集可能な文字を含む SVG を 1 件返します。editor_url からウェブサイトの FlowChart 会話で開けます。無料の変換で PNG、PDF、TIFF、PPTX に書き出せます。
添付ファイルは先に POST /files と用途 flowchart_attachment でアップロードします。ウェブサイトのアップロード枠に数えられ、24 時間利用できます。
編集#
JSON {"job": "<flowchart job id>", "instruction": "..."} を伴う POST /flowcharts/edits は、そのジョブのフローチャートを縦横比を保って変更します。instruction は 1~8,000 文字、100 クレジットです。グラフ編集と同じ規則が適用されます。親ジョブが実行中なら再試行可能な 409 REVISION_CONFLICT(PARENT_JOB_RUNNING)、失敗済みなら 400 INVALID_REQUEST(JOB_NOT_SUCCEEDED)を返します。最新バージョンのみ編集可能(409 REVISION_CONFLICT、NOT_LATEST_REVISION)で、一度に 1 件の編集を実行します(EDIT_IN_PROGRESS)。結果はウェブサイトの同じ FlowChart 会話に表示されます。
cURL#
curl -X POST https://scifig.ai/api/v1/flowcharts/generations \
-H "Authorization: Bearer $SCIFIG_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Prefer: wait=25" \
-H "Content-Type: application/json" \
-d '{
"prompt": "CONSORT flow of a randomized trial: 400 assessed, 80 excluded, 320 randomized into two arms of 160, follow-up and analysis",
"aspect_ratio": "4:3"
}'JavaScript#
const response = await fetch('https://scifig.ai/api/v1/flowcharts/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": "CONSORT flow of a randomized trial: 400 assessed, 80 excluded, 320 randomized into two arms of 160, follow-up and analysis",
"aspect_ratio": "4:3"
}),
});
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/flowcharts/generations",
headers=headers,
json={
"prompt": "CONSORT flow of a randomized trial: 400 assessed, 80 excluded, 320 randomized into two arms of 160, follow-up and analysis",
"aspect_ratio": "4:3"
},
timeout=60,
)
print(response.status_code, response.json())