すべてのプロダクト
Search
ドキュメントセンター

:Wan - image-to-video - first frame API reference

最終更新日:Apr 21, 2026

Wan 画像動画変換モデルは、最初のフレーム画像テキストプロンプトからスムーズな動画を生成します。

リファレンスユーザーガイド

説明

新しくリリースされた Wanxiang - Image-to-video 2.7 は、最初のフレームからの動画生成、最初と最後のフレームからの動画生成、動画継続生成をサポートしています。こちらを優先的に使用することを推奨します

このトピックの Wan 画像動画変換 モデル (wan2.6 以前) は、最初のフレームからの動画生成のみをサポートしています。

可用性

モデル、エンドポイント URL、API キーは同じリージョンにある必要があります。クロスリージョンでの呼び出しは失敗します。

  • モデルの選択:対象リージョンでモデルが利用可能であることを確認します。

  • URL の選択:対応するリージョンのエンドポイント URL を選択します。HTTP と HTTPS の両方がサポートされています。

  • API キーの設定:リージョンを選択し、API キーを取得し、環境変数に設定します。

  • SDK のインストール:SDK を使用して API を呼び出す場合は、DashScope SDK をインストールします。

説明

このトピックのサンプルコードは、シンガポールリージョンに適用されます。

HTTP

画像動画変換タスクには 1〜5 分かかります。非同期呼び出しを使用してください:タスクを作成し、結果をポーリングします

ステップ 1:タスクの作成

シンガポール

POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis

バージニア

POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis

北京

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis

フランクフルト

POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis

API を呼び出す際は、WorkspaceId を実際のワークスペース ID に置き換えてください。

説明
  • タスクが作成された後、返された task_id を使用して結果をクエリします。task_id は 24 時間有効です。重複したタスクを作成しないでください。代わりに、ポーリングを使用して結果を取得してください。

  • 初心者向けのガイダンスについては、「Postman」をご参照ください。

リクエストパラメーター

マルチショットナラティブ

この機能は wan2.6 モデルでのみサポートされています。

"prompt_extend": true"shot_type":"multi" を設定することで有効になります。

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.6-i2v-flash",
    "input": {
        "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
    },
    "parameters": {
        "resolution": "720P",
        "prompt_extend": true,
        "duration": 10,
        "shot_type":"multi"
    }
}'

自動ダビング

この機能は wan2.6 および wan2.5 モデルでのみサポートされています。

input.audio_url を指定しない場合、モデルは動画コンテンツに基づいて、一致する BGM または効果音を自動的に生成します。

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.5-i2v-preview",
    "input": {
        "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"
    },
    "parameters": {
        "resolution": "480P",
        "prompt_extend": true,
        "duration": 10
    }
}'

音声ファイルの提供

この機能は wan2.6 および wan2.5 モデルでのみサポートされています。

動画に BGM やナレーションを指定するには、カスタム音声ファイルの URL を input.audio_url パラメーターで渡します。

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.5-i2v-preview",
    "input": {
        "prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "img_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"
    },
    "parameters": {
        "resolution": "480P",
        "prompt_extend": true,
        "duration": 10
    }
}'

無音動画の生成

無音動画の生成は、以下のモデルでのみサポートされています:

  • wan2.6-i2v-flash:無音動画を生成するには、明示的に parameters.audio = false を設定する必要があります。

  • wan2.2 および wan2.1 モデル:デフォルトで無音動画が生成されます。追加のパラメーターは必要ありません。

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.2-i2v-plus",
    "input": {
        "prompt": "A cat running on the grass",
        "img_url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
    },
    "parameters": {
        "resolution": "480P",
        "prompt_extend": true
    }
}'

ネガティブプロンプトの使用

negative_prompt パラメーターを使用して、生成される動画に「花」が表示されないようにします。

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.2-i2v-plus",
    "input": {
        "prompt": "A cat running on the grass",
        "negative_prompt": "flowers",
        "img_url": "https://cdn.translate.alibaba.com/r/wanx-demo-1.png"
    },
    "parameters": {
        "resolution": "480P",
        "prompt_extend": true
    }
}'
ヘッダー

Content-Type string (必須)

リクエストのコンテンツタイプです。application/json である必要があります。

Authorization string (必須)

Model Studio API キーでリクエストを認証します。例:Bearer sk-xxxx。

X-DashScope-Async string (必須)

非同期処理を有効にします。HTTP リクエストは非同期呼び出しのみをサポートします。enable である必要があります。

重要

このリクエストヘッダーがない場合、「current user api does not support synchronous calls」というエラーが返されます。

リクエストボディ

model string (必須)

モデル名です。モデルの料金 をご確認ください。

例:wan2.6-i2v-flash。

input object (必須)

プロンプトなどの基本的な入力情報を含みます。

プロパティ

prompt string (任意)

希望する動画のコンテンツと視覚的特徴を記述するテキストプロンプトです。

中国語と英語をサポートします (各文字 = 1 単位、超過したテキストは自動的に切り捨てられます)。モデルごとの文字数制限:

  • wan2.6 および wan2.5 モデル:最大 1,500 文字。

  • wan2.2 および wan2.1 モデル:最大 800 文字。

例:草の上を走る小さな猫。

プロンプトのヒントについては、「テキスト動画変換/画像動画変換プロンプトガイド」をご参照ください。

negative_prompt string (任意)

動画から除外するコンテンツです。

中国語と英語をサポートします。最大 500 文字。超過したテキストは自動的に切り捨てられます。

例:low resolution, error, worst quality, low quality, disfigured, extra fingers, bad proportions。

img_url string (必須)

最初のフレーム画像の URL または Base64 文字列です。

画像の制約:

  • フォーマット:JPEG、JPG、PNG (alpha チャンネルなし)、BMP、WEBP。

  • 解像度:幅と高さの両方が 240〜8,000 ピクセルの範囲内である必要があります。

  • ファイルサイズ:

    • wan2.6 および wan2.5 シリーズモデル:20 MB 以下。

    • wan2.2 および wan2.1 シリーズモデル:10 MB 以下。

サポートされている入力フォーマット:

  1. パブリック URL:

    • HTTP と HTTPS がサポートされています。

    • 例:https://cdn.translate.alibaba.com/r/wanx-demo-1.png。

  2. Base64 エンコードされた画像文字列:

    • データフォーマット:data:{MIME_type};base64,{base64_data}

    • 例:data:image/png;base64,GDU7MtCZzEbTbmRZ...... (長さのため省略)。

    • 詳細については、「入力画像」をご参照ください。

audio_url string (任意)

サポートモデル:wan2.6 および wan2.5。

音声ファイルの URL です。モデルはこの音声と同期して動画を生成します。

サポートされている入力フォーマット:

  1. パブリック URL:

    • HTTP と HTTPS がサポートされています。

    • 例:https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/xxx.mp3。

音声の制約:

  • フォーマット:wav、mp3。

  • 持続時間:3〜30 秒。

  • ファイルサイズ:15 MB 以下。

  • オーバーフロー処理:duration (5 秒または 10 秒) を超える音声は、最初の 5 秒または 10 秒に切り捨てられます。短い音声の場合、残りの動画は無音になります (例:3 秒の音声 + 5 秒の動画 = 3 秒の音声 + 2 秒の無音)。

例:https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3。

parameters object (任意)

動画処理パラメーター (解像度、持続時間、プロンプトリライト、ウォーターマーク) です。

プロパティ

resolution string (任意)

重要

解像度はコストに直接影響します。モデルの料金 をご確認ください

生成される動画の解像度レベルです。モデルは、選択されたレベルのピクセル数に合わせて出力をスケーリングします。アスペクト比は入力画像 (img_url) にほぼ一致しますよくある質問 をご参照ください。

デフォルト値とオプションは model パラメーターによって異なります:

  • wan2.6-i2v-flash:オプション:720P、1080P。デフォルト:1080P

  • wan2.6-i2v:オプション:720P、1080P。デフォルト:1080P

  • wan2.6-i2v-us:オプション:720P、1080P。デフォルト:1080P

  • wan2.5-i2v-preview:オプション:480P、720P、1080P。デフォルト:1080P

  • wan2.2-i2v-flash:オプション:480P、720P。デフォルト:720P

  • wan2.2-i2v-plus:オプション:480P、1080P。デフォルト:1080P

  • wan2.1-i2v-turbo:オプション:480P、720P。デフォルト:720P

  • wan2.1-i2v-plus:オプション:720P。デフォルト:720P

例:1080P。

duration integer (任意)

重要

持続時間はコストに影響します。モデルの料金 をご確認ください

動画の持続時間 (秒) です。有効な値はモデルによって異なります:

  • wan2.6-i2v-flash:2〜15 の整数。デフォルト:5。

  • wan2.6-i2v:2〜15 の整数。デフォルト:5。

  • wan2.6-i2v-us:オプション:5、10、15。デフォルト:5。

  • wan2.5-i2v-preview:オプション:5、10。デフォルト:5。

  • wan2.2-i2v-plus:5 秒に固定 (設定不可)。

  • wan2.2-i2v-flash:5 秒に固定 (設定不可)。

  • wan2.1-i2v-plus:5 秒に固定 (設定不可)。

  • wan2.1-i2v-turbo:オプション:3、4、または 5。デフォルト:5。

例:5。

prompt_extend boolean (任意)

プロンプトリライトを有効にするかどうか。有効にすると、LLM が入力プロンプトを書き換えます。これにより、短いプロンプトの生成品質が向上しますが、処理時間が増加します。

  • true (デフォルト)

  • false

例:true。

shot_type string (任意)

サポートモデル:wan2.6 モデル。

動画が単一の連続したショットを使用するか、複数の切り替えショットを使用するかを指定します。

"prompt_extend": true の場合にのみ有効です。

優先度:shot_type > prompt。例:shot_type="single" は、プロンプトがマルチショットを要求していても、シングルショットの動画を出力します。

有効な値:

  • single (デフォルト)

  • multi

例:single。

説明

このパラメーターを使用して、物語の構造を厳密に制御します。例えば、製品デモにはシングルショット、短編映画にはマルチショットなどです。

audio boolean (任意)

重要

音声設定はコストに影響します (音声あり vs 無音)。呼び出す前にコンソールで料金をご確認ください。

対応モデル: wan2.6-i2v-flash。

音声付きでビデオを生成するかどうかを指定します。

優先度:audio > audio_urlaudio=false は、audio_url が提供されていても無音動画を生成します (無音レートで課金)。

有効な値:

  • true (デフォルト)

  • false

例:true。

watermark boolean (任意)

右下隅に「AI Generated」のウォーターマークを追加します。

  • false (デフォルト)

  • true

例:false。

seed integer (任意)

乱数シードです。値の範囲:[0, 2147483647]

指定しない場合、システムはランダムなシードを生成します。再現性を高めるにはシードを固定してください。

注:同じシードでも、全く同じ結果が保証されるわけではありません (確率的モデルのため)。

例:12345。

レスポンスパラメーター

成功レスポンス

task_id を保存して、タスクのステータスと結果をクエリします。

{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

エラーレスポンス

タスクの作成に失敗しました。「エラーメッセージ」をご参照ください。

{
    "code": "InvalidApiKey",
    "message": "No API-key provided.",
    "request_id": "7438d53d-6eb8-4596-8835-xxxxxx"
}

output object

タスクの出力情報です。

プロパティ

task_id string

タスク ID です。24 時間クエリに有効です。

task_status string

タスクのステータスです。

列挙値

  • PENDING

  • RUNNING

  • SUCCEEDED

  • FAILED

  • CANCELED

  • UNKNOWN:タスクが存在しないか、ステータスが不明です。

request_id string

追跡とトラブルシューティングのためのユニークなリクエスト識別子です。

code string

エラーコードです。失敗したリクエストに対してのみ返されます。「エラーメッセージ」をご参照ください。

message string

詳細なエラーメッセージです。失敗したリクエストに対してのみ返されます。「エラーメッセージ」をご参照ください。

ステップ 2:結果のクエリ

シンガポール

GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id}

バージニア

GET https://dashscope-us.aliyuncs.com/api/v1/tasks/{task_id}

北京

GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}

フランクフルト

GET https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/tasks/{task_id}

API を呼び出す際は、WorkspaceId を実際のワークスペース ID に置き換えてください。

説明
  • ポーリングの推奨:動画生成には数分かかります。15 秒などの適切な間隔でポーリングメカニズムを使用してください。

  • タスクの状態遷移:PENDING → RUNNING → SUCCEEDED または FAILED。

  • 結果リンク:タスクが成功すると、24 時間有効な動画 URL が返されます。動画をダウンロードし、OSS などの永続ストレージに保存してください。

  • task_id の有効期間24 時間。この期間を過ぎると、クエリはタスクステータスを UNKNOWN として返します。

リクエストパラメーター

タスク結果のクエリ

{task_id} を、前の API 呼び出しで返された task_id の値に置き換えてください。task_id は 24 時間クエリに有効です。

curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
ヘッダー

Authorization string (必須)

Model Studio API キーでリクエストを認証します。例:Bearer sk-xxxx。

URL パスパラメーター

task_id string (必須)

タスクの ID です。

レスポンスパラメーター

タスク成功

動画 URL は 24 時間のみ有効で、その後自動的にパージされます。生成された動画は速やかに保存してください。

{
    "request_id": "2ca1c497-f9e0-449d-9a3f-xxxxxx",
    "output": {
        "task_id": "af6efbc0-4bef-4194-8246-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-09-25 11:07:28.590",
        "scheduled_time": "2025-09-25 11:07:35.349",
        "end_time": "2025-09-25 11:17:11.650",
        "orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "video_url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxx"
    },
    "usage": {
        "duration": 10,
        "input_video_duration": 0,
        "output_video_duration": 10,
        "video_count": 1,
        "SR": 720
    }
}

タスク失敗

タスクが失敗すると、task_status は FAILED になり、エラーコードとメッセージが表示されます。「エラーメッセージ」をご参照ください。

{
    "request_id": "e5d70b02-ebd3-98ce-9fe8-759d7d7b107d",
    "output": {
        "task_id": "86ecf553-d340-4e21-af6e-a0c6a421c010",
        "task_status": "FAILED",
        "code": "InvalidParameter",
        "message": "The size is not match xxxxxx"
    }
}

タスククエリ期限切れ

task_id は 24 時間有効です。この期間を過ぎると、クエリは次のエラーを返します。

{
    "request_id": "a4de7c32-7057-9f82-8581-xxxxxx",
    "output": {
        "task_id": "502a00b1-19d9-4839-a82f-xxxxxx",
        "task_status": "UNKNOWN"
    }
}

output object

タスクの出力情報です。

プロパティ

task_id string

タスク ID です。24 時間クエリに有効です。

task_status string

タスクのステータスです。

列挙値

  • PENDING

  • RUNNING

  • SUCCEEDED

  • FAILED

  • CANCELED

  • UNKNOWN:タスクが存在しないか、ステータスが不明です。

ポーリング中の状態遷移:

  • PENDING → RUNNING → SUCCEEDED または FAILED。

  • 最初のクエリステータスは通常 PENDING または RUNNING です。

  • ステータスが SUCCEEDED に変わると、レスポンスには生成された動画の URL が含まれます。

  • ステータスが FAILED の場合は、エラーメッセージを確認してタスクをリトライしてください。

submit_time string

タスクが送信された時刻です。時刻は UTC+8 で、フォーマットは YYYY-MM-DD HH:mm:ss.SSS です。

scheduled_time string

タスクが実行された時刻です。時刻は UTC+8 で、フォーマットは YYYY-MM-DD HH:mm:ss.SSS です。

end_time string

タスクが完了した時刻です。時刻は UTC+8 で、フォーマットは YYYY-MM-DD HH:mm:ss.SSS です。

video_url string

生成された動画の URL です。task_status が SUCCEEDED の場合にのみ返されます。

24 時間有効です。動画は MP4 フォーマットで、H.264 エンコーディングです。

orig_prompt string

元の入力プロンプトで、リクエストパラメーター prompt に対応します。

actual_prompt string

prompt_extend=true の場合、システムはプロンプトを書き換えます。このフィールドは最適化されたバージョンを返します。

  • prompt_extend=false の場合、このフィールドは返されません。

  • 注:wan2.6 モデルは、prompt_extend の値に関係なく、このフィールドを返しません。

code string

エラーコードです。失敗したリクエストに対してのみ返されます。「エラーメッセージ」をご参照ください。

message string

詳細なエラーメッセージです。失敗したリクエストに対してのみ返されます。「エラーメッセージ」をご参照ください。

usage object

出力統計です。成功した結果に対してのみカウントされます。

プロパティ

wan2.6 モデルによって返されるパラメーター

input_video_duration integer

入力動画の持続時間 (秒) です。入力動画はサポートされていないため、0 に固定されています。

output_video_duration integer

wan2.6 モデルに対してのみ返されます。

出力動画の持続時間 (秒) です。input.duration と等しくなります。

duration integer

課金に使用される合計動画持続時間です。

課金計算式:duration=input_video_duration+output_video_duration

SR integer

wan2.6 モデルに対してのみ返されます。生成された動画の解像度レベルです。例:720。

video_count integer

生成された動画の数です。1 に固定されています。

audio boolean

wan2.6-i2v-flash モデルに対してのみ返されます。出力動画に音声があるかどうかを示します。

wan2.2 および wan2.5 モデルによって返されるパラメーター

duration integer

生成された動画の持続時間 (秒) です。有効な値:5、10。

課金計算式:コスト = 動画秒数 × 単価。

SR integer

生成された動画の解像度です。有効な値:480、720、1080。

video_count integer

生成された動画の数です。1 に固定されています。

wan2.1 モデルによって返されるパラメーター

video_duration integer

生成された動画の持続時間 (秒) です。有効な値:3、4、5。

課金計算式:コスト = 動画秒数 × 単価。

video_ratio string

生成された動画のアスペクト比です。標準に固定されています。

video_count integer

生成された動画の数です。1 に固定されています。

request_id string

追跡とトラブルシューティングのためのユニークなリクエスト識別子です。

DashScope SDK

SDK のパラメーター名は、ほとんどが HTTP API と一致します (構造は各言語の規則に従います)。

画像動画変換タスクには 1〜5 分かかります。SDK は非同期 HTTP 呼び出しフローをラップし、同期と非同期の両方の呼び出しをサポートします。

実際の処理時間は、キューの長さとサービスの実行状況によって異なります。結果が出るまでしばらくお待ちください。

Python SDK

null

DashScope Python SDK ≥ 1.25.8 が必要です。古いバージョンではエラー (「url error, please check url!」) が発生する可能性があります。更新するには、「SDK のインストール」をご参照ください。

モデルのリージョンに基づいて base_http_api_url を設定します:

シンガポール

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

バージニア

dashscope.base_http_api_url = 'https://dashscope-us.aliyuncs.com/api/v1'

北京

dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

フランクフルト

dashscope.base_http_api_url = 'https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1'

API を呼び出す際は、WorkspaceId を実際のワークスペース ID に置き換えてください。

サンプルコード

同期呼び出し

同期呼び出しは完了するまでブロックします。3 つの画像入力方法があります:パブリック URL、Base64、ローカルファイルパス。

リクエスト例
import base64
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import mimetypes
import dashscope

# シンガポールリージョンの URL。URL の取得:https://www.alibabacloud.com/help/ja/model-studio/image-to-video-api-reference
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'


# 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
# API キーの取得:https://www.alibabacloud.com/help/ja/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

# --- ヘルパー関数:Base64 エンコーディング用 ---
# フォーマット:data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
    mime_type, _ = mimetypes.guess_type(file_path)
    if not mime_type or not mime_type.startswith("image/"):
        raise ValueError("Unsupported or unrecognized image format")
    with open(file_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
    return f"data:{mime_type};base64,{encoded_string}"

"""
画像の入力方法:
次の 3 つの方法から 1 つを選択します

1. パブリック URL を使用 - 一般公開されている画像に適しています
2. ローカルファイルを使用 - ローカルでの開発やテストに適しています
3. Base64 エンコーディングを使用 - 非公開の画像や暗号化伝送が必要なシナリオに適しています
"""

# [方法 1] 一般公開されている画像 URL を使用
# 例:パブリック画像 URL を使用
img_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"

# [方法 2] ローカルファイルを使用 (絶対パスと相対パスをサポート)
# フォーマット要件:file:// + ファイルパス
# 例 (絶対パス):
# img_url = "file://" + "/path/to/your/img.png"    # Linux/macOS
# img_url = "file://" + "/C:/path/to/your/img.png"  # Windows
# 例 (相対パス):
# img_url = "file://" + "./img.png"                # 現在の実行可能ファイルのパスからの相対パス

# [方法 3] Base64 エンコードされた画像を使用
# img_url = encode_file("./img.png")

# 音声 URL を設定
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"

def sample_call_i2v():
    # 同期呼び出し、結果を直接返します
    print('please wait...')
    rsp = VideoSynthesis.call(api_key=api_key,
                              model='wan2.6-i2v-flash',
                              prompt='A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.',
                              img_url=img_url,
                              audio_url=audio_url,
                              resolution="720P",
                              duration=10,
                              prompt_extend=True,
                              watermark=False,
                              negative_prompt="",
                              seed=12345)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print("video_url:", rsp.output.video_url)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))


if __name__ == '__main__':
    sample_call_i2v()
レスポンス例
video_url は 24 時間有効です。速やかにダウンロードしてください。
{
    "status_code": 200,
    "request_id": "2794c7a3-fe8c-4dd4-a1b7-xxxxxx",
    "code": null,
    "message": "",
    "output": {
        "task_id": "c15d5b14-07c4-4af5-b862-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx",
        "submit_time": "2026-01-22 23:24:46.527",
        "scheduled_time": "2026-01-22 23:24:46.565",
        "end_time": "2026-01-22 23:25:59.978",
        "orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise."
    },
    "usage": {
        "video_count": 1,
        "video_duration": 0,
        "video_ratio": "",
        "duration": 10,
        "input_video_duration": 0,
        "output_video_duration": 10,
        "audio": true,
        "SR": 720
    }
}

非同期呼び出し

非同期呼び出しはすぐにタスク ID を返します。結果をポーリングするか、完了を待ちます。

リクエスト例
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

# シンガポールリージョンの URL。URL の取得:https://www.alibabacloud.com/help/ja/model-studio/image-to-video-api-reference
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'


# 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
# API キーの取得:https://www.alibabacloud.com/help/ja/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

# 一般公開されている画像 URL を使用
img_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png"

# 音声 URL を設定
audio_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3"


def sample_async_call_i2v():
    # 非同期呼び出し、task_id を返します
    rsp = VideoSynthesis.async_call(api_key=api_key,
                                    model='wan2.6-i2v-flash',
                                    prompt='A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.',
                                    img_url=img_url,
                                    audio_url=audio_url,
                                    resolution="720P",
                                    duration=10,
                                    prompt_extend=True,
                                    watermark=False,
                                    negative_prompt="",
                                    seed=12345)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print("task_id: %s" % rsp.output.task_id)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

    # 非同期タスク情報を取得
    status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
    if status.status_code == HTTPStatus.OK:
        print(status.output.task_status)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (status.status_code, status.code, status.message))

    # 非同期タスクの完了を待機
    rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output.video_url)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))


if __name__ == '__main__':
    sample_async_call_i2v()
レスポンス例

1. タスク作成のレスポンス例

{
    "status_code": 200,
    "request_id": "6dc3bf6c-be18-9268-9c27-xxxxxx",
    "code": "",
    "message": "",
    "output": {
        "task_id": "686391d9-7ecf-4290-a8e9-xxxxxx",
        "task_status": "PENDING",
        "video_url": ""
    },
    "usage": null
}

2. タスク結果クエリのレスポンス例

video_url は 24 時間有効です。速やかにダウンロードしてください。
{
    "status_code": 200,
    "request_id": "2794c7a3-fe8c-4dd4-a1b7-xxxxxx",
    "code": null,
    "message": "",
    "output": {
        "task_id": "c15d5b14-07c4-4af5-b862-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx",
        "submit_time": "2026-01-22 23:24:46.527",
        "scheduled_time": "2026-01-22 23:24:46.565",
        "end_time": "2026-01-22 23:25:59.978",
        "orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise."
    },
    "usage": {
        "video_count": 1,
        "video_duration": 0,
        "video_ratio": "",
        "duration": 10,
        "input_video_duration": 0,
        "output_video_duration": 10,
        "audio": true,
        "SR": 720
    }
}

Java SDK

null

DashScope Java SDK ≥ 2.22.6 が必要です。古いバージョンではエラー (「url error, please check url!」) が発生する可能性があります。更新するには、「SDK のインストール」をご参照ください。

モデルのリージョンに基づいて baseHttpApiUrl を設定します:

シンガポール

Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";

バージニア

Constants.baseHttpApiUrl = "https://dashscope-us.aliyuncs.com/api/v1";

北京

Constants.baseHttpApiUrl = "https://dashscope.aliyuncs.com/api/v1";

フランクフルト

Constants.baseHttpApiUrl = "https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1";

API を呼び出す際は、WorkspaceId を実際のワークスペース ID に置き換えてください。

サンプルコード

同期呼び出し

同期呼び出しは完了するまでブロックします。3 つの画像入力方法があります:パブリック URL、Base64、ローカルファイルパス。

リクエスト例
// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

 
public class Image2Video {

    static {
        // シンガポールリージョンの URL。URL の取得:https://www.alibabacloud.com/help/ja/model-studio/image-to-video-api-reference
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:apiKey="sk-xxx"
    // API キーの取得:https://www.alibabacloud.com/help/ja/model-studio/get-api-key
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    
    /**
     * 画像の入力方法:次の 3 つから 1 つを選択します
     *
     * 1. パブリック URL を使用 - 一般公開されている画像に適しています
     * 2. ローカルファイルを使用 - ローカルでの開発やテストに適しています
     * 3. Base64 エンコーディングを使用 - 非公開の画像や暗号化伝送が必要なシナリオに適しています
     */

    // [方法 1] パブリック URL
    static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";

    // [方法 2] ローカルファイルパス (file://+絶対パス)
    // static String imgUrl = "file://" + "/your/path/to/img.png";    // Linux/macOS
    // static String imgUrl = "file://" + "/C:/your/path/to/img.png";  // Windows

    // [方法 3] Base64 エンコーディング
    // static String imgUrl = Image2Video.encodeFile("/your/path/to/img.png");
    
    // 音声 URL を設定
    static String audioUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3";

    public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
        // パラメーターを設定
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("prompt_extend", true);
        parameters.put("watermark", false);
        parameters.put("seed", 12345);

        VideoSynthesis vs = new VideoSynthesis();
        VideoSynthesisParam param =
                VideoSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model("wan2.6-i2v-flash")
                        .prompt("A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.")
                        .imgUrl(imgUrl)
                        .audioUrl(audioUrl)
                        .duration(10)
                        .parameters(parameters)
                        .resolution("720P")
                        .negativePrompt("")
                        .build();
        System.out.println("please wait...");
        VideoSynthesisResult result = vs.call(param);
        System.out.println(JsonUtils.toJson(result));
    }
    
     /**
     * ファイルを Base64 文字列にエンコードします
     * @param filePath ファイルパス
     * @return Base64 文字列 (フォーマット:data:{MIME_type};base64,{base64_data})
     */
    public static String encodeFile(String filePath) {
        Path path = Paths.get(filePath);
        if (!Files.exists(path)) {
            throw new IllegalArgumentException("File does not exist: " + filePath);
        }
        // MIME タイプを検出
        String mimeType = null;
        try {
            mimeType = Files.probeContentType(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("Cannot detect file type: " + filePath);
        }
        if (mimeType == null || !mimeType.startsWith("image/")) {
            throw new IllegalArgumentException("Unsupported or unrecognized image format");
        }
        // ファイルコンテンツを読み込んでエンコード
        byte[] fileBytes = null;
        try{
            fileBytes = Files.readAllBytes(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("Cannot read file content: " + filePath);
        }
    
        String encodedString = Base64.getEncoder().encodeToString(fileBytes);
        return "data:" + mimeType + ";base64," + encodedString;
    }
    

    public static void main(String[] args) {
        try {
            image2video();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}
レスポンス例
video_url は 24 時間有効です。速やかにダウンロードしてください。
{
    "request_id": "87c091bb-7a3c-4904-8501-xxxxxx",
    "output": {
        "task_id": "413ed6e4-5f3a-4f57-8d58-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx",
        "orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "submit_time": "2026-01-22 23:25:45.729",
        "scheduled_time": "2026-01-22 23:25:45.771",
        "end_time": "2026-01-22 23:26:44.942"
    },
    "usage": {
        "video_count": 1,
        "duration": 10.0,
        "input_video_duration": 0.0,
        "output_video_duration": 10.0,
        "SR": "720"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

非同期呼び出し

非同期呼び出しはすぐにタスク ID を返します。結果をポーリングするか、完了を待ちます。

リクエスト例
// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisListResult;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;

import java.util.HashMap;
import java.util.Map;

public class Image2Video {

    static {
        // シンガポールリージョンの URL。URL の取得:https://www.alibabacloud.com/help/ja/model-studio/image-to-video-api-reference
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    }

    // 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください:api_key="sk-xxx"
    // API キーの取得:https://www.alibabacloud.com/help/ja/model-studio/get-api-key
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    // 入力画像 URL を設定
    static String imgUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png";

    // 音声 URL を設定
    static String audioUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3";

    public static void image2video() throws ApiException, NoApiKeyException, InputRequiredException {
        // パラメーターを設定
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("prompt_extend", true);
        parameters.put("watermark", false);
        parameters.put("seed", 12345);

        VideoSynthesis vs = new VideoSynthesis();
        VideoSynthesisParam param =
                VideoSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model("wan2.6-i2v-flash")
                        .prompt("A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.")
                        .imgUrl(imgUrl)
                        .audioUrl(audioUrl)
                        .duration(10)
                        .parameters(parameters)
                        .resolution("720P")
                        .negativePrompt("")
                        .build();
        // 非同期呼び出し
        VideoSynthesisResult task = vs.asyncCall(param);
        System.out.println(JsonUtils.toJson(task));
        System.out.println("please wait...");

        // 結果を取得
        VideoSynthesisResult result = vs.wait(task, apiKey);
        System.out.println(JsonUtils.toJson(result));
    }

    // タスクリストを取得
    public static void listTask() throws ApiException, NoApiKeyException {
        VideoSynthesis is = new VideoSynthesis();
        AsyncTaskListParam param = AsyncTaskListParam.builder().build();
        param.setApiKey(apiKey);
        VideoSynthesisListResult result = is.list(param);
        System.out.println(result);
    }

    // 単一タスクの結果を取得
    public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
        VideoSynthesis is = new VideoSynthesis();
        // DASHSCOPE_API_KEY が環境変数として設定されている場合、apiKey は null にできます
        VideoSynthesisResult result = is.fetch(taskId, apiKey);
        System.out.println(result.getOutput());
        System.out.println(result.getUsage());
    }

    public static void main(String[] args) {
        try {
            image2video();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}
レスポンス例

1. タスク作成のレスポンス例

{
    "request_id": "5dbf9dc5-4f4c-9605-85ea-xxxxxxxx",
    "output": {
        "task_id": "7277e20e-aa01-4709-xxxxxxxx",
        "task_status": "PENDING"
    }
}

2. タスク結果クエリのレスポンス例

video_url は 24 時間有効です。速やかにダウンロードしてください。
{
    "request_id": "87c091bb-7a3c-4904-8501-xxxxxx",
    "output": {
        "task_id": "413ed6e4-5f3a-4f57-8d58-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=xxx",
        "orig_prompt": "A scene of urban fantasy art. A dynamic graffiti art character. A boy made of spray paint comes to life from a concrete wall. He raps an English song at high speed while striking a classic, energetic rapper pose. The scene is set under an urban railway bridge at night. The lighting comes from a single street lamp, creating a cinematic atmosphere full of high energy and amazing detail. The audio of the video consists entirely of his rap, with no other dialogue or noise.",
        "submit_time": "2026-01-22 23:25:45.729",
        "scheduled_time": "2026-01-22 23:25:45.771",
        "end_time": "2026-01-22 23:26:44.942"
    },
    "usage": {
        "video_count": 1,
        "duration": 10.0,
        "input_video_duration": 0.0,
        "output_video_duration": 10.0,
        "SR": "720"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

制限事項

  • データ有効期間:task_id と動画 URL は 24 時間のみ保持されます。期限切れになると、クエリやダウンロードはできません。

  • コンテンツモデレーション:入力 (プロンプト、画像) と出力はセキュリティレビューを受けます。違反するとエラー (例:「IPInfringementSuspect」、「DataInspectionFailed」) が返されます。「」をご参照ください。

エラーコード

呼び出しの失敗やエラーについては、「エラーメッセージ」でトラブルシューティングを行ってください。

よくある質問

Q:特定のアスペクト比 (例:3:4) の動画を生成するにはどうすればよいですか?

A:出力のアスペクト比は入力画像 (img_url) と一致しますが、正確な比率 (例:厳密な 3:4) は保証されません。わずかなずれが生じる可能性があります。

  • ずれが生じる理由:

    モデルは入力画像の比率を基準とし、ターゲットピクセル (解像度で設定) に基づいて最も近い有効な解像度を計算します。幅/高さは 16 の倍数である必要があり、微調整が必要です。出力比率はターゲット (例:3:4) に近似しますが、正確ではありません。

    • 例:入力画像 750×1000 (アスペクト比 3:4 = 0.75)、解像度 = "720P" (ターゲット約 920,000 ピクセル) の場合、出力は 816×1104 (アスペクト比 ≈ 0.739、約 900,000 ピクセル) になります。

  • ベストプラクティス

    • 入力制御:ターゲットのアスペクト比を持つ画像を最初のフレームとして使用します。

    • 後処理:厳密な比率が必要な場合は、編集ツールで生成された動画をクロップまたはパディングします。

Q:動画ストレージのドメイン名ホワイトリストを取得するにはどうすればよいですか?

A:モデルによって生成された動画は OSS に保存されます。API は一時的なパブリック URL を返します。このダウンロード URL のファイアウォールホワイトリストを設定するには、次の点にご注意ください:基盤となるストレージは動的に変更される可能性があります。このトピックでは、古い情報によるアクセス問題を避けるため、固定の OSS ドメイン名ホワイトリストは提供していません。セキュリティ管理要件がある場合は、アカウントマネージャーに連絡して最新の OSS ドメイン名リストを入手してください。