Referencia de la API
Generación de imágenes
Genera una ilustración científica a partir de una descripción de texto, opcionalmente guiada por imágenes de referencia.
Cuerpo JSON#
POST /images/generations con un cuerpo JSON. Ámbito requerido: figures:generate.
| Campo | Tipo | Obligatorio | Valor predeterminado | Reglas |
|---|---|---|---|---|
| prompt | string | sí | — | 3–20 000 caracteres |
| aspect_ratio | string | no | 1:1 | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
| quality | string | no | standard | standard, advanced o premium; determina el modelo y el precio |
| style | string | no | — | flat, 2-5d, line-art, hand-drawn, scientific, line, 3d, editorial, sketch, watercolor, auto |
| palette | cadena o matriz | no | — | Identificador de una paleta predefinida o 1–4 colores #RRGGBB |
| reference_file_ids | array | no | — | 1–3 file_id de imágenes, de subidas o resultados anteriores |
Los campos desconocidos se rechazan con 400 INVALID_REQUEST; details.issues indica cada problema. Algunos modelos, imágenes de referencia y relaciones de aspecto requieren un plan de pago; en ese caso se devuelve 403 PLAN_REQUIRED.
Créditos#
| quality | Créditos |
|---|---|
| standard | 50 |
| advanced | 75 |
| premium | 100 |
Los créditos se reservan al crear la tarea, se cobran una sola vez si se completa y se devuelven íntegramente si falla. La respuesta es una tarea; consulta Tareas y espera limitada para ver sus campos y estados. Los errores se enumeran en Errores.
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())