SDK 및 코드 예제
Seedance 2.0 API는 표준 REST 인터페이스를 사용합니다. 아래는 주요 프로그래밍 언어별 전체 통합 예제입니다.
Base 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 클라이언트 라이브러리를 그대로 사용할 수 있습니다 -- base URL만 https://api.evolink.ai로 설정하세요.
관련 문서
- 빠른 시작 -- 시작하기
- 인증 -- API 키 설정
- 비디오 생성 API -- 전체 파라미터 레퍼런스