YouTube
Motion Math
Any idea becomes a neon maths Short, with the real number worked out and shown happening
- From
- 100 crper ad
- Endpoint
POST /api/v1/studio/counter/runs- Workflow id
counter
Real outputs of this workflow.
The request
# 1. Price it. Free, nothing is charged.
PRICE=$(curl -s -X POST https://staglight.ai/api/v1/studio/counter/estimate \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"card": "stack"
}' | 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/studio/counter/runs \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"card": "stack",
"max_credits": '"$PRICE"'
}')
ID=$(echo "$START" | jq -r .id)
# 3. Wait until it finishes.
while :; do
STATUS=$(curl -s "https://staglight.ai/api/v1/studio/counter/runs/$ID" -H "Authorization: Bearer $STAGLIGHT_API_KEY" | jq -r .status)
case "$STATUS" in succeeded|partial|failed) break ;; esac; sleep 10
done
# 4. Download every file in one zip.
curl -s -L -o result.zip "https://staglight.ai/api/v1/studio/counter/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 = {
"card": "stack"
}
price = requests.post(f"{BASE}/api/v1/studio/counter/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 = {
"card": "stack",
"max_credits": 100
}
body["max_credits"] = price
r = requests.post(f"{BASE}/api/v1/studio/counter/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/studio/counter/runs/{start['id']}", headers=HEADERS, timeout=60).json()
if run["status"] in ("succeeded", "partial", "failed"):
break
time.sleep(10)
# 4. Download every file in one zip.
with open("result.zip", "wb") as out:
out.write(requests.get(f"{BASE}/api/v1/studio/counter/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 = {
"card": "stack"
};
const price = await (await fetch(`${BASE}/api/v1/studio/counter/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 = {
"card": "stack",
"max_credits": 100
};
body.max_credits = price.credits;
const res = await fetch(`${BASE}/api/v1/studio/counter/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", "partial", "failed"].includes(run.status)) {
await new Promise((r) => setTimeout(r, 10000));
run = await (await fetch(`${BASE}/api/v1/studio/counter/runs/${start.id}`, { headers })).json();
}
// 4. Download every file in one zip.
console.log(`${BASE}/api/v1/studio/counter/runs/${start.id}/outputs.zip`); Use the Staglight API to run the workflow "Motion Math" from server code.
Docs: https://staglight.ai/llms.txt
This workflow: https://staglight.ai/en/api/workflows/counter
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/studio/counter/estimate
2. Start it: POST /api/v1/studio/counter/runs, with an Idempotency-Key header and max_credits.
Body: {"card": "stack", "max_credits": 100}
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
| Template | Final, best text |
|---|---|
| Stack it | 100 cr |
| Double it | 100 cr |
| Fall from it | 100 cr |
| Halve it | 100 cr |
| Fit it | 100 cr |
| Odds pile | 100 cr |
| Race | 100 cr |
| How long | 100 cr |
| Size line-up | 136 cr |
| Clacks | 100 cr |
| Surprise me | 100 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 |
|---|---|---|
cardrequiredThe template | string | stack, double, fall, halve, fit, odds, race, rate, compare, clacks, surprise |
inputs.ideaYour idea | string | |
inputs.itemStack what | enum | random, paper, bill, card, penny, lego, can, person |
inputs.targetReach where | enum | random, eiffel, burj, everest, plane, space, iss, gps, ... |
inputs.fall_fromFall from where | enum | random, eiffel, burj, everest, plane, space, iss, gps, ... |
inputs.cut_itemCut what | enum | random, a4, card, person |
inputs.smallDown to | enum | random, hair, cell, bacterium, virus, dna, atom |
inputs.containerFill what | enum | random, basketball, earth, jupiter, sun |
inputs.ballWith what | enum | random, earth, golf, moon, pingpong, tennis |
inputs.own_smallYour tiny thing | string | |
inputs.own_small_mmIts size (mm) | string | |
inputs.own_ballWhat goes inside | string | |
inputs.own_ball_mmIts width (mm) | string | |
inputs.own_containerYour container | string | |
inputs.own_container_lIts volume (litres) | string | |
inputs.odds_whatWhat is rare | string | |
inputs.odds_one_inOdds: 1 in | string | |
inputs.odds_exactExact odds (a game of chance) | bool | |
inputs.race_1Racer 1 | string | |
inputs.race_1_kmhRacer 1 speed (km/h) | string | |
inputs.race_2Racer 2 | string | |
inputs.race_2_kmhRacer 2 speed (km/h) | string | |
inputs.race_3Racer 3 | string | |
inputs.race_3_kmhRacer 3 speed (km/h) | string | |
inputs.race_4Racer 4 | string | |
inputs.race_4_kmhRacer 4 speed (km/h) | string | |
inputs.race_kmRace distance (km) | string | |
inputs.rate_taskThe job | string | |
inputs.rate_unitCounted in | string | |
inputs.rate_totalHow much in all | string | |
inputs.rate_perHow much each period | string | |
inputs.rate_periodPeriod | enum | second, minute, hour, day, year |
inputs.cmp_1Thing 1 | string | |
inputs.cmp_1_mThing 1 size (m) | string | |
inputs.cmp_1_byThing 1 size measures | enum | , height, length |
inputs.cmp_1_picThing 1 picture (English words) | string | |
inputs.cmp_2Thing 2 | string | |
inputs.cmp_2_mThing 2 size (m) | string | |
inputs.cmp_2_byThing 2 size measures | enum | , height, length |
inputs.cmp_2_picThing 2 picture (English words) | string | |
inputs.cmp_3Thing 3 | string | |
inputs.cmp_3_mThing 3 size (m) | string | |
inputs.cmp_3_byThing 3 size measures | enum | , height, length |
inputs.cmp_3_picThing 3 picture (English words) | string | |
inputs.cmp_4Thing 4 | string | |
inputs.cmp_4_mThing 4 size (m) | string | |
inputs.cmp_4_byThing 4 size measures | enum | , height, length |
inputs.cmp_4_picThing 4 picture (English words) | string | |
inputs.cmp_5Thing 5 | string | |
inputs.cmp_5_mThing 5 size (m) | string | |
inputs.cmp_5_byThing 5 size measures | enum | , height, length |
inputs.cmp_5_picThing 5 picture (English words) | string | |
inputs.cmp_6Thing 6 | string | |
inputs.cmp_6_mThing 6 size (m) | string | |
inputs.cmp_6_byThing 6 size measures | enum | , height, length |
inputs.cmp_6_picThing 6 picture (English words) | string | |
inputs.cmp_7Thing 7 | string | |
inputs.cmp_7_mThing 7 size (m) | string | |
inputs.cmp_7_byThing 7 size measures | enum | , height, length |
inputs.cmp_7_picThing 7 picture (English words) | string | |
inputs.cmp_8Thing 8 | string | |
inputs.cmp_8_mThing 8 size (m) | string | |
inputs.cmp_8_byThing 8 size measures | enum | , height, length |
inputs.cmp_8_picThing 8 picture (English words) | string | |
inputs.cmp_9Thing 9 | string | |
inputs.cmp_9_mThing 9 size (m) | string | |
inputs.cmp_9_byThing 9 size measures | enum | , height, length |
inputs.cmp_9_picThing 9 picture (English words) | string | |
inputs.cmp_10Thing 10 | string | |
inputs.cmp_10_mThing 10 size (m) | string | |
inputs.cmp_10_byThing 10 size measures | enum | , height, length |
inputs.cmp_10_picThing 10 picture (English words) | string | |
inputs.cmp_11Thing 11 | string | |
inputs.cmp_11_mThing 11 size (m) | string | |
inputs.cmp_11_byThing 11 size measures | enum | , height, length |
inputs.cmp_11_picThing 11 picture (English words) | string | |
inputs.clacks_digitsDigits of pi | enum | 1, 2, 3, 4, 5 |
inputs.themeColour | enum | random, blue, mint, red, amber, pink, violet, white |
inputs.own_colorYour own colour | string | |
inputs.handleChannel name on the video | string | |
inputs.languageLanguage | enum | auto, en, es |
inputs.questionYour own wording | string | |
inputs.own_itemYour item | string | |
inputs.own_size_mmIts height in mm | string | |
inputs.own_targetYour place | string | |
inputs.own_target_kmHow far in km | string | |
inputs.own_aboutSizes are rough figures | bool | |
inputs.drawSurprise question | string | |
inputs.picturesPictures of each thing | bool | |
qualityQuality | enum | final |
aspectShape | enum | 9:16 |
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 YouTube
Ranking Shorts
Five crazy levels, ranked #5 to #1, in one vertical Short
per ad, from190 cr
- Real output YouTube
Glow-up Series
An animated series in your language where your audience votes what changes each day
per ad, from216 cr
- Real output YouTube
DIY Build Shorts
A tired room or an old find made new, built on camera in six shots
per ad, from240 cr