SDK とサンプルコード

Seedance 2.0 API は標準的な REST インターフェースを採用しており、SDK なしで任意の HTTP クライアントから呼び出せます。このページでは 3 つの生成モードすべてに対応するコピペ可能なコードを提供します。

ベース URL

https://api.evolink.ai

すべての例で export EVOLINK_API_KEY="your-api-key-here" が設定済みであることを前提とします。

Text-to-Video

Python

import os
import time
import requests

API_KEY = os.environ["EVOLINK_API_KEY"]
BASE_URL = "https://api.evolink.ai"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# 1. タスクを作成
response = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers=headers,
    json={
        "model": "seedance-2.0-text-to-video",
        "prompt": "A cinematic sunset over the ocean, wide shot",
        "duration": 5,
        "quality": "720p",
        "aspect_ratio": "16:9"
    }
)
task_id = response.json()["id"]
print(f"Task created: {task_id}")

# 2. ポーリング
while True:
    result = requests.get(f"{BASE_URL}/v1/tasks/{task_id}", headers=headers).json()

    if result["status"] == "completed":
        print(f"Video URL: {result['results'][0]}")
        break
    if result["status"] == "failed":
        print("Generation failed")
        break

    print(f"Progress: {result['progress']}%")
    time.sleep(5)

Node.js

const API_KEY = process.env.EVOLINK_API_KEY;
const BASE_URL = "https://api.evolink.ai";

const headers = {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json"
};

// 1. タスクを作成
const createRes = await fetch(`${BASE_URL}/v1/videos/generations`, {
    method: "POST",
    headers,
    body: JSON.stringify({
        model: "seedance-2.0-text-to-video",
        prompt: "A cinematic sunset over the ocean, wide shot",
        duration: 5,
        quality: "720p",
        aspect_ratio: "16:9"
    })
});
const { id: taskId } = await createRes.json();
console.log(`Task created: ${taskId}`);

// 2. ポーリング
while (true) {
    const res = await fetch(`${BASE_URL}/v1/tasks/${taskId}`, { headers });
    const result = await res.json();

    if (result.status === "completed") {
        console.log(`Video URL: ${result.results[0]}`);
        break;
    }
    if (result.status === "failed") {
        console.log("Generation failed");
        break;
    }

    console.log(`Progress: ${result.progress}%`);
    await new Promise(r => setTimeout(r, 5000));
}

cURL

# 1. タスクを作成
curl -X POST https://api.evolink.ai/v1/videos/generations \
  -H "Authorization: Bearer $EVOLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-2.0-text-to-video",
    "prompt": "A cinematic sunset over the ocean, wide shot",
    "duration": 5,
    "quality": "720p"
  }'

# レスポンス: {"id": "task-unified-...", "status": "pending", ...}

# 2. ステータスを取得
curl https://api.evolink.ai/v1/tasks/TASK_ID \
  -H "Authorization: Bearer $EVOLINK_API_KEY"

Image-to-Video

最初フレームモード(画像 1 枚)

response = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers=headers,
    json={
        "model": "seedance-2.0-image-to-video",
        "prompt": "The model slowly turns, hair flowing gently in the wind",
        "image_urls": ["https://example.com/portrait.jpg"],
        "duration": 5,
        "quality": "720p",
        "aspect_ratio": "adaptive"
    }
)

最初・最後フレームのトランジション(画像 2 枚)

response = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers=headers,
    json={
        "model": "seedance-2.0-image-to-video",
        "prompt": "A smooth transition from sunrise to sunset over the same ocean",
        "image_urls": [
            "https://example.com/sunrise.jpg",
            "https://example.com/sunset.jpg"
        ],
        "duration": 6,
        "quality": "720p"
    }
)

Reference-to-Video

1 リクエストで画像、動画、音声の参照素材を組み合わせます。

response = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers=headers,
    json={
        "model": "seedance-2.0-reference-to-video",
        "prompt": (
            "Replicate video 1's first-person perspective and pacing; "
            "use audio 1 as background music throughout. "
            "Scene: a young rider weaving through rain-soaked city streets "
            "at night, neon reflections on wet asphalt."
        ),
        "image_urls": ["https://example.com/rider-style.jpg"],
        "video_urls": ["https://example.com/pov-reference.mp4"],
        "audio_urls": ["https://example.com/synthwave-bgm.mp3"],
        "duration": 10,
        "quality": "720p",
        "aspect_ratio": "16:9"
    }
)

注意: reference-to-video には @Image1@Video1 のようなタグ構文は 存在しません。各素材の役割は通常の自然言語で記述してください。

Fast モデルの利用

model フィールドを seedance-2.0-xxx から seedance-2.0-fast-xxx に置き換えるだけです。他のすべてのパラメータはそのまま維持できます。

response = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers=headers,
    json={
        "model": "seedance-2.0-fast-text-to-video",  # ← この行のみ変更
        "prompt": "A cinematic sunset over the ocean, wide shot",
        "duration": 5,
        "quality": "720p"
    }
)

Fast モデル を参照してください。

ポーリングの代わりに Webhook を使う

response = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers=headers,
    json={
        "model": "seedance-2.0-text-to-video",
        "prompt": "A cat playing piano",
        "duration": 5,
        "callback_url": "https://yourapp.com/api/video-callback"
    }
)
# Webhook エンドポイントには、タスク取得エンドポイントと同じボディ形状の POST が届きます

Webhook を参照してください。

OpenAI スタイルの規約

API は OpenAI スタイルの REST 規約(Bearer トークン、JSON ボディ、統一されたレスポンススキーマ)に従います。任意の HTTP クライアントライブラリで利用でき、専用 SDK は不要です。

関連