SDK とコード例
Seedance 2.0 API は標準的な REST インターフェースを使用しています。以下は、主要な言語での完全な統合例です。
ベース URL
https://api.evolink.ai
Python
import requests
import time
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.evolink.ai"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# 1. Create a video generation task
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json={
"model": "seedance-2.0",
"prompt": "A sunset over the ocean, cinematic wide shot",
"duration": 5,
"quality": "1080p",
"aspect_ratio": "16:9"
}
)
task = response.json()
task_id = task["id"]
print(f"Task created: {task_id}")
# 2. Poll for completion
while True:
status = requests.get(
f"{BASE_URL}/v1/tasks/{task_id}",
headers=headers
)
result = status.json()
if result["status"] == "completed":
print(f"Video URL: {result['results'][0]}")
break
elif result["status"] == "failed":
print("Generation failed")
break
print(f"Progress: {result['progress']}%")
time.sleep(5)
Node.js
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://api.evolink.ai";
const headers = {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
};
// 1. Create a video generation task
const createRes = await fetch(`${BASE_URL}/v1/videos/generations`, {
method: "POST",
headers,
body: JSON.stringify({
model: "seedance-2.0",
prompt: "A sunset over the ocean, cinematic wide shot",
duration: 5,
quality: "1080p",
aspect_ratio: "16:9"
})
});
const task = await createRes.json();
const taskId = task.id;
console.log(`Task created: ${taskId}`);
// 2. Poll for completion
const poll = async () => {
while (true) {
const statusRes = await fetch(`${BASE_URL}/v1/tasks/${taskId}`, { headers });
const result = await statusRes.json();
if (result.status === "completed") {
console.log(`Video URL: ${result.results[0]}`);
return;
}
if (result.status === "failed") {
console.log("Generation failed");
return;
}
console.log(`Progress: ${result.progress}%`);
await new Promise(r => setTimeout(r, 5000));
}
};
await poll();
cURL
# 1. Create a video generation task
curl -X POST https://api.evolink.ai/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2.0",
"prompt": "A sunset over the ocean, cinematic wide shot",
"duration": 5,
"quality": "1080p"
}'
# Response: {"id": "task-unified-...", "status": "pending", ...}
# 2. Check task status
curl https://api.evolink.ai/v1/tasks/TASK_ID \
-H "Authorization: Bearer YOUR_API_KEY"
# When completed: {"status": "completed", "results": ["https://...mp4"], ...}
画像からビデオの例
# Animate a single image
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json={
"model": "seedance-2.0",
"prompt": "The woman turns her head slowly, hair flowing in the wind",
"image_urls": ["https://example.com/portrait.jpg"],
"duration": 5,
"quality": "1080p"
}
)
先頭-末尾フレームの例
# Generate transition between two keyframes
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json={
"model": "seedance-2.0",
"prompt": "Smooth camera pan revealing the landscape",
"image_urls": [
"https://example.com/frame-start.jpg",
"https://example.com/frame-end.jpg"
],
"duration": 8,
"quality": "1080p"
}
)
マルチモーダルの例
# Combine image, video, and audio references with @tags
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json={
"model": "seedance-2.0",
"prompt": "@Image1 as first frame, replicate @Video1 camera movement, @Audio1 for BGM rhythm. A cinematic night cityscape.",
"image_urls": ["https://example.com/scene.jpg"],
"video_urls": ["https://example.com/camera-ref.mp4"],
"audio_urls": ["https://example.com/bgm.mp3"],
"duration": 10,
"quality": "1080p"
}
)
コールバック URL の使用例
# Use callback_url instead of polling
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json={
"model": "seedance-2.0",
"prompt": "A cat playing piano",
"callback_url": "https://yourapp.com/api/video-callback"
}
)
# Your callback endpoint will receive the task result when complete
OpenAI 互換
この API は OpenAI 互換の規約に準拠しています。既存の HTTP クライアントライブラリをそのまま使用できます。ベース URL を https://api.evolink.ai に設定するだけです。