One-Click Test
Copy the script below, paste your API key, and run it. The script will create a task, poll until completion, and print the video URL.
import requests, time, sys
API_KEY = "YOUR_API_KEY" # ← paste your API key here
BASE_URL = "https://seedance2-pro.com/api/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# 1. Create task
print("Creating task...")
resp = requests.post(f"{BASE_URL}/jobs/createTask", headers=headers, json={
"model": "seedance-20",
"inputs": {
"prompt": "A golden retriever running on a beach at sunset, waves crashing in the background, cinematic slow motion",
"resolution": "1280x720",
"duration": "5s"
}
})
data = resp.json()
if not resp.ok:
print(f"Error: {data['message']}")
if resp.status_code == 402:
print(f" Need {data['required']} credits, you have {data['available']}")
sys.exit(1)
task_id = data["taskId"]
print(f"Task created: {task_id}")
# 2. Poll for completion
print("Generating video", end="", flush=True)
start = time.time()
while time.time() - start < 300:
resp = requests.get(f"{BASE_URL}/jobs/recordInfo?taskId={task_id}", headers=headers)
result = resp.json()
if result["status"] == "success":
elapsed = int(time.time() - start)
print(f"\n\nDone in {elapsed}s!")
print(f"Video URL: {result['output'][0]['url']}")
print(f"Resolution: {result['output'][0]['width']}x{result['output'][0]['height']}")
sys.exit(0)
if result["status"] == "fail":
print(f"\n\nFailed: {result['error']}")
sys.exit(1)
print(".", end="", flush=True)
time.sleep(5)
print("\n\nTimeout after 300s. Task may still be processing.")
print(f"Check manually: GET {BASE_URL}/jobs/recordInfo?taskId={task_id}")
pip install requests
python demo.py
const API_KEY = "YOUR_API_KEY"; // ← paste your API key here
const BASE_URL = "https://seedance2-pro.com/api/v1";
const headers = {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
};
async function main() {
// 1. Create task
console.log("Creating task...");
const createResp = await fetch(`${BASE_URL}/jobs/createTask`, {
method: "POST",
headers,
body: JSON.stringify({
model: "seedance-20",
inputs: {
prompt: "A golden retriever running on a beach at sunset, waves crashing in the background, cinematic slow motion",
resolution: "1280x720",
duration: "5s",
},
}),
});
const createData = await createResp.json();
if (!createResp.ok) {
console.error(`Error: ${createData.message}`);
if (createResp.status === 402) {
console.error(` Need ${createData.required} credits, you have ${createData.available}`);
}
process.exit(1);
}
const { taskId } = createData;
console.log(`Task created: ${taskId}`);
// 2. Poll for completion
process.stdout.write("Generating video");
const start = Date.now();
while (Date.now() - start < 300000) {
const pollResp = await fetch(`${BASE_URL}/jobs/recordInfo?taskId=${taskId}`, { headers });
const data = await pollResp.json();
if (data.status === "success") {
const elapsed = Math.round((Date.now() - start) / 1000);
console.log(`\n\nDone in ${elapsed}s!`);
console.log(`Video URL: ${data.output[0].url}`);
console.log(`Resolution: ${data.output[0].width}x${data.output[0].height}`);
process.exit(0);
}
if (data.status === "fail") {
console.log(`\n\nFailed: ${data.error}`);
process.exit(1);
}
process.stdout.write(".");
await new Promise((r) => setTimeout(r, 5000));
}
console.log("\n\nTimeout after 300s. Task may still be processing.");
console.log(`Check manually: GET ${BASE_URL}/jobs/recordInfo?taskId=${taskId}`);
}
main();
# Set your API key
export SEEDANCE_API_KEY="YOUR_API_KEY"
# 1. Create task
echo "Creating task..."
RESPONSE=$(curl -s -X POST "https://seedance2-pro.com/api/v1/jobs/createTask" \
-H "Authorization: Bearer $SEEDANCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-20",
"inputs": {
"prompt": "A golden retriever running on a beach at sunset, waves crashing in the background, cinematic slow motion",
"resolution": "1280x720",
"duration": "5s"
}
}')
echo "$RESPONSE" | python3 -m json.tool
# 2. Extract taskId and poll
TASK_ID=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['taskId'])")
echo "Polling task: $TASK_ID"
while true; do
RESULT=$(curl -s "https://seedance2-pro.com/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
-H "Authorization: Bearer $SEEDANCE_API_KEY")
STATUS=$(echo "$RESULT" | python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
if [ "$STATUS" = "success" ]; then
echo "Done!"
echo "$RESULT" | python3 -m json.tool
break
elif [ "$STATUS" = "fail" ]; then
echo "Failed!"
echo "$RESULT" | python3 -m json.tool
break
fi
echo "Status: $STATUS ... waiting 5s"
sleep 5
done
What This Demo Does
| Step | API Call | Cost |
|---|
| Create task | POST /jobs/createTask | 200 credits (5s video) |
| Poll status | GET /jobs/recordInfo | Free |
| Download video | Direct URL | Free |
5-second video at 1280x720 costs 200 credits. Generation typically finishes in 1-5 minutes.
Try Different Parameters
Replace resolution value:
1280x720 — Landscape 16:9
720x1280 — Portrait 9:16
720x720 — Square 1:1
960x720 — Landscape 4:3
720x960 — Portrait 3:4
Replace duration value: 4s to 15s. Credits scale linearly (40 credits/sec).
Add urls to inputs (1-2 images):{
"model": "seedance-20",
"inputs": {
"urls": [
"https://example.com/first-frame.jpg",
"https://example.com/last-frame.jpg"
],
"prompt": "Smooth transition between the two scenes",
"resolution": "1280x720",
"duration": "5s"
}
}
Next Steps