「テキストによる画像検索」ツールを使用すると、モデルはテキスト記述に一致する画像をインターネットで検索できます。その後、モデルはそれらの画像を記述し、推論します。このツールは、ビジュアル Q&A や画像推奨タスクに使用します。
利用方法
Responses API を通じて、テキストから画像への検索ツールを呼び出します。tools パラメーターを含め、web_search_image ツールを指定します。
# 依存関係をインポートし、クライアントを作成します...
response = client.responses.create(
model="qwen3.5-plus",
input="Find a tech-themed background image suitable for a PowerPoint cover",
tools=[{"type": "web_search_image"}]
)
print(response.output_text)サポートされるモデル
Qwen-Plus:
qwen3.5-plus、qwen3.5-plus-2026-02-15Qwen-Flash:
qwen3.5-flash、qwen3.5-flash-2026-02-23オープンソース Qwen:
qwen3.5-397b-a17b、qwen3.5-122b-a10b、qwen3.5-27b、qwen3.5-35b-a3b
これは Responses API を介してのみ呼び出すことができます。
クイックスタート
以下のコードを実行して、Responses API を介して「テキストによる画像検索」ツールを呼び出し、テキスト記述に基づいてインターネット上の画像を検索します。
まず、API キーを取得し、それを環境変数として設定する必要があります。
import os
import json
from openai import OpenAI
client = OpenAI(
# 環境変数を設定していない場合は、次の行を api_key="sk-xxx" に置き換えてください (非推奨)。
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
)
response = client.responses.create(
model="qwen3.5-plus",
input="Find a tech-themed background image suitable for a PowerPoint cover",
tools=[
{
"type": "web_search_image"
}
]
)
for item in response.output:
if item.type == "web_search_image_call":
print(f"[Tool call] Text-to-image search (status: {item.status})")
# 画像のリストを解析して表示します
if item.output:
images = json.loads(item.output)
print(f" Found {len(images)} images:")
for img in images[:5]: # 最初の 5 件を表示します
print(f" [{img['index']}] {img['title']}")
print(f" {img['url']}")
if len(images) > 5:
print(f" ... Total {len(images)} images")
elif item.type == "message":
print(f"\n[Model response]")
print(response.output_text)
# トークンの使用量とツール呼び出しの統計情報を表示します
print(f"\n[Token usage] Input: {response.usage.input_tokens}, Output: {response.usage.output_tokens}, Total: {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 stats] {tool_name} calls: {info.get('count', 0)}")import OpenAI from "openai";
import process from 'process';
const openai = new OpenAI({
// 環境変数を設定していない場合は、次の行を apiKey: "sk-xxx" に置き換えてください (非推奨)。
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: "Find a tech-themed background image suitable for a PowerPoint cover",
tools: [
{ type: "web_search_image" }
]
});
for (const item of response.output) {
if (item.type === "web_search_image_call") {
console.log(`[Tool call] Text-to-image search (status: ${item.status})`);
// 画像のリストを解析して表示します
if (item.output) {
const images = JSON.parse(item.output);
console.log(` Found ${images.length} images:`);
images.slice(0, 5).forEach(img => {
console.log(` [${img.index}] ${img.title}`);
console.log(` ${img.url}`);
});
if (images.length > 5) {
console.log(` ... Total ${images.length} images`);
}
}
} else if (item.type === "message") {
console.log(`\n[Model response]`);
console.log(response.output_text);
}
}
// トークンの使用量とツール呼び出しの統計情報を表示します
console.log(`\n[Token usage] Input: ${response.usage.input_tokens}, Output: ${response.usage.output_tokens}, Total: ${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 stats] ${toolName} calls: ${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": "Find a tech-themed background image suitable for a PowerPoint cover",
"tools": [
{"type": "web_search_image"}
]
}'上記のコードを実行すると、次のような出力が返されます。
[Tool call] Text-to-image search (status: completed)
Found 30 images:
[1] Best Free Information Technology Background S Google Slides Themes ...
https://image.slidesdocs.com/responsive-images/slides/0-technology-line-network-information-training-courseware-powerpoint-background_17825ea41f__960_540.jpg
[2] Data Technology Blue Abstract Business Glow Powerpoint Background ...
https://image.slidesdocs.com/responsive-images/background/data-technology-blue-abstract-business-glow-powerpoint-background_e667bfafcb__960_540.jpg
[3] PPT Technology Style Background Template Banner Backgrounds | PSD ...
https://img.pikbest.com/backgrounds/20190418/ppt-technology-style-background-template-banner_1889599.jpg!bw700
[4] Download Now! PowerPoint Background Design Technology
https://www.slideegg.com/image/catalog/89734-powerpoint-background-design-technology.png
[5] Powerpoint Template Technology Images ...
https://t4.ftcdn.net/jpg/07/53/21/13/360_F_753211329_cVkWkZdxs9tNEoS5q2d8ZH362YQnAH0p.jpg
... Total 30 images
[Model response]
Here are several tech-themed background images perfect for your PowerPoint cover. Choose one that fits your topic and style:
**1. Classic blue circuit board and chip style**
Best for: hardware, chips, electronics engineering, or low-level technology topics.

**2. Abstract particle and network connectivity style**
Best for: big data, artificial intelligence, network security, or cloud computing topics.

...
[Token usage] Input: 4326, Output: 645, Total: 4971
[Tool stats] web_search_image calls: 1ストリーミング出力
「テキストによる画像検索」ツールは実行に時間がかかります。ストリーミング出力を有効にすると、結果が利用可能になり次第、取得できます。
import os
import json
from openai import OpenAI
client = OpenAI(
# 環境変数を設定していない場合は、次の行を api_key="sk-xxx" に置き換えてください (非推奨)。
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
)
stream = client.responses.create(
model="qwen3.5-plus",
input="Find a tech-themed background image suitable for a PowerPoint cover",
tools=[{"type": "web_search_image"}],
stream=True
)
for event in stream:
# ツール呼び出し開始
if event.type == "response.output_item.added":
if event.item.type == "web_search_image_call":
print("[Tool call] Text-to-image search in progress...")
# ツール呼び出し完了。画像のリストを解析して表示します
elif event.type == "response.output_item.done":
if event.item.type == "web_search_image_call":
print(f"[Tool call] Text-to-image search complete (status: {event.item.status})")
if event.item.output:
images = json.loads(event.item.output)
print(f" Found {len(images)} images:")
for img in images[:5]: # 最初の 5 件を表示します
print(f" [{img['index']}] {img['title']}")
print(f" {img['url']}")
if len(images) > 5:
print(f" ... Total {len(images)} 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] Input: {usage.input_tokens}, Output: {usage.output_tokens}, Total: {usage.total_tokens}")
if hasattr(usage, 'x_tools') and usage.x_tools:
for tool_name, info in usage.x_tools.items():
print(f"[Tool stats] {tool_name} calls: {info.get('count', 0)}")import OpenAI from "openai";
import process from 'process';
const openai = new OpenAI({
// 環境変数を設定していない場合は、次の行を apiKey: "sk-xxx" に置き換えてください (非推奨)。
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: "Find a tech-themed background image suitable for a PowerPoint cover",
tools: [{ type: "web_search_image" }],
stream: true
});
for await (const event of stream) {
// ツール呼び出し開始
if (event.type === "response.output_item.added") {
if (event.item && event.item.type === "web_search_image_call") {
console.log("[Tool call] Text-to-image search in progress...");
}
}
// ツール呼び出し完了。画像のリストを解析して表示します
else if (event.type === "response.output_item.done") {
if (event.item && event.item.type === "web_search_image_call") {
console.log(`[Tool call] Text-to-image search complete (status: ${event.item.status})`);
if (event.item.output) {
const images = JSON.parse(event.item.output);
console.log(` Found ${images.length} images:`);
images.slice(0, 5).forEach(img => {
console.log(` [${img.index}] ${img.title}`);
console.log(` ${img.url}`);
});
if (images.length > 5) {
console.log(` ... Total ${images.length} images`);
}
}
}
}
// モデル応答開始
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] Input: ${usage.input_tokens}, Output: ${usage.output_tokens}, Total: ${usage.total_tokens}`);
if (usage && usage.x_tools) {
for (const [toolName, info] of Object.entries(usage.x_tools)) {
console.log(`[Tool stats] ${toolName} calls: ${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": "Find a tech-themed background image suitable for a PowerPoint cover",
"tools": [
{"type": "web_search_image"}
],
"stream": true
}'上記のコードを実行すると、次のような出力が返されます。
[Tool call] Text-to-image search in progress...
[Tool call] Text-to-image search complete (status: completed)
Found 30 images:
[1] Free Technology Background PowerPoint & Google Slides Themes
https://slidechef.net/wp-content/uploads/2023/11/TECHNOLOGY-BACKGROUND.jpg
[2] Best Free Information Technology Background S Google Slides Themes ...
https://image.slidesdocs.com/responsive-images/slides/0-technology-line-network-information-training-courseware-powerpoint-background_17825ea41f__960_540.jpg
[3] PPT Technology Style Background Template Banner Backgrounds | PSD ...
https://img.pikbest.com/backgrounds/20190418/ppt-technology-style-background-template-banner_1889599.jpg!bw700
[4] Download Now! PowerPoint Background Design Technology
https://www.slideegg.com/image/catalog/89734-powerpoint-background-design-technology.png
[5] Powerpoint Template Technology Images ...
https://t4.ftcdn.net/jpg/07/53/21/13/360_F_753211329_cVkWkZdxs9tNEoS5q2d8ZH362YQnAH0p.jpg
... Total 30 images
[Model response]
Here are several tech-themed background images perfect for your PowerPoint cover. Choose one that fits your topic and style:
**1. Minimalist network connection style (best for big data, connectivity, or communications topics)**
This image uses a deep blue background with clean node connections in the corner and plenty of white space in the center...

**2. Hard-core circuit and chip style (best for artificial intelligence, hardware, or low-level technology topics)**
The left side features complex circuit board textures and a HUD-like circular design...

...
[Token usage] Input: 7180, Output: 558, Total: 7738
[Tool stats] web_search_image calls: 1課金
課金には以下が含まれます。
モデル呼び出し料金:画像検索結果がプロンプトに追加されます。これにより、入力トークン数が増加します。標準のモデルレートで課金されます。料金の詳細については、「モデルリスト」をご参照ください。
ツール呼び出し料金:1,000 回の呼び出しあたり、8 ドル (国際)、3.440461 ドル (中国本土)。