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

Alibaba Cloud Model Studio:イメージ間検索

最終更新日:Feb 25, 2026

イメージ間検索ツールは、入力されたイメージをもとにインターネット上で視覚的に類似したイメージを検索し、その検索結果を分析・推論する機能をモデルに提供します。類似プロダクトの画像検索や、視覚コンテンツの出所追跡などのシナリオでご利用ください。

使用方法

イメージ間検索機能は Responses API の呼び出しを使用します。image_search ツールを tools パラメーターに追加してください。input フィールド内に、マルチモーダル形式でイメージを渡します。

input には必ずイメージコンテンツを含める必要があります。input_image 型を使用してイメージ URL を指定します。また、検索の補足コンテキストとして、input_text 型のテキストを併記することもできます。
# 依存関係をインポートし、クライアントを作成...
input_content = [
    {"type": "input_text", "text": "このイメージと同様のスタイルの風景画像を検索"},
    {"type": "input_image", "image_url": "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png"}
]
response = client.responses.create(
    model="qwen3.5-plus",
    input=[{"role": "user", "content": input_content}],
    tools=[{"type": "image_search"}]
)

print(response.output_text)

対応モデル

  • Qwen-Plus:qwen3.5-plusqwen3.5-plus-2026-02-15

  • Qwen-Flash:qwen3.5-flashqwen3.5-flash-2026-02-23

  • オープンソース Qwen:qwen3.5-397b-a17bqwen3.5-122b-a10bqwen3.5-27bqwen3.5-35b-a3b

  • Responses API 経由でのみ呼び出し可能です。

クイックスタート

以下のコードを実行して、Responses API を使用してイメージ間検索ツールを呼び出し、入力イメージに基づいて類似または関連するイメージを検索します。

API キー を取得します。API キーを環境変数として設定します。
サンプルコード内の image_url を、実際のパブリックネットワークからアクセス可能なイメージの URL に置き換えてください。イメージはパブリックネットワークからのアクセスを許可している必要があります。
import os
import json
from openai import OpenAI

client = OpenAI(
    # 環境変数を設定していない場合は、次の行を「api_key="sk-xxx"」(Model Studio API キーを使用)に置き換えてください。
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
)

input_content = [
    {"type": "input_text", "text": "このイメージと同様のスタイルの風景画像を検索"},
    # image_url を、実際のパブリックネットワークからアクセス可能なイメージの URL に置き換えてください。
    {"type": "input_image", "image_url": "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png"}
]

response = client.responses.create(
    model="qwen3.5-plus",
    input=[{"role": "user", "content": input_content}],
    tools=[
        {
            "type": "image_search"
        }
    ]
)

# 出力を走査して各ステップを表示
for item in response.output:
    if item.type == "image_search_call":
        print(f"[Tool Call] イメージ間検索 (ステータス: {item.status})")
        # 検索結果のイメージ一覧を解析・表示
        if item.output:
            images = json.loads(item.output)
            print(f"  {len(images)} 件のイメージが見つかりました:")
            for img in images[:5]:  # 最初の 5 件を表示
                print(f"  [{img['index']}] {img['title']}")
                print(f"      {img['url']}")
            if len(images) > 5:
                print(f"  ... 合計 {len(images)} 件のイメージ")
    elif item.type == "message":
        print(f"\n[Model Response]")
        print(response.output_text)

# トークン使用量およびツール呼び出し統計を表示
print(f"\n[Token Usage] 入力: {response.usage.input_tokens}, 出力: {response.usage.output_tokens}, 合計: {response.usage.total_tokens}")
if hasattr(response.usage, 'x_tools') and response.usage.x_tools:
    for tool_name, info in response.usage.x_tools.items():
        print(f"[Tool Statistics] {tool_name} の呼び出し回数: {info.get('count', 0)}")
import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    // 環境変数を設定していない場合は、次の行を「apiKey: "sk-xxx"」(Model Studio API キーを使用)に置き換えてください。
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});

async function main() {
    const response = await openai.responses.create({
        model: "qwen3.5-plus",
        input: [
            {
                role: "user",
                content: [
                    { type: "input_text", text: "このイメージと同様のスタイルの風景画像を検索" },
                    // image_url を、実際のパブリックネットワークからアクセス可能なイメージの URL に置き換えてください。
                    { type: "input_image", image_url: "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png" }
                ]
            }
        ],
        tools: [
            { type: "image_search" }
        ]
    });

    // 出力を走査して各ステップを表示
    for (const item of response.output) {
        if (item.type === "image_search_call") {
            console.log(`[Tool Call] イメージ間検索 (ステータス: ${item.status})`);
            // 検索結果のイメージ一覧を解析・表示
            if (item.output) {
                const images = JSON.parse(item.output);
                console.log(`  ${images.length} 件のイメージが見つかりました:`);
                images.slice(0, 5).forEach(img => {
                    console.log(`  [${img.index}] ${img.title}`);
                    console.log(`      ${img.url}`);
                });
                if (images.length > 5) {
                    console.log(`  ... 合計 ${images.length} 件のイメージ`);
                }
            }
        } else if (item.type === "message") {
            console.log(`\n[Model Response]`);
            console.log(response.output_text);
        }
    }

    // トークン使用量およびツール呼び出し統計を表示
    console.log(`\n[Token Usage] 入力: ${response.usage.input_tokens}, 出力: ${response.usage.output_tokens}, 合計: ${response.usage.total_tokens}`);
    if (response.usage && response.usage.x_tools) {
        for (const [toolName, info] of Object.entries(response.usage.x_tools)) {
            console.log(`[Tool Statistics] ${toolName} の呼び出し回数: ${info.count || 0}`);
        }
    }
}

main();
curl -X POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-plus",
    "input": [
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "このイメージと同様のスタイルの風景画像を検索"},
                {"type": "input_image", "image_url": "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png"}
            ]
        }
    ],
    "tools": [
        {"type": "image_search"}
    ]
}'

上記のコードを実行すると、以下の応答が得られます:

[Tool Call] イメージ間検索 (ステータス: completed)
  2 件のイメージが見つかりました:
  [1] 2024 年清明節休暇のお知らせ
      https://www.healthcabin.net/blog/wp-content/uploads/2024/04/QingMing-Festival-Holiday-Notice-2024.jpg
  [2] 霧に包まれた湖面に映る静かなアジア風景石橋
      https://thumbs.dreamstime.com/b/serene-asian-landscape-stone-bridge-reflecting-misty-water-tranquil-illustration-traditional-arch-spanning-lake-style-376972039.jpg

[Model Response]
了解しました。ご要望のスタイルに近い風景画像をいくつか見つけました。

これらの画像は、いずれも中国の水墨画や伝統的な山水画の特徴を捉えており、以下の共通点があります:
*   **伝統的な建築物**: 例として、楼閣、塔、アーチ型の橋など。
*   **自然要素**: 例として、遠くの山々、湖、柳、蓮の花など。
*   **芸術的スタイル**: 上品な色使いと柔らかな線で、穏やかで深遠な雰囲気を演出しています。

...

[Token Usage] 入力: 2753, 出力: 181, 合計: 2934
[Tool Statistics] image_search の呼び出し回数: 1

ストリーミング出力

イメージ間検索ツールの処理には時間がかかる場合があります。リアルタイムの中間結果を受信するために、ストリーミング出力を有効化できます。

import os
import json
from openai import OpenAI

client = OpenAI(
    # 環境変数を設定していない場合は、次の行を「api_key="sk-xxx"」(Model Studio API キーを使用)に置き換えてください。
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
)

input_content = [
    {"type": "input_text", "text": "このイメージと同様のスタイルの風景画像を検索"},
    # image_url を、実際のパブリックネットワークからアクセス可能なイメージの URL に置き換えてください。
    {"type": "input_image", "image_url": "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png"}
]

stream = client.responses.create(
    model="qwen3.5-plus",
    input=[{"role": "user", "content": input_content}],
    tools=[{"type": "image_search"}],
    stream=True
)

for event in stream:
    # ツール呼び出しが開始されたとき
    if event.type == "response.output_item.added":
        if event.item.type == "image_search_call":
            print("[Tool Call] イメージ間検索を実行中...")
    # ツール呼び出しが完了し、検索結果のイメージ一覧を解析・表示
    elif event.type == "response.output_item.done":
        if event.item.type == "image_search_call":
            print(f"[Tool Call] イメージ間検索が完了しました (ステータス: {event.item.status})")
            if event.item.output:
                images = json.loads(event.item.output)
                print(f"  {len(images)} 件のイメージが見つかりました:")
                for img in images[:5]:  # 最初の 5 件を表示
                    print(f"  [{img['index']}] {img['title']}")
                    print(f"      {img['url']}")
                if len(images) > 5:
                    print(f"  ... 合計 {len(images)} 件のイメージ")
    # モデル応答が開始されたとき
    elif event.type == "response.content_part.added":
        print(f"\n[Model Response]")
    # ストリーミングテキスト出力
    elif event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
    # 応答が完了し、使用量を出力
    elif event.type == "response.completed":
        usage = event.response.usage
        print(f"\n\n[Token Usage] 入力: {usage.input_tokens}, 出力: {usage.output_tokens}, 合計: {usage.total_tokens}")
        if hasattr(usage, 'x_tools') and usage.x_tools:
            for tool_name, info in usage.x_tools.items():
                print(f"[Tool Statistics] {tool_name} の呼び出し回数: {info.get('count', 0)}")
import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    // 環境変数を設定していない場合は、次の行を「apiKey: "sk-xxx"」(Model Studio API キーを使用)に置き換えてください。
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});

async function main() {
    const stream = await openai.responses.create({
        model: "qwen3.5-plus",
        input: [
            {
                role: "user",
                content: [
                    { type: "input_text", text: "このイメージと同様のスタイルの風景画像を検索" },
                    // image_url を、実際のパブリックネットワークからアクセス可能なイメージの URL に置き換えてください。
                    { type: "input_image", image_url: "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png" }
                ]
            }
        ],
        tools: [{ type: "image_search" }],
        stream: true
    });

    for await (const event of stream) {
        // ツール呼び出しが開始されたとき
        if (event.type === "response.output_item.added") {
            if (event.item.type === "image_search_call") {
                console.log("[Tool Call] イメージ間検索を実行中...");
            }
        }
        // ツール呼び出しが完了し、検索結果のイメージ一覧を解析・表示
        else if (event.type === "response.output_item.done") {
            if (event.item && event.item.type === "image_search_call") {
                console.log(`[Tool Call] イメージ間検索が完了しました (ステータス: ${event.item.status})`);
                if (event.item.output) {
                    const images = JSON.parse(event.item.output);
                    console.log(`  ${images.length} 件のイメージが見つかりました:`);
                    images.slice(0, 5).forEach(img => {
                        console.log(`  [${img.index}] ${img.title}`);
                        console.log(`      ${img.url}`);
                    });
                    if (images.length > 5) {
                        console.log(`  ... 合計 ${images.length} 件のイメージ`);
                    }
                }
            }
        }
        // モデル応答が開始されたとき
        else if (event.type === "response.content_part.added") {
            console.log(`\n[Model Response]`);
        }
        // ストリーミングテキスト出力
        else if (event.type === "response.output_text.delta") {
            process.stdout.write(event.delta);
        }
        // 応答が完了し、使用量を出力
        else if (event.type === "response.completed") {
            const usage = event.response.usage;
            console.log(`\n\n[Token Usage] 入力: ${usage.input_tokens}, 出力: ${usage.output_tokens}, 合計: ${usage.total_tokens}`);
            if (usage && usage.x_tools) {
                for (const [toolName, info] of Object.entries(usage.x_tools)) {
                    console.log(`[Tool Statistics] ${toolName} の呼び出し回数: ${info.count || 0}`);
                }
            }
        }
    }
}

main();
curl -X POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-plus",
    "input": [
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "このイメージと同様のスタイルの風景画像を検索"},
                {"type": "input_image", "image_url": "https://img.alicdn.com/imgextra/i4/O1CN01YbrnSS1qtmsAkw0Ud_!!6000000005554-2-tps-788-450.png"}
            ]
        }
    ],
    "tools": [
        {"type": "image_search"}
    ],
    "stream": true
}'

上記のコードを実行すると、以下の応答が得られます:

[Tool Call] イメージ間検索を実行中...
[Tool Call] イメージ間検索が完了しました (ステータス: completed)
  3 件のイメージが見つかりました:
  [1] 2024 年清明節休暇のお知らせ
      https://www.healthcabin.net/blog/wp-content/uploads/2024/04/QingMing-Festival-Holiday-Notice-2024.jpg
  [2] 霧に包まれた湖面に映る静かなアジア風景石橋
      https://thumbs.dreamstime.com/b/serene-asian-landscape-stone-bridge-reflecting-misty-water-...
  [3] ...

[Model Response]
了解しました。ご要望のスタイルに近い風景画像をいくつか見つけました。これらの画像は、いずれも中国の水墨画や工筆画の特徴を捉えており...

[Token Usage] 入力: 5339, 出力: 164, 合計: 5503
[Tool Statistics] image_search の呼び出し回数: 1

課金

課金対象は以下のとおりです:

  • モデル呼び出し料金:イメージ間検索の結果はプロンプトに追加されるため、モデルの入力トークン数が増加します。これはモデルの標準料金体系に基づいて課金されます。料金の詳細については、「モデル一覧」をご参照ください。

  • ツール呼び出し料金:国際:8 USD、中国本土:6.880922 USD(1,000 回あたり)。

よくある質問

Q:対応するイメージフォーマットと入力方法は何ですか?

A:詳細については、「イメージ制限」および「ファイル入力方法」をご参照ください。

OpenAI SDK では、ローカルパスによる入力はサポートされていません。

Q:何枚のイメージを入力できますか?

A:イメージの枚数は、モデルの最大入力長によって制限されます。イメージとテキストの合計トークン数は、モデルがサポートする最大値より小さくなければなりません。モデルは 1 枚のイメージを一度に検索しますが、複数回呼び出すことで複数のイメージを処理できます。

検索対象のイメージ数はモデルが決定します。

Q:検索結果として返されるイメージの数はいくつですか?

A:この数はモデルが決定します。固定値ではなく、最大で 100 件のイメージが返されます。