大規模言語モデルは、直接 Web コンテンツにアクセスすることはできません。Web Extractor ツールは、指定された URL からコンテンツをフェッチして抽出し、モデルが必要とする情報を提供します。
利用方法
Web Extractor 機能は 3 つの呼び出しメソッドをサポートしており、それぞれ設定パラメーターが異なります。
OpenAI 互換の Responses API
tools パラメーターで web_search と web_extractor の両方のツールを追加して Web Extractor を有効にし、enable_thinking パラメーターを設定して思考モードを有効にします。
最適な結果を得るためには、code_interpreter ツールも有効にすることを推奨します。# 依存関係をインポートし、クライアントを作成...
response = client.responses.create(
model="qwen3-max-2026-01-23",
input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
tools=[
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
extra_body={
"enable_thinking": True
}
)
print(response.output_text)OpenAI 互換の Chat Completions API
enable_search パラメーターで Web 検索を有効にし、search_strategy を agent_max に設定して Web Extractor を有効にします。また、enable_thinking パラメーターを設定して思考モードを有効にする必要があります。
非ストリーミング出力はサポートされていません。
# 依存関係をインポートし、クライアントを作成...
completion = client.chat.completions.create(
model="qwen3-max-2026-01-23",
messages=[{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content"}],
extra_body={
"enable_thinking": True,
"enable_search": True,
"search_options": {"search_strategy": "agent_max"}
},
stream=True
)DashScope
enable_search パラメーターで Web 検索を有効にし、search_strategy を agent_max に設定して Web Extractor を有効にします。また、enable_thinking パラメーターを設定して思考モードを有効にする必要があります。
非ストリーミング出力はサポートされていません。
from dashscope import Generation
response = Generation.call(
model="qwen3-max-2026-01-23",
messages=[{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content"}],
enable_search=True,
search_options={"search_strategy": "agent_max"},
enable_thinking=True,
result_format="message",
stream=True,
incremental_output=True
)サポートされるモデル
思考モードが有効な qwen3-max-2026-01-23 をサポートします。
クイックスタート
以下のコードを実行して、Responses API 経由で Web Extractor ツールを呼び出し、技術ドキュメントを自動的に要約します。
import os
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-max-2026-01-23",
input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
tools=[
{
"type": "web_search"
},
{
"type": "web_extractor"
},
{
"type": "code_interpreter"
}
],
extra_body = {
"enable_thinking": True
}
)
# 中間出力を表示するには、次の行のコメントを解除してください
# print(response.output)
print("="*20+"Response"+"="*20)
print(response.output_text)
# ツール呼び出し回数を表示
usage = response.usage
print("="*20+"Tool Invocation Count"+"="*20)
if hasattr(usage, 'x_tools') and usage.x_tools:
print(f"\nWeb Extractor invocations: {usage.x_tools.get('web_extractor', {}).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-max-2026-01-23",
input: "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
tools: [
{ type: "web_search" },
{ type: "web_extractor" },
{ type: "code_interpreter" }
],
enable_thinking: true
});
console.log("====================Response====================");
console.log(response.output_text);
// ツール呼び出し回数を表示
console.log("====================Tool Invocation Count====================");
if (response.usage && response.usage.x_tools) {
console.log(`Web Extractor invocations: ${response.usage.x_tools.web_extractor?.count || 0}`);
console.log(`Web Search invocations: ${response.usage.x_tools.web_search?.count || 0}`);
}
// 中間出力を表示するには、次の行のコメントを解除してください
// console.log(JSON.stringify(response.output[0], null, 2));
}
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-max-2026-01-23",
"input": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
"tools": [
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
"enable_thinking": true
}'上記のコードを実行すると、以下のような応答が生成されます。
====================Response====================
Alibaba Cloud Model Studio の公式ドキュメントに基づき、**Code Interpreter** 機能の概要を以下に示します。
## 概要
...
> **出典**: Alibaba Cloud Model Studio 公式ドキュメント - [Qwen Code Interpreter](https://www.alibabacloud.com/help/model-studio/qwen-code-interpreter) および [Assistant API Code Interpreter](https://www.alibabacloud.com/help/model-studio/code-interpreter) (最終更新日: 2025 年 12 月)
====================Tool Invocation Count====================
Web Extractor 呼び出し回数: 1ストリーミング出力
Web 抽出には時間がかかる場合があります。ストリーミング出力を有効にして、中間結果をリアルタイムで受け取ることを推奨します。
OpenAI 互換の Responses API
import os
from openai import OpenAI
client = OpenAI(
# 環境変数を設定していない場合は、次の行を api_key="sk-xxx" に置き換えてください。
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
)
stream = client.responses.create(
model="qwen3-max-2026-01-23",
input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
tools=[
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
stream=True,
extra_body={"enable_thinking": True}
)
reasoning_started = False
output_started = False
for chunk in stream:
# 思考プロセスを表示
if chunk.type == 'response.reasoning_summary_text.delta':
if not reasoning_started:
print("="*20 + "Reasoning Process" + "="*20)
reasoning_started = True
print(chunk.delta, end='', flush=True)
# ツール呼び出しの完了を表示
elif chunk.type == 'response.output_item.done':
if hasattr(chunk, 'item') and hasattr(chunk.item, 'type'):
if chunk.item.type == 'web_extractor_call':
print("\n" + "="*20 + "Tool Invocation" + "="*20)
print(chunk.item.goal)
print(chunk.item.output)
elif chunk.item.type == 'reasoning':
reasoning_started = False
# 応答内容を表示
elif chunk.type == 'response.output_text.delta':
if not output_started:
print("\n" + "="*20 + "Response" + "="*20)
output_started = True
print(chunk.delta, end='', flush=True)
# 応答完了、ツール呼び出し回数を表示
elif chunk.type == 'response.completed':
print("\n" + "="*20 + "Tool Invocation Count" + "="*20)
usage = chunk.response.usage
if hasattr(usage, 'x_tools') and usage.x_tools:
print(f"Web Extractor invocations: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")
print(f"Web Search invocations: {usage.x_tools.get('web_search', {}).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.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});
async function main() {
const stream = await openai.responses.create({
model: "qwen3-max-2026-01-23",
input: "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
tools: [
{ type: "web_search" },
{ type: "web_extractor" },
{ type: "code_interpreter" }
],
stream: true,
enable_thinking: true
});
let reasoningStarted = false;
let outputStarted = false;
for await (const chunk of stream) {
// 思考プロセスを表示
if (chunk.type === 'response.reasoning_summary_text.delta') {
if (!reasoningStarted) {
console.log("====================Reasoning Process====================");
reasoningStarted = true;
}
process.stdout.write(chunk.delta);
}
// ツール呼び出しの完了を表示
else if (chunk.type === 'response.output_item.done') {
if (chunk.item && chunk.item.type === 'web_extractor_call') {
console.log("\n" + "====================Tool Invocation====================");
console.log(chunk.item.goal);
console.log(chunk.item.output);
} else if (chunk.item && chunk.item.type === 'reasoning') {
reasoningStarted = false;
}
}
// 応答内容を表示
else if (chunk.type === 'response.output_text.delta') {
if (!outputStarted) {
console.log("\n" + "====================Response====================");
outputStarted = true;
}
process.stdout.write(chunk.delta);
}
// 応答完了、ツール呼び出し回数を表示
else if (chunk.type === 'response.completed') {
console.log("\n" + "====================Tool Invocation Count====================");
const usage = chunk.response.usage;
if (usage && usage.x_tools) {
console.log(`Web Extractor invocations: ${usage.x_tools.web_extractor?.count || 0}`);
console.log(`Web Search invocations: ${usage.x_tools.web_search?.count || 0}`);
}
}
}
}
main();curl -X POST https://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max-2026-01-23",
"input": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content",
"tools": [
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
"enable_thinking": true,
"stream": true
}'OpenAI 互換の Chat Completions API
import os
from openai import OpenAI
client = OpenAI(
# 環境変数を設定していない場合は、次の行を api_key="sk-xxx" に置き換えてください。
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
stream = client.chat.completions.create(
model="qwen3-max-2026-01-23",
messages=[
{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content"}
],
extra_body={
"enable_search": True,
"search_options": {"search_strategy": "agent_max"}
},
stream=True
)
for chunk in stream:
print(chunk)import OpenAI from "openai";
import process from 'process';
const openai = new OpenAI({
// 環境変数を設定していない場合は、次の行を apiKey: "sk-xxx" に置き換えてください。
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const stream = await openai.chat.completions.create({
model: "qwen3-max-2026-01-23",
messages: [
{ role: "user", content: "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content" }
],
enable_search: true,
search_options: { search_strategy: "agent_max" },
stream: true
});
for await (const chunk of stream) {
console.log(chunk);
}
}
main();curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max-2026-01-23",
"messages": [
{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content"}
],
"enable_search": true,
"search_options": {"search_strategy": "agent_max"},
"stream": true
}'DashScope
Java SDK はサポートされていません。
import os
import dashscope
from dashscope import Generation
# 環境変数を設定していない場合は、次の行を dashscope.api_key = "sk-xxx" に置き換えてください。
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")
response = Generation.call(
model="qwen3-max-2026-01-23",
messages=[
{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content"}
],
enable_search=True,
search_options={"search_strategy": "agent_max"},
enable_thinking=True,
result_format="message",
stream=True,
incremental_output=True
)
reasoning_started = False
output_started = False
last_usage = None
for chunk in response:
if chunk.status_code == 200:
message = chunk.output.choices[0].message
# 思考プロセスを表示
if hasattr(message, 'reasoning_content') and message.reasoning_content:
if not reasoning_started:
print("="*20 + "Reasoning Process" + "="*20)
reasoning_started = True
print(message.reasoning_content, end='', flush=True)
# 応答内容を表示
if hasattr(message, 'content') and message.content:
if not output_started:
print("\n" + "="*20 + "Response" + "="*20)
output_started = True
print(message.content, end='', flush=True)
# 最後の usage 情報を保存
if hasattr(chunk, 'usage') and chunk.usage:
last_usage = chunk.usage
# ツール呼び出し回数を表示
if last_usage:
print("\n" + "="*20 + "Tool Invocation Count" + "="*20)
if hasattr(last_usage, 'plugins') and last_usage.plugins:
print(f"Web Extractor invocations: {last_usage.plugins.get('web_extractor', {}).get('count', 0)}")curl -X POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "X-DashScope-SSE: enable" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max-2026-01-23",
"input": {
"messages": [
{
"role": "user",
"content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter section and summarize the main content"
}
]
},
"parameters": {
"enable_thinking": true,
"enable_search": true,
"search_options": {
"search_strategy": "agent_max"
},
"result_format": "message"
}
}'課金
課金には以下の要素が含まれます。
モデル呼び出しコスト:抽出された Web コンテンツがプロンプトに追加されるため、モデルの入力トークンが増加します。これは、モデルの標準料金で課金されます。料金の詳細については、「モデル」をご参照ください。
ツール呼び出しコスト:Web Extractor と Web Search の両方の料金が含まれます。
Web Search の 1,000 回の呼び出しごとの料金:
中国本土:$0.57341。
国際:$10.00。
Web Extractor ツールは現在、期間限定で無料です。