Wan 2.6 の画像・参照動画(R2V)API で精密な映像パイプラインを構築する
対象モデル:
wan2.6(任意の Flash ID:wan2.6-flash)
推論エンドポイント:https://toapis.com/v1/videos/generations
関連: OpenAI Sora 2 API ガイド · Alibaba Wan 3.0 動画 API クイックスタート · Wan 3.0 Prime と Wan 2.6 Flash の比較 · MiniMax H3 自動 R2V パイプライン · Wan 2.6 リファレンス · Wan 2.6 Flash リファレンス · wan2.6 モデルガイド · wan2.6-flash モデルガイド
1. TL;DR と能力の概要
- まずカタログを確認する: 計画草稿は「Wan 2.6 R2V」を公開モデル
wan-2-6-r2vとして扱ったり、パイプライン全体をwan-2-6-flashに向けたりすることがあります。2026-11-23 に公式の Wan 2.6 生成リファレンス(HTTP 200)を確認すると、公開 ID はwan2.6です。公式の Flash 生成リファレンス(HTTP 200)はwan2.6-flashを示します。パス/videos/wan2.6-r2v/generationは HTTP 404 でした。/model-guide/wan2-6-r2vは HTTP 200 でもタイトルが “Model Guide Not Found” で、実在するガイドではありません。同日のtoapis.com/sitemap.xmlには、この系列としてwan2-6とwan2-6-flashのみがありました。 - ここでの “R2V” の意味:
wan2.6でmetadata.reference_urls(公開動画 URL)を送ると参照動画(r2v)モードになります。公式ページによれば、サーバーは上流モデルwan2.6-r2vにルーティングします。それでもmodel: "wan2.6"を送ります。画像から動画はimage_urls(画像 1 枚)です。prompt のみのリクエストはテキストから動画です。image_urlsとmetadata.reference_urlsは併用できないため、これら 3 モードは実質的に排他です。 - 契約:
POST /v1/videos/generationsに非同期送信し、completedまたはfailedまでGET /v1/videos/generations/{id}をポーリングします。通常タスクはGET /v1/tasks/{id}でも照会できます。公式例はhttps://toapis.com(中国本土はhttps://toapis.cn)です。本シリーズの以前の記事ではhttps://api.toapis.comを使うこともあります。オリジンは一つに揃えてください。本稿は公式例に従います。 - Flash は別 ID です:
wan2.6-flashは画像から動画と参照動画のみです。テキストのみの生成は未サポートで、prompt のみのリクエストはエラーになります。Flash は無音動画(audio: false)を、文書化された別単価で生成できます。非 Flash のwan2.6は既定で常に音声を含みます。 - 捨てるべき未確認の主張:
motion_amplitude、$0.018や$0.030毎秒、レイテンシや SLA の数字は、現行の ToAPIs ドキュメントではありません。料金はアカウントカタログで確認してください。
2. 公式の Wan 2.6 ID、ルーティング、パラメータ規則
model フィールドには公開モデル名を使います。草稿の別名に置き換えないでください。上流名 wan2.6-r2v も、後続の公式ページが公開カタログ文字列として掲載しない限り送らないでください。2026-11-23 の生成リファレンスには載っていません。
| カタログ ID | 本ガイドでの役割 | 文書化されたジョブ |
|---|---|---|
wan2.6 | 既定の公開 ID | テキストから動画(prompt のみ)、画像から動画(image_urls)、参照動画 / R2V(metadata.reference_urls) |
wan2.6-flash | 別の Flash 公開 ID | 画像から動画と参照動画のみ。prompt のみは失敗する |
wan3.0-video | 後続の関連 Wan ID。Wan 3.0 クイックスタート を参照 | 別の All-in-One パラメータ(先頭・末尾フレームを含む)。Wan 3.0 のフィールドを Wan 2.6 に混ぜない |
wan2.6(および対応する Flash)は送信したメディアでルーティングします。
| 指定したパラメータ | 上流モード |
|---|---|
metadata.reference_urls(動画 URL) | 参照動画(r2v)。Flash は wan2.6-r2v-flash へ |
image_urls(画像 1 枚) | 画像から動画(i2v) |
prompt のみ | wan2.6 ではテキストから動画(t2v)。wan2.6-flash ではエラー |
wan2.6 の文書化フィールドには、prompt(テキストから動画では必須。i2v と r2v では任意で、期待する動きやスタイルを書く)、image_urls(公開の http:// または https:// 画像 URL 最大 1 件。base64 は非対応。先に Upload Image API を使う)、aspect_ratio(16:9、9:16、1:1、4:3、3:4。画像から動画では非対応)、resolution(720p または 1080p、既定 1080p。480p は非対応)、duration(5、10、15、既定 5)、negative_prompt、seed、prompt_extend(既定 true)、audio(非 Flash は既定で常に音声を含む。明示的に有効化するなら true)、shot_type(single または multi。テキストから動画と参照動画のみ)、watermark、metadata.reference_urls(公開動画 URL。「複数」の参照動画に対応。image_urls と併用不可)があります。
Flash リファレンスはより狭いです。model は wan2.6-flash に固定、image_urls か metadata.reference_urls のいずれかが必須、prompt は任意、さらに resolution、duration、audio(既定 true。false は無音で別料金)、watermark、metadata.reference_urls が記載されています。そのページに aspect_ratio、shot_type、negative_prompt、seed、prompt_extend の記載はありません。

図 1: 文書化された wan2.6 または wan2.6-flash のペイロードを POST /v1/videos/generations に送ります。image_urls と metadata.reference_urls は併用できません。同じタスク id をポーリングし、status が completed になってから result.data[0].url を読んでください。
公式の wan2.6 解像度とアスペクト比のサイズ表は次のとおりです。
| アスペクト比 | 説明 | 720p サイズ | 1080p サイズ |
|---|---|---|---|
| 16:9 | 横位置(既定) | 1280×720 | 1920×1080 |
| 9:16 | 縦位置 | 720×1280 | 1080×1920 |
| 1:1 | 正方形 | 960×960 | 1440×1440 |
| 4:3 | 横位置 | 1088×832 | 1632×1248 |
| 3:4 | 縦位置 | 832×1088 | 1248×1632 |
3. 本番実装: cURL と Python
スニペットは公式例の https://toapis.com に従います。中国本土から呼ぶ場合はオリジンを https://toapis.cn に替えてください。本番投入前に、アカウント向け API リファレンスで id、result.data[0].url、応答エンベロープを確認してください。
ステップ 1: 画像から動画と参照動画の cURL
wan2.6 の画像から動画(このモードでは aspect_ratio を送らない):
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "wan2.6",
"prompt": "The product rotates slowly under studio lighting, camera locked off",
"image_urls": ["https://example.com/product.jpg"],
"resolution": "1080p",
"duration": 5
}'
同じ公開 ID での参照動画(R2V)。返却された id を保存します。
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "wan2.6",
"prompt": "The character waves and smiles at the camera",
"metadata": {
"reference_urls": ["https://cdn.example.com/ref-character.mp4"]
},
"shot_type": "single",
"aspect_ratio": "16:9",
"resolution": "1080p",
"duration": 5
}'
Flash の画像から動画プレビュー(無音。文書上の単価は低い)は、もう一方の公開 ID を使います。
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "wan2.6-flash",
"prompt": "The person comes alive and smiles at the camera",
"image_urls": ["https://example.com/portrait.jpg"],
"resolution": "720p",
"duration": 5,
"audio": false
}'
ステップ 2: Python ヘルパーとポーラー
import os
import time
import requests
API_KEY = os.environ["TOAPIS_API_KEY"]
BASE = "https://toapis.com"
ENDPOINT = f"{BASE}/v1/videos/generations"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
DOCUMENTED_IDS = {"wan2.6", "wan2.6-flash"}
RESOLUTIONS = {"720p", "1080p"}
DURATIONS = {5, 10, 15}
ASPECTS = {"16:9", "9:16", "1:1", "4:3", "3:4"}
SHOT_TYPES = {"single", "multi"}
def dispatch_wan26(
prompt: str | None = None,
*,
model: str = "wan2.6",
image_urls: list[str] | None = None,
reference_urls: list[str] | None = None,
aspect_ratio: str | None = None,
resolution: str = "1080p",
duration: int = 5,
negative_prompt: str | None = None,
seed: int | None = None,
prompt_extend: bool | None = None,
audio: bool | None = None,
shot_type: str | None = None,
watermark: bool | None = None,
) -> str:
if model not in DOCUMENTED_IDS:
raise ValueError("Send wan2.6 or wan2.6-flash; wan-2-6-r2v is not a documented public ID")
if duration not in DURATIONS:
raise ValueError("duration must be 5, 10, or 15")
if resolution not in RESOLUTIONS:
raise ValueError("resolution must be 720p or 1080p")
if image_urls and reference_urls:
raise ValueError("image_urls cannot be combined with metadata.reference_urls")
if image_urls and len(image_urls) != 1:
raise ValueError("image_urls is documented as supporting only 1 image")
if model == "wan2.6-flash" and not image_urls and not reference_urls:
raise ValueError("wan2.6-flash requires image_urls or metadata.reference_urls")
if model == "wan2.6" and not prompt and not image_urls and not reference_urls:
raise ValueError("wan2.6 needs a prompt, an image, or reference video URLs")
if image_urls and aspect_ratio:
raise ValueError("aspect_ratio is not supported in image-to-video mode on wan2.6")
if aspect_ratio and aspect_ratio not in ASPECTS:
raise ValueError("unsupported aspect_ratio")
if shot_type and shot_type not in SHOT_TYPES:
raise ValueError("shot_type must be single or multi")
if image_urls and shot_type:
raise ValueError("shot_type applies to text-to-video and reference-video modes only")
payload: dict = {
"model": model,
"resolution": resolution,
"duration": duration,
}
if prompt:
payload["prompt"] = prompt
if image_urls:
payload["image_urls"] = image_urls
if reference_urls:
payload["metadata"] = {"reference_urls": reference_urls}
if aspect_ratio:
payload["aspect_ratio"] = aspect_ratio
if negative_prompt:
payload["negative_prompt"] = negative_prompt
if seed is not None:
payload["seed"] = seed
if prompt_extend is not None:
payload["prompt_extend"] = prompt_extend
if audio is not None:
payload["audio"] = audio
if shot_type:
payload["shot_type"] = shot_type
if watermark is not None:
payload["watermark"] = watermark
res = requests.post(ENDPOINT, headers=HEADERS, json=payload, timeout=30)
res.raise_for_status()
data = res.json()
task_id = data.get("id") or data.get("task_id")
if not task_id:
raise RuntimeError(f"Unexpected submission envelope: {data}")
return task_id
def poll_task(task_id: str, deadline_s: int = 900) -> str:
poll_url = f"{BASE}/v1/videos/generations/{task_id}"
interval = 10.0
start = time.time()
time.sleep(5)
while time.time() - start < deadline_s:
poll = requests.get(poll_url, headers=HEADERS, timeout=15)
if poll.status_code == 429:
retry_after = poll.headers.get("Retry-After")
time.sleep(float(retry_after) if retry_after else min(interval * 2, 120))
continue
poll.raise_for_status()
data = poll.json()
status = data.get("status")
if status == "completed":
return data["result"]["data"][0]["url"]
if status == "failed":
raise RuntimeError(f"Generation failed: {data.get('error')}")
time.sleep(interval)
interval = min(interval * 1.5, 30.0)
raise TimeoutError(f"Task {task_id} exceeded {deadline_s}s; check status before retrying")
if __name__ == "__main__":
task_id = dispatch_wan26(
"The character waves and smiles at the camera",
reference_urls=["https://cdn.example.com/ref-character.mp4"],
shot_type="single",
aspect_ratio="16:9",
resolution="1080p",
duration=5,
)
print("Task:", task_id)
print("Video:", poll_task(task_id))
expires_at の前にファイルをダウンロードしてください。動画タスク状態リファレンスは 30 日の保持を文書化しています。wan2.6 で既定の prompt_extend を有効のままにすると、公式ページはシステムがプロンプトを自動で最適化・拡充すると述べていますが、計測された遅延は公表していません。
4. エラー処理と状態マトリクス
次の分類は診断の出発点であり、ToAPIs のエラーコードを保証するものではありません。HTTP 照会が成功しても、タスクの status を読む必要があります。リクエストエラーと status: failed の理由はエラーリファレンスを参照してください。
| HTTP またはタスク状態 | よくある分類 | 推奨アクション |
|---|---|---|
400 | 未知のモデル別名、image_urls と metadata.reference_urls の混在、Flash の prompt のみ、または i2v での aspect_ratio | wan2.6 または wan2.6-flash を送り、排他的なメディアを一方に絞り、公開 URL のみを使う |
401 | API キー欠落または無効 | ToAPIs ダッシュボードでキーをローテーションし、Authorization: Bearer ヘッダーを確認する |
429 | レートまたは同時実行制限 | Retry-After があれば従い、ジッター付きでバックオフし、安全なときだけ再試行する |
5xx またはクライアントタイムアウト | 一時的なゲートウェイまたは上流の問題 | 再投入する前に既存のタスク id を照会する |
status: queued または in_progress | エラーではない | 待って再びポーリングする |
status: failed | 生成が成功しなかった | error.code と error.message(あれば error.reason)を読む。ポリシー拒否のペイロードをそのまま再送しない |
5. 価格と FinOps
公式の Wan 2.6 生成リファレンスに単価表はありません。秒課金であること、解像度によって価格が異なること、モデルマーケットプレイスを参照することが書かれています。公式 Flash 生成リファレンスには “Audio vs Silent Pricing” 表があり、2026-11-23 に再確認した内容は次のとおりです。
| モード | 720p 単価 | 1080p 単価 |
|---|---|---|
音声あり(audio: true) | ¥0.3 / 秒 | ¥0.5 / 秒 |
無音(audio: false) | ¥0.15 / 秒 | ¥0.25 / 秒 |
2026-11-23 取得のモデルガイドは、wan2.6 が 12 credits / 秒、wan2.6-flash が 6 credits / 秒 という価格参考を示し、最終課金は現行のアカウント見積もりと duration・resolution 規則に従うと述べています。credits と Flash の円表はスナップショットであり、すべてのモードの契約ではありません。credits を独自に通貨換算せず、草稿のドル単価も再利用しないでください。
- Flash での試作は、ジョブが画像から動画または参照動画のときに限る。 テキストのみの案件は
wan2.6-flash向きではありません。 - Flash で音声を切るのは、無音出力が目的のときだけ。 公式表では無音の単価が低いです。非 Flash の
wan2.6は既定で常に音声を含み、生成ページに対応する円表はありません。 - 表示価格はチャネルの保証ではありません。 バッチを見積もる前に、アカウントカタログで ID と現行見積もりを確認してください。
6. よくある質問
frontmatter の FAQ を参照してください。要約: wan2.6 または wan2.6-flash を送り、wan-2-6-r2v は使わない。image_urls と metadata.reference_urls は混在させない。motion_amplitude は未文書化。duration は 5、10、15 秒。生成ステータスパスをポーリングし、タスク id を保存する。
7. 実行チェックリスト
-
wan2.6またはwan2.6-flashを送る。wan-2-6-r2vやwan-2-6-flashなどの草稿別名は使わない。 - モードは一つにする。prompt のみ(
wan2.6)、公開画像 URL 1 件、または公開参照動画 URL。同一リクエストに画像と参照動画を混ぜない。 - ローカルメディアは先にアップロードし、
http(s)URL のみを渡す。base64 は送らない。 - 画像から動画のリクエストでは
aspect_ratioとshot_typeを省略する。 - タスク
idを保存し、GET /v1/videos/generations/{id}をポーリングし、completedのあとだけresult.data[0].urlを読む。 - 料金は現行アカウント見積もりに従う。2026-11-23 の Flash 円表と credits スナップショットは日付付きの参考に限る。
-
expires_atの前に動画をダウンロードする(文書上の保持は 30 日)。