Video
Product link ad
Paste your product link, get a video ad
- From
- 169 crper ad
- Endpoint
POST /api/v1/studio/link_ad/runs- Workflow id
link_ad
Real outputs of this workflow.
The request
# 0. Upload your file first. Its id goes in the body.
MEDIA_ID=$(curl -s -X POST https://staglight.ai/api/v1/uploads \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" -F file=@product.jpg | jq -r .id)
# 1. Price it. Free, nothing is charged.
PRICE=$(curl -s -X POST https://staglight.ai/api/v1/studio/link_ad/estimate \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"card": "talk",
"inputs": {"description": "Your words here"},
"media": {
"product": ["'"$MEDIA_ID"'"]
}
}' | 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/link_ad/runs \
-H "Authorization: Bearer $STAGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"card": "talk",
"inputs": {"description": "Your words here"},
"media": {
"product": ["'"$MEDIA_ID"'"]
},
"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/link_ad/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/link_ad/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']}"}
# 0. Upload your file first. Its id goes in the body.
with open("product.jpg", "rb") as f:
media_id = requests.post(f"{BASE}/api/v1/uploads", headers=HEADERS, files={"file": f},
timeout=300).json()["id"]
# 1. Price it. Free, nothing is charged.
estimate = {
"card": "talk",
"inputs": {"description": "Your words here"},
"media": {
"product": [media_id]
}
}
price = requests.post(f"{BASE}/api/v1/studio/link_ad/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": "talk",
"inputs": {"description": "Your words here"},
"media": {
"product": [media_id]
},
"max_credits": 169
}
body["max_credits"] = price
r = requests.post(f"{BASE}/api/v1/studio/link_ad/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/link_ad/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/link_ad/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" };
// 0. Upload your file first. Its id goes in the body.
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("file", new Blob([await readFile("product.jpg")]), "product.jpg");
const { id: mediaId } = await (await fetch(`${BASE}/api/v1/uploads`, { method: "POST", headers, body: form })).json();
// 1. Price it. Free, nothing is charged.
const estimate = {
"card": "talk",
"inputs": {"description": "Your words here"},
"media": {
"product": [mediaId]
}
};
const price = await (await fetch(`${BASE}/api/v1/studio/link_ad/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": "talk",
"inputs": {"description": "Your words here"},
"media": {
"product": [mediaId]
},
"max_credits": 169
};
body.max_credits = price.credits;
const res = await fetch(`${BASE}/api/v1/studio/link_ad/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/link_ad/runs/${start.id}`, { headers })).json();
}
// 4. Download every file in one zip.
console.log(`${BASE}/api/v1/studio/link_ad/runs/${start.id}/outputs.zip`); Use the Staglight API to run the workflow "Product link ad" from server code.
Docs: https://staglight.ai/llms.txt
This workflow: https://staglight.ai/en/api/workflows/link_ad
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/link_ad/estimate
2. Start it: POST /api/v1/studio/link_ad/runs, with an Idempotency-Key header and max_credits.
Body: {"card": "talk", "inputs": {"description": "Your words here"}, "media": {"product": ["med_your_upload_id"]}, "max_credits": 169}
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 |
|---|---|
| Talks about it | 169 cr |
| Presenter demo | 169 cr |
| Scene comes alive | 169 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 | talk, demo, scene |
media.productrequiredProduct photo | media id[] | |
inputs.nameProduct name | string | |
inputs.descriptionrequiredWhat it is | string | |
inputs.saySpoken line (optional, turns on voice) | string | |
inputs.motionWhat moves (optional, the video only) | string | |
inputs.genderWho's showcasing it | enum | man, woman |
inputs.setScene | enum | bathroom, bedroom, kitchen, car, park, street |
inputs.shotsShot style | enum | single, multi |
inputs.framingShot distance | enum | wide, medium, close |
inputs.modelModel | enum | kling, veo_fast, veo_best |
inputs.durationDuration | enum | 5, 10, 15 |
inputs.soundNative sound | bool | |
inputs.nicheCategory | string | |
inputs.product_infoProduct facts | string | |
qualityQuality | enum | final |
aspectShape | enum | 9:16, 1:1, 16:9 |
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 Video
AI Influencer
Create your own AI influencer, pick a move and get a vertical video ready to post.
per ad, from10 cr
- Real output Video
UGC Video
One product image, one line of description, one video
per ad, from169 cr
- Real output Video
Wiggle Clip
One static wide shot of the product being worn, then burn a different hook on it for every post
per ad, from94 cr