SciFig

Référence API

Création et modification de diagrammes de flux

Dessinez des diagrammes de flux scientifiques et des diagrammes de flux de travail en SVG, puis modifiez-les avec de nouvelles instructions.

Afficher en Markdown

Corps JSON#

POST /flowcharts/generations. Portée requise : figures:generate.

ChampTypeObligatoireValeur par défautRègles
promptstringoui—1 à 8 000 caractères
aspect_ratiostringnonautoauto, 16:9, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 21:9
attachment_file_idsarraynon—Jusqu’à 8 fichiers importés avec l’usage flowchart_attachment, par exemple un protocole ou un brouillon

100 crédits. Une tâche réussie contient un résultat SVG avec du texte modifiable et un editor_url qui l’ouvre dans sa conversation FlowChart sur le site. Exportez en PNG, PDF, TIFF ou PPTX avec une conversion gratuite.

Les pièces jointes sont d’abord importées avec POST /files et l’usage flowchart_attachment ; elles comptent dans les limites d’importation du site et peuvent être utilisées pendant 24 heures.

Modifications#

POST /flowcharts/edits avec le JSON {"job": "<flowchart job id>", "instruction": "..."} modifie le diagramme de flux produit par cette tâche en conservant son rapport largeur/hauteur. instruction contient de 1 à 8 000 caractères. 100 crédits. Les règles des modifications de graphiques s’appliquent : une tâche parente en cours renvoie un 409 REVISION_CONFLICT permettant une nouvelle tentative avec PARENT_JOB_RUNNING ; une tâche parente échouée renvoie 400 INVALID_REQUEST avec JOB_NOT_SUCCEEDED. Seule la version la plus récente peut être modifiée, sinon 409 REVISION_CONFLICT avec NOT_LATEST_REVISION. Une seule modification peut être en cours, sinon EDIT_IN_PROGRESS. Le résultat apparaît dans la même conversation FlowChart sur le site.

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