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

Alibaba Cloud Model Studio:Postman または cURL を使用した画像・動画生成 API の呼び出し

最終更新日:Jun 13, 2026

この記事では、Postman および cURL を使用して Alibaba Cloud Model Studio (Bailian) 上の画像または動画生成 API を呼び出す方法について説明します。Text-to-Image の例を用いて、タスク作成から結果取得までの完全なプロセスを紹介します。

  • Postman:HTTP リクエストをテストするための直感的でグラフィカルなツールです。初心者におすすめです。

  • cURL:コマンドラインに慣れた開発者向けの強力なコマンドラインツールです。

説明

Postman および cURL は、迅速なテストや機能検証を目的としています。本番環境では、公式 SDK を使用するか、独自に HTTP 呼び出しを実装してください。

非同期呼び出しメカニズム

画像および動画生成タスクは完了までに長時間を要することがあり、その所要時間は 10 秒以上から数分程度まで幅があります。長時間の HTTP 接続やタイムアウトを回避するため、API は非同期呼び出しメカニズムを採用しています。処理は次の 2 ステップに分かれます。

  1. タスクの作成:API を呼び出してタスクを作成します。サービスは同期的にタスク ID (task_id) を返します。

  2. 結果の照会:タスク ID を使用してタスクのステータスをポーリングし、タスクが完了したら最終的な画像または動画の URL を取得します。

HTTP 呼び出し例 (Text-to-Image)

方法 1:Postman の使用(推奨)

cURL からの Postman 設定

cURL コマンドを Postman リクエストに変換する際、パラメーターは次のようにマッピングされます。

cURL パラメーター

Postman UI

説明

curl -X POST または curl -X GET

リクエストメソッドのドロップダウン

HTTP リクエストメソッドを選択します。

https://<api-endpoint-url>

URL 入力ボックス

API エンドポイントの URL です。

-H 'Key: Value'

Headers タブ

リクエストヘッダーをキーと値のペアとして設定します。

-d '{...}'

Body タブ

リクエストボディを設定します。

前提条件

API を呼び出す前に、ご利用のリージョン向けの API キーを取得し、Postman をダウンロードしてください。

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

以下の cURL コマンドを使用して Postman を設定します。

以下のベース URL はシンガポールリージョン用です。ご利用のリージョンに対応するベース URL を使用する必要があります。
curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.5-t2i-preview",
    "input": {
        "prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
    },
    "parameters": {
        "size": "1024*1024",
        "n": 1
    }
}'
  1. Postman で、new または + ボタンをクリックして新しいリクエストを作成し、リクエストタイプとして HTTP を選択します。

  2. リクエストメソッドのドロップダウンから POST を選択し、モデルのデプロイメントリージョンに対応する URL を入力します。

    • シンガポール:https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis で、WorkspaceId は「ワークスペース ID の取得」で説明されている実際のワークスペース ID に置き換えてください。

    • 米国 (バージニア):https://dashscope-us.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis

    • 中国 (北京):https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis

    各リージョンでサポートされているモデルについては、Model Studio コンソールをご確認ください。現在のリージョンとサービスデプロイ範囲は、事前定義されたシステムバインディング関係に基づいており、カスタム組み合わせはサポートされていません。

    1-intl

  3. Headers タブをクリックし、次の 3 つのキーと値のペアを追加します。

    キー

    説明

    Postman の Headers タブで、X-DashScope-AsyncenableAuthorizationBearer <your-api-key>Content-Typeapplication/json に設定します。

    X-DashScope-Async

    enable

    非同期呼び出しを有効にします。

    Authorization

    Bearer sk-xxx (sk-xxx はご利用の API キーに置き換えてください)

    認証情報です。

    Content-Type

    application/json

    リクエストボディが JSON 形式であることを宣言します。

  4. リクエストボディを設定します。

    • Body タブをクリックし、raw ラジオボタンを選択して、右側のフォーマットドロップダウンメニューから JSON を選択し、cURL の例で -d の後に続く JSON コンテンツを入力ボックスに貼り付けます。

      {
          "model": "wan2.5-t2i-preview",
          "input": {
              "prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
          },
          "parameters": {
              "size": "1024*1024",
              "n": 1
          }
      }
    • (オプション)ページ右側の Beautify をクリックして JSON を整形し、読みやすくします。

    3-intl-zh

  5. Send をクリックしてリクエストを送信し、task_id を取得します。task_id の有効期間は 24 時間です。この期間を過ぎると結果を照会できなくなりますので、速やかに結果を取得してください。

    {
        "request_id": "896b2ccd-a0cd-40a8-a557-bb73cee5cf95",
        "output": {
            "task_id": "42442de9-917d-4c41-80a7-37fb7ad25ed2",
            "task_status": "PENDING"
        }
    }

    4-

ステップ 2:タスク ID による結果照会

タスク ID を取得したら、照会エンドポイントを呼び出して最終結果を取得します。

  • シンガポール:https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis で、WorkspaceId は実際の ワークスペース ID に置き換えてください。

  • 米国 (バージニア):https://dashscope-us.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis

  • 中国 (北京):https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
  1. Postman で照会リクエストを設定します。

    1. 新しい HTTP リクエストを作成します。

    2. リクエストメソッドを GET に設定します。

    3. リージョンに応じて照会 URL を入力し、URL 内の {task_id} をステップ 1 で取得した実際の task_id に置き換えます。

    4. Headers タブで Authorization ヘッダーを追加し、ステップ 1 で使用したのと同じ API キーを使用します。

    5. Send をクリックします。

    5-zh

  2. 応答を確認します。task_statusSUCCEEDED になるまでこのエンドポイントをポーリングし、画像 URL を取得します。画像 URL の有効期間は 24 時間 です。有効期間内に必ず画像をダウンロードしてください。

    "results": [
                {
                    "orig_prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display",
                    "actual_prompt": "A cozy and elegant flower shop, with an exterior decorated with exquisitely carved windows. The window frames are light-colored wood, set with transparent glass that reveals the soft light inside. The front door is a beautiful solid wood door that retains its natural grain, complemented by a brass handle and a vintage nameplate, giving it a quaint and textured feel. On both sides of the front steps, and on the windowsills and entrance area, various flowers—including roses, lilies, hydrangeas, and tulips—are arranged in a staggered, vibrant display. Some bouquets are wrapped in kraft paper and tied with twine, exuding a fresh, natural scent. The background features a quiet European town streetscape, with stone-paved roads and greenery adding to the charm. The overall image is in a realistic photographic style, with soft lighting and a warm color palette that highlights the shop's exquisite and romantic atmosphere.",
                    "url": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/1d/3a/20251203/7a2bee47/42442de9-917d-4c41-80a7-37fb7ad25ed2.png?xxx"
                }
            ]

方法 2:cURL の使用

コマンドラインに慣れた開発者は、cURL を使用して API を迅速にテストできます。

前提条件

cURL コマンドを実行する前に:

  • モデルサービスを有効化し、API キーを取得します。

  • cURL がインストールされていることを確認し、API キーを環境変数として設定して、後で $DASHSCOPE_API_KEY 変数を直接参照できるようにします。

    cURL のインストール状況の確認

    次のコマンドを実行して、cURL がインストールされているかどうかを確認します。

    curl --version

    次のような出力が表示された場合、cURL はインストールされています。

    curl 8.x.x (x86_64-apple-darwin23.0) libcurl/8.x.x (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.58.0
    Release-Date: 2023-10-11
    Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
    Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets

    インストールされていない場合は、次のようなメッセージが表示される可能性があります。

    • Windows:'curl' is not recognized as an internal or external command, operable program or batch file

    • Linux/macOS:command not found: curl

    curl ダウンロードページにアクセスしてインストールしてください。

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

  • ターミナルで次のコマンドを実行します。

    以下のベース URL はシンガポールリージョン用です。ご利用のリージョンに対応するベース URL を使用する必要があります。
    curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis \
        -H 'X-DashScope-Async: enable' \
        -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
        -H 'Content-Type: application/json' \
        -d '{
        "model": "wan2.5-t2i-preview",
        "input": {
            "prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
        },
        "parameters": {
            "size": "1024*1024",
            "n": 1
        }
    }'
  • リクエストが成功すると、task_id が返されます。この ID の有効期間は 24 時間であり、有効期限切れ後は照会に使用できません。速やかに結果を取得してください。

    curl -X POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis \
        -H 'X-DashScope-Async: enable' \
        -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
        -H 'Content-Type: application/json' \
        -d '{
        "model": "wan2.5-t2i-preview",
        "input": {
            "prompt": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
        },
        "parameters": {
            "size": "1024*1024",
            "n": 1
        }
    }'
    {"request_id":"ca3b5224-bc60-4e47-80f4-2790040e9e55","output":{"task_id":"2de3f7e1-52ce-4cf4-a466-f2d318061c43","task_status":"PENDING"}}

    task_id-intl-zh

ステップ 2:タスク ID による結果照会

  • 次のコマンド内の {task_id} をステップ 1 で取得したタスク ID に置き換え、コマンドをターミナルにコピーして実行します。

    以下のベース URL はシンガポールリージョン用です。ご利用のリージョンに対応するベース URL を使用する必要があります。
    curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
    --header "Authorization: Bearer $DASHSCOPE_API_KEY"
  • タスクが完了すると(task_statusSUCCEEDED になると)、応答に画像 URL が含まれます。画像 URL の有効期間は 24 時間 です。速やかにダウンロードしてください。

    モデルの処理には長時間を要するため(数十秒から数分程度)、この API をポーリングする必要がある場合があります。task_statusRUNNING でなくなるまで、3~5 秒ごとに API を照会することを推奨します。
    curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/2de3f7e1-52ce-4cf4-a466-f2d3f8061c43 \
    --header "Authorization: Bearer $DASHSCOPE_API_KEY"
    {"request_id":"24143559-9964-4898-8f9c-d968bba182b9","output":{"task_id":"2de3f7e1-52ce-4cf4-a466-f2d3f8061c43","task_status":"SUCCEEDED","submit_time":"2025-12-03 10:19:18.293","scheduled_time":"2025-12-03 10:19:18.320","end_time":"2025-12-03 10:19:31.890","results":[{"orig_prompt":"A flower shop with exquisite windows, a beautiful wooden door, and flowers on display","actual_prompt":"A cozy, elegant flower shop. The exterior wall features exquisitely carved windows with dark brown wooden frames, and the glass is clean and bright, revealing the soft light inside. The front door is a beautiful solid wood door that retains its natural grain, complemented by a brass handle and a vintage nameplate that exudes a strong artisanal feel. On both sides of the front steps, and on the windowsills and entrance area, various flowers—including blooming roses, elegant hydrangeas, fresh daisies, and green eucalyptus leaves—are arranged in a staggered yet harmonious display. The background is a quiet European town streetscape, with a stone-paved road and a vine-covered neighboring wall enhancing the romantic atmosphere. The overall image is in a realistic photographic style, with soft, natural lighting that highlights the wood texture and floral details.","url":"https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/1d/59/20251203/7a2bee47/2de3f7e1-52ce-4cf4-a466-f2d3f8061c43.png?Expires=1764814771&OSSAccessKeyId=xxx"}],"task_metrics":{"TOTAL":1,"FAILED":0,"SUCCEEDED":1}},"usage":{"image_count":1}}

    result-intl-zh

次のステップ

初めての画像生成に成功したら、次の内容を試してみてください。

  • API パラメーターの詳細を確認:追加のパラメーターについては、Text-to-Image API ドキュメントをご参照ください。

  • 動画生成を試すfirst-frame-to-video API を使用して動画を作成してみてください。

  • 他のモデルを探索:Model Studio コンソールにアクセスして、Alibaba Cloud Model Studio (Bailian) でサポートされているすべての画像および動画モデルをご確認ください。