YouTube
Cortos animados
Un corto animado sin palabras sobre un problema que superar y el día que todo cambió
- Desde
- 245 crpor anuncio
- Endpoint
POST /api/v1/studio/shortfilm/runs- Id del flujo
shortfilm
Resultados reales de este flujo.
La solicitud
# 1. Pide el precio. Gratis, no se cobra nada.
PRICE=$(curl -s -X POST https://staglight.ai/api/v1/studio/shortfilm/estimate \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"card": "film",
"inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"}
}' | jq .credits)
echo "$PRICE"
# 2. Inícialo. max_credits rechaza lo que pase de ese precio; el Idempotency-Key evita un cobro doble.
START=$(curl -s -X POST https://staglight.ai/api/v1/studio/shortfilm/runs \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"card": "film",
"inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"},
"max_credits": '"$PRICE"'
}')
ID=$(echo "$START" | jq -r .id)
# 3. Espera a que termine.
while :; do
STATUS=$(curl -s "https://staglight.ai/api/v1/studio/shortfilm/runs/$ID" -H "Authorization: Bearer $STAGLIGHT_API_KEY" | jq -r .status)
case "$STATUS" in succeeded|partial|failed) break ;; esac; sleep 10
done
# 4. Descarga todos los archivos en un zip.
curl -s -L -o result.zip "https://staglight.ai/api/v1/studio/shortfilm/runs/$ID/outputs.zip" -H "Authorization: Bearer $STAGLIGHT_API_KEY" import os, time, uuid, requests
BASE = "https://staglight.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['STAGLIGHT_API_KEY']}"}
# 1. Pide el precio. Gratis, no se cobra nada.
estimate = {
"card": "film",
"inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"}
}
price = requests.post(f"{BASE}/api/v1/studio/shortfilm/estimate", headers=HEADERS, json=estimate, timeout=60).json()["credits"]
print(price)
# 2. Inícialo. max_credits rechaza lo que pase de ese precio; el Idempotency-Key evita un cobro doble.
body = {
"card": "film",
"inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"},
"max_credits": 485
}
body["max_credits"] = price
r = requests.post(f"{BASE}/api/v1/studio/shortfilm/runs", json=body, timeout=60,
headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())})
r.raise_for_status()
start = r.json()
# 3. Espera a que termine.
while True:
run = requests.get(f"{BASE}/api/v1/studio/shortfilm/runs/{start['id']}", headers=HEADERS, timeout=60).json()
if run["status"] in ("succeeded", "partial", "failed"):
break
time.sleep(10)
# 4. Descarga todos los archivos en un zip.
with open("result.zip", "wb") as out:
out.write(requests.get(f"{BASE}/api/v1/studio/shortfilm/runs/{start['id']}/outputs.zip", headers=HEADERS, timeout=300).content) // Node 18 o posterior. Guárdalo como run.mjs: el await de nivel superior necesita un módulo.
const BASE = "https://staglight.ai";
const headers = { Authorization: `Bearer ${process.env.STAGLIGHT_API_KEY}` };
const json = { ...headers, "Content-Type": "application/json" };
// 1. Pide el precio. Gratis, no se cobra nada.
const estimate = {
"card": "film",
"inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"}
};
const price = await (await fetch(`${BASE}/api/v1/studio/shortfilm/estimate`, { method: "POST", headers: json, body: JSON.stringify(estimate) })).json();
console.log(price.credits);
// 2. Inícialo. max_credits rechaza lo que pase de ese precio; el Idempotency-Key evita un cobro doble.
const body = {
"card": "film",
"inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"},
"max_credits": 485
};
body.max_credits = price.credits;
const res = await fetch(`${BASE}/api/v1/studio/shortfilm/runs`, {
method: "POST", headers: { ...json, "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify(body),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const start = await res.json();
// 3. Espera a que termine.
let run = start;
while (!["succeeded", "partial", "failed"].includes(run.status)) {
await new Promise((r) => setTimeout(r, 10000));
run = await (await fetch(`${BASE}/api/v1/studio/shortfilm/runs/${start.id}`, { headers })).json();
}
// 4. Descarga todos los archivos en un zip.
console.log(`${BASE}/api/v1/studio/shortfilm/runs/${start.id}/outputs.zip`); Usa la API de Staglight para ejecutar el flujo "Cortos animados" desde código de servidor.
Docs: https://staglight.ai/es/llms.txt
Este flujo: https://staglight.ai/es/api/flujos/shortfilm
Clave: léela de la variable de entorno STAGLIGHT_API_KEY. Nunca en código del navegador.
1. Pide antes el precio, gratis: POST /api/v1/studio/shortfilm/estimate
2. Inícialo: POST /api/v1/studio/shortfilm/runs, con la cabecera Idempotency-Key y max_credits.
Cuerpo: {"card": "film", "inputs": {"plan": "{\"hero\": \"a simple pale cream cartoon figure with a smooth round bald head, two small dot eyes, a small mouth and a soft rounded body with thin arms and legs, no clothes details\", \"theme\": \"Lo hondo\", \"closer\": \"El miedo se encoge cuando nadas hacia él.\", \"shadow\": \"the fear of deep water\", \"shots\": [{\"shows\": \"An indoor pool at night with blue-green light rippling on the walls. The figure sits on the edge of the shallow end, feet in the water, staring at the dark deep end across the pool.\", \"day\": \"DÍA 12\", \"line\": \"Venía cada semana. Nunca pasaba de la cuerda.\", \"voice\": \"quédate donde haces pie.\"}, {\"shows\": \"The red-outlined shadow rises out of the deep end, dripping, and leans over the lane rope toward the figure, who pulls its feet out of the water.\", \"day\": \"DÍA 30\", \"line\": \"Lo hondo siempre contestaba primero.\", \"voice\": \"te vas a hundir.\"}, {\"shows\": \"The figure walks out past children splashing happily in the deep end, wrapped in a towel, head down, and sits alone on a bench in the dim changing room.\", \"day\": \"DÍA 58\", \"line\": \"Los niños jugaban en el agua que él temía.\", \"voice\": \"hay quien no puede.\"}, {\"shows\": \"Early morning, the pool empty and still. The figure stands at the edge of the deep end, breathes in, holds the ladder and lowers itself into the water up to the chin.\", \"day\": \"DÍA 1\", \"line\": \"Una mañana bajó por la escalerilla.\", \"voice\": \"\"}, {\"shows\": \"The figure kicks along the wall holding a float, sinks, splutters, grabs the edge, then lets go and tries again while the red shadow at the bottom of the pool grows smaller.\", \"day\": \"DÍA 45\", \"line\": \"Toser. Agarrarse al borde. Otra vez.\", \"voice\": \"vuelve atrás.\"}, {\"shows\": \"Sunlight pours through high windows. The figure swims slowly across the deep end, past the rope, and floats on its back in the middle of the pool, arms open, while the faint red shadow fades away below\", \"day\": \"DÍA 200\", \"line\": \"Ahora el centro de la piscina es su lugar favorito.\", \"voice\": \"\"}]}"}, "max_credits": 485}
Los archivos son ids de POST /api/v1/uploads.
3. Si se agota el tiempo, mira la lista de trabajos antes de reintentar, y reintenta con el mismo Idempotency-Key.
4. Consulta la ejecución hasta que termine y descarga su outputs.zip. Cuánto cuesta
| Plantilla | Final, mejor texto | Borrador, rápido y barato |
|---|---|---|
| Corto animado | 485 cr | 245 cr |
Precios del servidor con los ajustes por defecto. La llamada de estimación da el precio exacto para tus entradas, gratis.
Entradas
| Nombre | Tipo | Valores |
|---|---|---|
cardLa plantilla | string | film |
inputs.ideaTu idea | string | |
inputs.planEl plan | string | |
inputs.drawCorto sorpresa | string | |
inputs.lengthDuración | enum | 12, 30 |
inputs.shapeTipo de historia | enum | arc, unseen, split, fork, habit, any |
inputs.languageIdioma | enum | auto, en, es |
qualityCalidad | enum | final, draft |
aspectFormato | enum | 9:16, 16:9 |
Los archivos son ids de POST /api/v1/uploads. Ver la documentación
Pruébalo a mano
El mismo flujo funciona en el estudio, con el mismo saldo. Úsalo para ver el resultado antes de escribir código.
Más flujos
- Resultado real YouTube
Shorts de ranking
Cinco puestos locos, del #5 al #1, en un solo Short vertical
por anuncio, desde190 cr
- Resultado real YouTube
Serie Glow-up
Una serie animada en la que tu público vota qué cambia cada día
por anuncio, desde216 cr
- Resultado real YouTube
Mates en movimiento
Cualquier idea se convierte en un Short de mates en neón, con la cifra real calculada y mostrada en acción
por anuncio, desde100 cr