SciFig

API reference

Image generations

Generate a scientific illustration from a text prompt, optionally guided by reference images.

JSON body#

POST /images/generations with a JSON body. Required scope: figures:generate.

FieldTypeRequiredDefaultRules
promptstringyes—3–20,000 characters
aspect_ratiostringno1:11:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
qualitystringnostandardstandard, advanced or premium; sets the model and the price
stylestringno—flat, 2-5d, line-art, hand-drawn, scientific, line, 3d, editorial, sketch, watercolor, auto
palettestring or arrayno—A palette preset id, or 1–4 #RRGGBB colours
reference_file_idsarrayno—1–3 image file_ids (uploads or earlier outputs)

Unknown fields are rejected with 400 INVALID_REQUEST; details.issues names each problem. Some models, reference images and ratios need a paid plan, which returns 403 PLAN_REQUIRED.

Credits#

qualityCredits
standard50
advanced75
premium100

Credits are reserved when the job is created, charged once when it succeeds and returned in full when it fails. The response is a job; see Jobs and bounded waiting for its fields and statuses. Errors are listed under Errors.

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