動画タスクの作成
Seedance API(v3)
https://api.tokenlio.ai とプラットフォーム Bearer Key、現在の一覧にある正確な model ID を使用します。詳細なフィールドは公式資料も参照でき、呼び出しには本ページのアドレス・認証・例を使用してください。
model/contentを送信して動画タスクを作成します。HTTP200/idは受付であり、最終結果は照会またはコールバックで取得します。
リクエストパラメータ
| フィールド | 型 | 既定値 | 説明 |
|---|---|---|---|
model | string | 必須 | 現在の一覧の正確な公開モデル ID。モデルと入力を参照。 |
content | object[] | 必須 | 空でないテキスト・メディア配列。 |
resolution | string | 720p | モデルが対応する出力解像度。 |
ratio | string | adaptive | 16:9、9:16、3:4、1:1、4:3、21:9、adaptive。Mini の adaptive は対応時のみ。 |
duration | integer | モデル既定値 | 2.0 系 4〜15 秒、2.5 は 4〜30 秒。-1 は自動選択。2.5 の既定値は -1、Mini の -1 は対応時のみ。 |
generate_audio | boolean | true | 音声生成。Fast/Mini の例は false。音声生成は対応時のみ。 |
return_last_frame | boolean | false | 対応時に末尾フレーム URL を返す。 |
watermark | boolean | false | 生成コンテンツの透かし。 |
seed | integer | — | 乱数シード。同一出力の保証なし。 |
output_format | string | mp4 | 2.5 は mov も対応。 |
priority | integer | 0 | 0〜9。 |
execution_expires_after | integer | 172800 | 有効期間(秒)、3600〜259200。 |
tools | object[] | — | テキスト入力のみ。{"type":"web_search"} を最大 1 件。 |
omni_reference_task_type | string | auto | 2.5 の auto / reference。edit / extend は対応時のみ。 |
draft | boolean | false | 2.5 ドラフト。対応時のみ。 |
callback_url | string | — | public HTTPS 生成コールバック。プラットフォームのタスクを配信し、X-Tokenlio-Event-Id で冪等処理。 |
JSON フィールドは大文字小文字を区別します。真偽値と整数を正しい型で指定し、未使用フィールドは省略してください。本文は 64 MiB 以内。作成・単一照会・DELETEにクエリはありません。一覧パラメータはタスク管理を参照。
content 要素
| type | 値 | role |
|---|---|---|
text | text | — |
image_url | image_url.url | reference_image、first_frame、last_frame |
video_url | video_url.url | reference_video |
audio_url | audio_url.url | reference_audio |
draft_task | draft_task.id | — |
role はメディアオブジェクトと同じ階層です。公開 HTTPS URL または asset://ASSET_ID を利用でき、画像は image_url.url に Base64 Data URL を直接指定することもできます。画像入力を参照してください。メディア URL に API Key を含めないでください。先頭・末尾フレームと参照素材は併用不可。2.0 系の参照音声には画像または動画が必要で、2.5 は音声だけの参照に対応します。2.5 の先頭・末尾フレームは ratio=adaptive。
画像入力:URL・Base64・素材 ID
先頭フレーム、末尾フレーム、参照画像の content[].image_url.url は次の 3 形式に対応します。
| 方式 | image_url.url の値 | 使い方 |
|---|---|---|
| 公開画像 URL | https://example.com/valley.png | 直接アクセスでき、処理中も有効な画像 URL。 |
| ローカル画像の Base64 | data:image/png;base64,<完全なBase64データ> | ファイルをエンコードして JSON に埋め込みます。事前の画像ホスティングや CreateAsset は不要です。 |
| 素材 ID | asset://ASSET_ID | 既存素材を参照します。素材管理を参照。 |
完全な形式 data:image/<画像形式>;base64,<Base64データ> を使用します。画像形式は小文字で実際のファイルと一致させ、PNG は image/png、JPEG は image/jpeg、WebP は image/webp とします。裸の Base64、ローカルパス、file:// URL は Data URL の代わりにはなりません。標準 Base64 を改行のない連続文字列にし、例のプレースホルダーはすべて置き換えてください。
画像要件は公式作成 APIに基づきます。
- 形式:
jpeg、png、webp、bmp、tiff、gif。Seedance 2.0 以降はheic、heifも対応。 - 画像 1 枚は 30 MB 未満。幅と高さはそれぞれ 300–6000 px、幅/高さの比率は 0.4–2.5。
- プラットフォームの生成リクエスト上限は 64 MiB。JSON、すべてのエンコード済み画像、その他のフィールドを含みます。Base64 のサイズは元ファイルの約 4/3 になるため、複数画像は合計し、大きなファイルには公開 URL または素材 ID を推奨します。
- エンコードしても素材数・role・モデル制限は変わりません。モデルと入力を参照してください。
first_frameは開始フレーム、reference_imageは生成の参照です。参照画像と先頭・末尾フレームは併用できません。
完全な例はローカル画像の Base64 動画生成を参照してください。画像の埋め込み先は生成リクエストであり、素材 Action のアップロードではありません。素材 Action の 32 KiB 制限はこの生成リクエストには適用されません。
作成と照会
curl -sS --fail-with-body "https://api.tokenlio.ai/api/v3/contents/generations/tasks" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "A ceramic teapot in soft window light, slow camera orbit"
}
],
"resolution": "1080p",
"duration": 5,
"generate_audio": false
}'
curl -sS --fail-with-body "https://api.tokenlio.ai/api/v3/contents/generations/tasks/TASK_ID" \
-H "Authorization: Bearer $TOKENLIO_API_KEY"作成レスポンス:
{
"id": "dfc68868-d388-4d83-a173-d44e47a8bec7"
}入力・モードの例
以下の JSON は同じ作成 API に送信します。URL と ID は利用可能な素材・タスクに置き換えてください。モデルの制限も確認してください。
先頭フレーム
{
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "The camera slowly approaches the subject"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/first.png"
},
"role": "first_frame"
}
],
"duration": 5,
"generate_audio": false
}先頭・末尾フレーム
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "A smooth transition from sunrise to evening"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/first.png"
},
"role": "first_frame"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/last.png"
},
"role": "last_frame"
}
],
"ratio": "adaptive",
"duration": 8,
"generate_audio": false
}参照画像
{
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "Use the character from image 1 walking through a garden"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/character.png"
},
"role": "reference_image"
}
],
"duration": 5,
"generate_audio": false
}ローカル画像の Base64 動画生成
Python 3 標準ライブラリでローカル PNG を読み込み、request.json を作成します。この手順はローカル処理のみで、生成を開始しません。./valley.png を自分の画像に置き換えてください。JPEG を使う場合は Data URL の接頭辞も data:image/jpeg;base64, に変更します。拡張子の変更だけでは不十分です。
import base64
import json
from pathlib import Path
image = Path("./valley.png").read_bytes()
if not image or len(image) >= 30_000_000:
raise ValueError("Image must be nonempty and smaller than 30 MB")
payload = {
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "Use the reference valley, lake and clouds. Cloud shadows move slowly, subtle ripples cross the water, and the camera steadily advances. Natural, realistic footage.",
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64," + base64.b64encode(image).decode("ascii")
},
"role": "reference_image",
},
],
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"generate_audio": False,
}
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
if len(body) > 64 * 1024 * 1024:
raise ValueError("Encoded request exceeds 64 MiB; use a URL or asset ID")
Path("request.json").write_bytes(body)パラメータを確認してから次のコマンドで実際の生成リクエストを送信します。実際の使用量に応じて課金されます。--data-binary @request.json で本文全体を読み込み、大きな Base64 をコマンドライン引数に含めずに送信できます。
curl -sS --fail-with-body "https://api.tokenlio.ai/api/v3/contents/generations/tasks" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $SEEDANCE_REQUEST_ID" \
--data-binary @request.json事前にプラットフォーム Key と、この意図に固有の SEEDANCE_REQUEST_ID を設定してください。復元時は同じ冪等キーと元の request.json を保持し、新しい意図には新しいキーを使います。作成を自動再送しないでください。受付時は {"id":"プラットフォームUUID"} が返ります。保存してタスク照会で状態と content.video_url を取得します。受付は生成完了ではありません。
元画像から動画を開始する場合は reference_image を first_frame に変更します。Seedance 2.5 の先頭フレームでは ratio:"adaptive" も必要です。request.json は画像全体を含むため、原素材と同様に保管し、ログやソース管理に含めないでください。
参照動画
{
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "Follow the camera movement in video 1 in a snowy street"
},
{
"type": "video_url",
"video_url": {
"url": "https://example.com/movement.mp4"
},
"role": "reference_video"
}
],
"duration": 5,
"generate_audio": false
}画像・動画・音声の参照
{
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "Use the character from image 1, the motion from video 1 and the rhythm of audio 1"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/character.png"
},
"role": "reference_image"
},
{
"type": "video_url",
"video_url": {
"url": "https://example.com/movement.mp4"
},
"role": "reference_video"
},
{
"type": "audio_url",
"audio_url": {
"url": "https://example.com/rhythm.mp3"
},
"role": "reference_audio"
}
],
"duration": 8,
"generate_audio": false
}2.5 の音声のみの参照
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "An abstract landscape whose movement follows the rhythm of audio 1"
},
{
"type": "audio_url",
"audio_url": {
"url": "https://example.com/rhythm.mp3"
},
"role": "reference_audio"
}
],
"duration": 10,
"generate_audio": false
}素材 ID の参照
{
"model": "seedance-2.0-mini",
"content": [
{
"type": "text",
"text": "The referenced character waves at the camera"
},
{
"type": "image_url",
"image_url": {
"url": "asset://ASSET_ID"
},
"role": "reference_image"
}
],
"resolution": "720p",
"duration": 5,
"generate_audio": false
}素材の作成は素材・人物認証 Actionに記載します。
Web 検索
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "A documentary-style introduction to the city described in the prompt"
}
],
"tools": [
{
"type": "web_search"
}
],
"duration": 10,
"generate_audio": false
}末尾フレームの出力
{
"model": "seedance-2.0",
"content": [
{
"type": "text",
"text": "A boat arrives at a quiet dock"
}
],
"duration": 5,
"return_last_frame": true,
"generate_audio": false
}成功時に content.last_frame_url を取得します。
MOV 出力
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "A slow overhead shot of a forest canopy"
}
],
"duration": 8,
"output_format": "mov",
"generate_audio": false
}長いシーン
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "A continuous 20-second shot: a traveler leaves the station, crosses a courtyard and approaches a waiting train"
}
],
"resolution": "1080p",
"duration": 20,
"generate_audio": false
}2.5 の編集・延長
どちらも参照動画と ratio=adaptive が必要です。編集は duration=-1、入力動画は 4〜30 秒。延長はその後の動きを記述します。対応する機能が利用可能な場合に使用できます。
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "Change the setting in video 1 from daytime to sunset"
},
{
"type": "video_url",
"video_url": {
"url": "https://example.com/source.mp4"
},
"role": "reference_video"
}
],
"omni_reference_task_type": "edit",
"ratio": "adaptive",
"duration": -1,
"generate_audio": false
}{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "Continue video 1 as the subject turns and walks toward the sea"
},
{
"type": "video_url",
"video_url": {
"url": "https://example.com/source.mp4"
},
"role": "reference_video"
}
],
"omni_reference_task_type": "extend",
"ratio": "adaptive",
"duration": 8,
"generate_audio": false
}ドラフトから正式動画へ
480p のドラフトを作成し、成功後にその ID を content の唯一の要素として指定します。出力は 1080p。継承する draft、duration、ratio、seed、generate_audio、omni_reference_task_type、tools、bitrate_mode は省略します。ドラフトで末尾フレームを要求しないでください。
{
"model": "seedance-2.5",
"content": [
{
"type": "text",
"text": "A cinematic tracking shot through a bamboo forest"
}
],
"draft": true,
"resolution": "480p",
"duration": 5,
"generate_audio": false
}{
"model": "seedance-2.5",
"content": [
{
"type": "draft_task",
"draft_task": {
"id": "dfc68868-d388-4d83-a173-d44e47a8bec7"
}
}
],
"resolution": "1080p"
}