SciFig

Riferimento API

Ingrandimento di immagini

Ingrandisci un’immagine a 2K, 4K o 8K.

Corpo JSON#

POST /images/upscales. Ambito richiesto: figures:generate.

CampoTipoObbligatorioValore predefinitoRegole
imagestringsì—Un file_id di immagine
scalestringsì—2k, 4k con il piano Starter o superiore, oppure 8k con il piano Plus o superiore; un saldo positivo di crediti acquistati in pacchetti equivale a Pro
scaleCrediti
2k50
4k100
8k150

Un’immagine che raggiunge già la dimensione di destinazione restituisce 400 INVALID_REQUEST con details.reason = UPSCALE_ALREADY_AT_TARGET senza addebiti. Le illustrazioni generate sono di circa 2K, quindi richiedi 4k o 8k. Un ingrandimento che supera il tempo limite viene rimborsato e non viene consegnato in seguito. La risposta è un processo; consulta Processi e attesa limitata per i campi e gli stati. Gli errori sono elencati in Errori.

cURL#

curl -X POST https://scifig.ai/api/v1/images/upscales \
  -H "Authorization: Bearer $SCIFIG_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=25" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "<file_id>",
    "scale": "4k"
  }'

JavaScript#

const response = await fetch('https://scifig.ai/api/v1/images/upscales', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    Prefer: 'wait=25',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "image": "<file_id>",
    "scale": "4k"
  }),
});
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/upscales",
    headers=headers,
    json={
        "image": "<file_id>",
        "scale": "4k"
    },
    timeout=60,
)
print(response.status_code, response.json())