Skip to content

빠른 시작 ​

Seedance API(v3)

https://api.tokenlio.ai와 플랫폼 Bearer Key, 현재 목록의 정확한 model ID를 사용하세요. 상세 필드는 공식 자료를 참고할 수 있으며 호출 주소·인증·예시는 본문을 따르세요.

텍스트로 영상 하나를 생성하고 id를 저장한 뒤 같은 작업을 조회하세요. 에셋 관리와 인물 인증은 필요에 따른 흐름이며 일반 생성의 전제 조건이 아닙니다.

목표별 연동 흐름 ​

목표읽는 순서
첫 영상 생성동영상 작업 생성 → 작업 조회와 관리
이미지·동영상·오디오 에셋 재사용에셋 그룹과 에셋 관리 → 동영상 작업 생성
인물 에셋 인증인물 에셋 인증 → 에셋 그룹과 에셋 관리 → 동영상 작업 생성
생성 결과 알림 수신생성 결과 콜백 → 작업 조회와 관리
Agent 호출 편성Agent 연동 가이드 → 호출 규칙

빠른 시작 ​

TOKENLIO_API_KEY와 이번 새 생성 의도에 고정할 TOKENLIO_IDEMPOTENCY_KEY를 설정하세요. 새 의도에만 새 키를 사용하고 결과 불명 복구에는 원래 키/본문을 유지합니다. 예시는 실제 생성을 수행하므로 먼저mock으로 로직을 검증하세요.

bash
# 1. 동영상 작업 생성
curl -sS --fail-with-body -X POST "https://api.tokenlio.ai/api/v3/contents/generations/tasks" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ${TOKENLIO_IDEMPOTENCY_KEY:?Set a stable intent key}" \
  --data '{
    "model": "seedance-2.0",
    "content": [
      {
        "type": "text",
        "text": "비가 갠 웅덩이를 종이배가 떠가고 카메라가 천천히 다가간다"
      }
    ],
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5,
    "generate_audio": false
  }'

# 2. 작업 조회. TASK_ID는 생성 응답의 id
curl -sS --fail-with-body -X GET "https://api.tokenlio.ai/api/v3/contents/generations/tasks/TASK_ID" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY"
python
import os
import time
import requests

BASE_URL = "https://api.tokenlio.ai"
headers = {
    "Authorization": f"Bearer {os.environ['TOKENLIO_API_KEY']}",
    "Content-Type": "application/json",
    "Idempotency-Key": os.environ["TOKENLIO_IDEMPOTENCY_KEY"],
}

# 1. 동영상 작업 생성
payload = {
    "model": "seedance-2.0",
    "content": [
        {
            "type": "text",
            "text": "비가 갠 웅덩이를 종이배가 떠가고 카메라가 천천히 다가간다"
        }
    ],
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5,
    "generate_audio": False
}
response = requests.post(
    f"{BASE_URL}/api/v3/contents/generations/tasks",
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
task_id = response.json()["id"]
print("Task ID:", task_id)

# 작업 조회
while True:
    time.sleep(5)
    response = requests.get(
        f"{BASE_URL}/api/v3/contents/generations/tasks/{task_id}",
        headers=headers,
        timeout=30,
    )
    response.raise_for_status()
    task = response.json()
    if task["status"] == "succeeded":
        print("동영상 URL:", task["content"]["video_url"])
        break
    if task["status"] in {"failed", "cancelled", "expired"}:
        print("작업 상태:", task["status"], task.get("error"))
        break
javascript
const baseUrl = "https://api.tokenlio.ai";
if (!process.env.TOKENLIO_IDEMPOTENCY_KEY) throw new Error("Set a stable intent key");
const headers = {
  Authorization: `Bearer ${process.env.TOKENLIO_API_KEY}`,
  "Content-Type": "application/json",
  "Idempotency-Key": process.env.TOKENLIO_IDEMPOTENCY_KEY,
};

// 1. 동영상 작업 생성
const response = await fetch(`${baseUrl}/api/v3/contents/generations/tasks`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    "model": "seedance-2.0",
    "content": [
      {
        "type": "text",
        "text": "비가 갠 웅덩이를 종이배가 떠가고 카메라가 천천히 다가간다"
      }
    ],
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5,
    "generate_audio": false
  }),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const { id } = await response.json();
console.log("Task ID:", id);

// 작업 조회
while (true) {
  await new Promise(resolve => setTimeout(resolve, 5000));
  const query = await fetch(`${baseUrl}/api/v3/contents/generations/tasks/${id}`, { headers });
  if (!query.ok) throw new Error(`${query.status}: ${await query.text()}`);
  const task = await query.json();
  if (task.status === "succeeded") {
    console.log("동영상 URL:", task.content.video_url);
    break;
  }
  if (["failed", "cancelled", "expired"].includes(task.status)) {
    console.log("작업 상태:", task.status, task.error);
    break;
  }
}

응답 예시 ​

생성 응답 ​

json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7"
}

생성 성공 시 조회 응답 ​

json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7",
  "model": "seedance-2.0",
  "status": "succeeded",
  "content": {
    "video_url": "https://example.com/result.mp4"
  },
  "resolution": "720p",
  "duration": 5,
  "usage": {
    "completion_tokens": 108900,
    "total_tokens": 108900
  }
}

생성은 HTTP 200과 작업 id를 반환합니다. 조회는 상태, 결과 URL, 사용량을 반환합니다. content.video_url은 임시 URL이며 재조회로 갱신되지 않습니다.

다음 단계 ​

통합 인터페이스로 주요 AI 모델에 액세스