Ad formats
Script Runner
Paste your script and we turn it into scenes, keyframes, clips and an edited video.
- From
- 198 crper ad
- Endpoint
POST /api/v1/runs- Workflow id
script_runner
Real outputs of this workflow.
The request
# 1. Price it. Free, nothing is charged.
PRICE=$(curl -s -X POST https://staglight.ai/api/v1/runs/estimate \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"format": "script_runner",
"options": {
"tier": "draft",
"aspect": "9:16",
"lang": "en",
"script": "Ana: My skin looked tired every morning. Then I found this serum."
}
}' | jq .credits)
echo "$PRICE"
# 2. Start it. max_credits refuses anything above that price; the Idempotency-Key stops a double charge.
START=$(curl -s -X POST https://staglight.ai/api/v1/runs \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"format": "script_runner",
"options": {
"tier": "draft",
"aspect": "9:16",
"lang": "en",
"script": "Ana: My skin looked tired every morning. Then I found this serum."
},
"auto": true,
"max_credits": '"$PRICE"'
}')
ID=$(echo "$START" | jq -r .id)
# 3. Wait until it finishes.
while :; do
STATUS=$(curl -s "https://staglight.ai/api/v1/runs/$ID?wait=30" -H "Authorization: Bearer $STAGLIGHT_API_KEY" | jq -r .status)
case "$STATUS" in succeeded|failed|canceled|awaiting_approval|needs_attention) break ;; esac
done
# 4. Download every file in one zip.
curl -s -L -o result.zip "https://staglight.ai/api/v1/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. Price it. Free, nothing is charged.
estimate = {
"format": "script_runner",
"options": {
"tier": "draft",
"aspect": "9:16",
"lang": "en",
"script": "Ana: My skin looked tired every morning. Then I found this serum."
}
}
price = requests.post(f"{BASE}/api/v1/runs/estimate", headers=HEADERS, json=estimate, timeout=60).json()["credits"]
print(price)
# 2. Start it. max_credits refuses anything above that price; the Idempotency-Key stops a double charge.
body = {
"format": "script_runner",
"options": {
"tier": "draft",
"aspect": "9:16",
"lang": "en",
"script": "Ana: My skin looked tired every morning. Then I found this serum."
},
"auto": True,
"max_credits": 117
}
body["max_credits"] = price
r = requests.post(f"{BASE}/api/v1/runs", json=body, timeout=60,
headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())})
r.raise_for_status()
start = r.json()
# 3. Wait until it finishes.
while True:
run = requests.get(f"{BASE}/api/v1/runs/{start['id']}", headers=HEADERS, params={"wait": 30}, timeout=60).json()
if run["status"] in ("succeeded", "failed", "canceled", "awaiting_approval", "needs_attention"):
break
# 4. Download every file in one zip.
with open("result.zip", "wb") as out:
out.write(requests.get(f"{BASE}/api/v1/runs/{start['id']}/outputs.zip", headers=HEADERS, timeout=300).content) // Node 18 or newer. Save as run.mjs: top-level await needs a module.
const BASE = "https://staglight.ai";
const headers = { Authorization: `Bearer ${process.env.STAGLIGHT_API_KEY}` };
const json = { ...headers, "Content-Type": "application/json" };
// 1. Price it. Free, nothing is charged.
const estimate = {
"format": "script_runner",
"options": {
"tier": "draft",
"aspect": "9:16",
"lang": "en",
"script": "Ana: My skin looked tired every morning. Then I found this serum."
}
};
const price = await (await fetch(`${BASE}/api/v1/runs/estimate`, { method: "POST", headers: json, body: JSON.stringify(estimate) })).json();
console.log(price.credits);
// 2. Start it. max_credits refuses anything above that price; the Idempotency-Key stops a double charge.
const body = {
"format": "script_runner",
"options": {
"tier": "draft",
"aspect": "9:16",
"lang": "en",
"script": "Ana: My skin looked tired every morning. Then I found this serum."
},
"auto": true,
"max_credits": 117
};
body.max_credits = price.credits;
const res = await fetch(`${BASE}/api/v1/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. Wait until it finishes.
let run = start;
while (!["succeeded", "failed", "canceled", "awaiting_approval", "needs_attention"].includes(run.status)) {
run = await (await fetch(`${BASE}/api/v1/runs/${start.id}?wait=30`, { headers })).json();
}
// 4. Download every file in one zip.
console.log(`${BASE}/api/v1/runs/${start.id}/outputs.zip`); Use the Staglight API to run the workflow "Script Runner" from server code.
Docs: https://staglight.ai/llms.txt
This workflow: https://staglight.ai/en/api/workflows/script_runner
Key: read it from the STAGLIGHT_API_KEY environment variable. Never put it in browser code.
1. Price it for free first: POST /api/v1/runs/estimate
2. Start it: POST /api/v1/runs, with an Idempotency-Key header and max_credits.
Body: {"format": "script_runner", "options": {"tier": "draft", "aspect": "9:16", "lang": "en", "script": "Ana: My skin looked tired every morning. Then I found this serum."}, "auto": true, "max_credits": 117}
Files are media ids from POST /api/v1/uploads.
3. After a timeout, check the job list before you retry, and retry with the same Idempotency-Key.
4. Poll the run until it finishes, then download its outputs.zip. What it costs
| Tier | 9:16 | 4:5 | 1:1 | 16:9 |
|---|---|---|---|---|
| Draft | 198 cr | 198 cr | 198 cr | 198 cr |
| Standard | 414 cr | 414 cr | 414 cr | 414 cr |
| Premium | 514 cr | 514 cr | 514 cr | 514 cr |
Prices from the server at the default settings. The estimate call gives the exact price for your inputs, for free.
Inputs
| Name | Type | Allowed |
|---|---|---|
formatrequiredThe format | string | script_runner |
options.scriptrequiredThe script, in block syntax or plain text | string | |
options.tierTier | enum | draft, standard, premium |
options.aspectShape | enum | 9:16, 4:5, 1:1, 16:9 |
options.langLanguage of the words | enum | es, en |
autoApprove every step within max_credits | boolean | true, false |
Files are media ids from POST /api/v1/uploads. View documentation
Try it by hand
The same workflow runs in the studio, on the same balance. Use it to see the result before you write code.
More workflows
- Real output Ad formats
Creator-style UGC
An AI presenter shows your product on camera, with a script, voiceover and captions.
per ad, from92 cr
- Real output Ad formats
Problem / Solution
Three scenes: the problem, the pain and your product as the fix, with voiceover and captions.
per ad, from157 cr
- Real output Ad formats
3 reasons
Three benefits in three clips with big on-screen numbers. The app sets the text, not the model.
per ad, from157 cr