API Crear clave

YouTube

Shorts de proyectos DIY

Un cuarto cansado o un hallazgo viejo, renovado ante la cámara en seis planos

Desde
240 crpor anuncio
Endpoint
POST /api/v1/studio/diy/runs
Id del flujo
diy

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/diy/estimate \
  -H "Authorization: Bearer $STAGLIGHT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "card": "build",
    "inputs": {"plan": "{\"builder\": \"a woman in her early 30s with auburn hair in a messy bun and light freckles, a plain rust-orange flannel shirt with rolled sleeves over a white T-shirt, faded denim overalls, a tan leather tool belt and brown work boots\", \"item\": \"old wooden rowing boat, about 3 metres long\", \"place\": \"a sunny backyard on green grass beside a weathered garden shed\", \"result\": \"boat daybed\", \"shots\": [{\"starts\": \"the old rowing boat sits right side up on the grass behind the shed, grey, cracked and full of dry leaves.\", \"ends\": \"the builder scoops one big armful of dry leaves out into a bucket beside the boat, grinning.\", \"line\": \"Encontré este bote viejo pudriéndose detrás de mi cobertizo. Hora de una segunda vida.\"}, {\"starts\": \"the boat is empty of leaves now, and its hull is grey and peeling.\", \"ends\": \"the builder runs an orbital sander along it in long passes, dust drifting in the sunlight, and a stripe of bare honey-coloured wood shines through.\", \"line\": \"Primero, lijé el casco hasta dejar la madera limpia.\"}, {\"starts\": \"the two old wooden seats are already sawn out and the inside is swept clean.\", \"ends\": \"the builder screws pale pine slats, each cut to the boat'\''s inside width, across the inside one by one with a cordless drill, making a flat base.\", \"line\": \"Después, quité los asientos y monté una base de listones dentro.\"}, {\"starts\": \"the slatted base is finished and four smooth wooden posts already stand at the corners of the boat.\", \"ends\": \"the builder pulls a cream canvas canopy tight across the tops of the four posts.\", \"line\": \"Luego vinieron cuatro postes y un toldo de lona.\"}, {\"starts\": \"the wood is still raw.\", \"ends\": \"the builder brushes on a warm oak finish that glows on the grain, in long smooth strokes.\", \"line\": \"Un acabado de roble cálido, a brocha.\"}, {\"starts\": \"string lights already run along the whole rim; the builder drops a thick mattress, plump cushions and a knitted blanket into the boat.\", \"ends\": \"the string lights glow warm and the builder leans back into the cushions\", \"line\": \"Cojines, mantas, listo. ¿Dormirías una siesta aquí?\"}], \"lang\": \"es\"}"}
  }' | 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/diy/runs \
  -H "Authorization: Bearer $STAGLIGHT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "card": "build",
    "inputs": {"plan": "{\"builder\": \"a woman in her early 30s with auburn hair in a messy bun and light freckles, a plain rust-orange flannel shirt with rolled sleeves over a white T-shirt, faded denim overalls, a tan leather tool belt and brown work boots\", \"item\": \"old wooden rowing boat, about 3 metres long\", \"place\": \"a sunny backyard on green grass beside a weathered garden shed\", \"result\": \"boat daybed\", \"shots\": [{\"starts\": \"the old rowing boat sits right side up on the grass behind the shed, grey, cracked and full of dry leaves.\", \"ends\": \"the builder scoops one big armful of dry leaves out into a bucket beside the boat, grinning.\", \"line\": \"Encontré este bote viejo pudriéndose detrás de mi cobertizo. Hora de una segunda vida.\"}, {\"starts\": \"the boat is empty of leaves now, and its hull is grey and peeling.\", \"ends\": \"the builder runs an orbital sander along it in long passes, dust drifting in the sunlight, and a stripe of bare honey-coloured wood shines through.\", \"line\": \"Primero, lijé el casco hasta dejar la madera limpia.\"}, {\"starts\": \"the two old wooden seats are already sawn out and the inside is swept clean.\", \"ends\": \"the builder screws pale pine slats, each cut to the boat'\''s inside width, across the inside one by one with a cordless drill, making a flat base.\", \"line\": \"Después, quité los asientos y monté una base de listones dentro.\"}, {\"starts\": \"the slatted base is finished and four smooth wooden posts already stand at the corners of the boat.\", \"ends\": \"the builder pulls a cream canvas canopy tight across the tops of the four posts.\", \"line\": \"Luego vinieron cuatro postes y un toldo de lona.\"}, {\"starts\": \"the wood is still raw.\", \"ends\": \"the builder brushes on a warm oak finish that glows on the grain, in long smooth strokes.\", \"line\": \"Un acabado de roble cálido, a brocha.\"}, {\"starts\": \"string lights already run along the whole rim; the builder drops a thick mattress, plump cushions and a knitted blanket into the boat.\", \"ends\": \"the string lights glow warm and the builder leans back into the cushions\", \"line\": \"Cojines, mantas, listo. ¿Dormirías una siesta aquí?\"}], \"lang\": \"es\"}"},
    "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/diy/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/diy/runs/$ID/outputs.zip" -H "Authorization: Bearer $STAGLIGHT_API_KEY"

Cuánto cuesta

PlantillaFinal, mejor textoBorrador, rápido y barato
Short de proyecto480 cr240 cr

Precios del servidor con los ajustes por defecto. La llamada de estimación da el precio exacto para tus entradas, gratis.

Entradas

NombreTipoValores
cardLa plantilla string build
inputs.ideaTu idea string
inputs.planEl plan string
inputs.drawProyecto sorpresa string
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.

Regístrate para probarlo

Más flujos