Alat pencarian teks-ke-gambar mencari gambar di web yang sesuai dengan deskripsi teks, lalu menganalisis hasilnya. Alat ini mendukung skenario tanya jawab visual dan rekomendasi gambar.
Penggunaan
Tambahkan alat web_search_image dalam parameter tools saat menggunakan Responses API.
# Impor dependensi dan buat client...
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)Model yang didukung
Internasional
Qwen-Plus:
qwen3.5-plus,qwen3.5-plus-2026-02-15Qwen-Flash:
qwen3.5-flash,qwen3.5-flash-2026-02-23Open-source Qwen:
qwen3.5-397b-a17b,qwen3.5-122b-a10b,qwen3.5-27b,qwen3.5-35b-a3b
Global
Qwen-Plus:
qwen3.5-plus,qwen3.5-plus-2026-02-15Qwen-Flash:
qwen3.5-flash,qwen3.5-flash-2026-02-23Open-source Qwen:
qwen3.5-397b-a17b,qwen3.5-122b-a10b,qwen3.5-27b,qwen3.5-35b-a3b
China daratan
Qwen-Plus:
qwen3.5-plus,qwen3.5-plus-2026-02-15Qwen-Flash:
qwen3.5-flash,qwen3.5-flash-2026-02-23Open-source Qwen:
qwen3.5-397b-a17b,qwen3.5-122b-a10b,qwen3.5-27b,qwen3.5-35b-a3b
Hanya tersedia melalui Responses API.
Mulai
Kode berikut memanggil alat pencarian teks-ke-gambar menggunakan Responses API untuk mencari gambar berdasarkan deskripsi teks.
Dapatkan Kunci API dan konfigurasikan sebagai Variabel lingkungan.
import os
import json
from openai import OpenAI
client = OpenAI(
# Jika tidak ada variabel lingkungan, gunakan: api_key="sk-xxx" (tidak disarankan).
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})")
# Urai dan tampilkan daftar gambar
if item.output:
images = json.loads(item.output)
print(f" Found {len(images)} images:")
for img in images[:5]: # Tampilkan 5 pertama
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)
# Tampilkan penggunaan token dan statistik pemanggilan tool
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({
// Jika tidak ada variabel lingkungan, gunakan: apiKey: "sk-xxx" (tidak disarankan).
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})`);
// Urai dan tampilkan daftar gambar
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);
}
}
// Tampilkan penggunaan token dan statistik pemanggilan tool
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"}
]
}'Menjalankan kode di atas menghasilkan output seperti berikut:
[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: 1Output streaming
Pencarian teks-ke-gambar mungkin memerlukan waktu. Aktifkan streaming untuk mendapatkan hasil antara secara real-time.
import os
import json
from openai import OpenAI
client = OpenAI(
# Jika tidak ada variabel lingkungan, gunakan: api_key="sk-xxx" (tidak disarankan).
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:
# Pemanggilan tool dimulai
if event.type == "response.output_item.added":
if event.item.type == "web_search_image_call":
print("[Tool call] Text-to-image search in progress...")
# Pemanggilan tool selesai. Urai dan tampilkan daftar gambar
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]: # Tampilkan 5 pertama
print(f" [{img['index']}] {img['title']}")
print(f" {img['url']}")
if len(images) > 5:
print(f" ... Total {len(images)} images")
# Respons model dimulai
elif event.type == "response.content_part.added":
print(f"\n[Model response]")
# Output teks yang distreaming
elif event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
# Respons selesai. Tampilkan penggunaan
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({
// Jika tidak ada variabel lingkungan, gunakan: apiKey: "sk-xxx" (tidak disarankan).
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) {
// Pemanggilan tool dimulai
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...");
}
}
// Pemanggilan tool selesai. Urai dan tampilkan daftar gambar
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`);
}
}
}
}
// Respons model dimulai
else if (event.type === "response.content_part.added") {
console.log(`\n[Model response]`);
}
// Output teks yang distreaming
else if (event.type === "response.output_text.delta") {
process.stdout.write(event.delta);
}
// Respons selesai. Tampilkan penggunaan
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
}'Menjalankan kode di atas menghasilkan output seperti berikut:
[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: 1Penagihan
Penagihan mencakup:
Biaya pemanggilan model: Hasil pencarian gambar ditambahkan ke prompt, sehingga meningkatkan jumlah input token. Penagihan mengikuti harga standar model (lihat Daftar model).
Biaya pemanggilan tool: Biaya per 1.000 kali pemanggilan adalah: $8 untuk mode penyebaran internasional, $3,44 untuk mode penyebaran China daratan dan global.