SciFig

API reference

Flowchart generations and edits

Draw scientific flowcharts and workflow diagrams as SVG, then change them with follow-up instructions.

JSON body#

POST /flowcharts/generations. Required scope: figures:generate.

FieldTypeRequiredDefaultRules
promptstringyes—1–8,000 characters
aspect_ratiostringnoautoauto, 16:9, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 21:9
attachment_file_idsarrayno—Up to 8 files uploaded with purpose flowchart_attachment (for example a protocol or a draft)

100 credits. A succeeded job has one SVG output with editable text and an editor_url that opens it in its FlowChart conversation on the website. Export PNG, PDF, TIFF or PPTX with a free conversion.

Attachments are uploaded first with POST /files and purpose flowchart_attachment; they count against the website’s upload limits and can be used for 24 hours.

Edits#

POST /flowcharts/edits with JSON {"job": "<flowchart job id>", "instruction": "..."} changes the flowchart that job produced and keeps its aspect ratio. instruction is 1–8,000 characters. 100 credits. The same rules as chart edits apply: a running parent returns a retryable 409 REVISION_CONFLICT (PARENT_JOB_RUNNING), a failed one 400 INVALID_REQUEST (JOB_NOT_SUCCEEDED), only the latest version can be edited (409 REVISION_CONFLICT, NOT_LATEST_REVISION), one edit runs at a time (EDIT_IN_PROGRESS), and the result appears in the same FlowChart conversation on the website.

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