API-Referenz
Bilder generieren
Erstellen Sie eine wissenschaftliche Illustration aus einer Textbeschreibung, optional mit Referenzbildern als Vorlage.
JSON-Anfrageinhalt#
POST /images/generations mit einem JSON-Anfrageinhalt. Erforderlicher Berechtigungsbereich: figures:generate.
| Feld | Typ | Erforderlich | Standard | Regeln |
|---|---|---|---|---|
| prompt | string | ja | — | 3–20.000 Zeichen |
| aspect_ratio | string | nein | 1:1 | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
| quality | string | nein | standard | standard, advanced oder premium; legt Modell und Preis fest |
| style | string | nein | — | flat, 2-5d, line-art, hand-drawn, scientific, line, 3d, editorial, sketch, watercolor, auto |
| palette | Zeichenfolge oder Array | nein | — | ID einer voreingestellten Palette oder 1–4 Farben im Format #RRGGBB |
| reference_file_ids | array | nein | — | 1–3 Bild-file_ids aus Uploads oder früheren Ergebnissen |
Unbekannte Felder werden mit 400 INVALID_REQUEST abgelehnt; details.issues nennt jedes Problem. Manche Modelle, Referenzbilder und Seitenverhältnisse erfordern einen kostenpflichtigen Tarif; andernfalls wird 403 PLAN_REQUIRED zurückgegeben.
Credits#
| quality | Credits |
|---|---|
| standard | 50 |
| advanced | 75 |
| premium | 100 |
Credits werden beim Erstellen des Auftrags reserviert, bei Erfolg einmal abgerechnet und bei einem Fehler vollständig zurückgegeben. Die Antwort ist ein Auftrag. Seine Felder und Status finden Sie unter Aufträge und begrenzte Wartezeit. Fehler sind unter Fehler aufgeführt.
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())