LLM は直接 Web ページのデータにアクセスできません。Web エクストラクターは、URL にアクセスし、そのコンテンツをモデル用に抽出します。
使用方法
Web エクストラクターは 3 つの方法で呼び出すことができます。必要なパラメーターは、各方法で異なります。
OpenAI互換 - Responses API
web_search と web_extractor を tools パラメーターに追加します。
qwen3-max-2026-01-23を使用する場合は、enable_thinkingをtrueに設定します。
数学やデータ分析の問題で精度を向上させるには、code_interpreter ツールも有効にしてください。# 依存関係をインポートし、クライアントを作成します...
response = client.responses.create(
model="qwen3.7-max",
input="Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
tools=[
# Web 抽出を有効にするには、Web 検索ツールも有効にします
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
extra_body={
# 思考モードを有効にする必要があります
"enable_thinking": True
}
)
print(response.output_text)
OpenAI互換 - Chat Completions API
enable_search を true に、search_strategy を agent_max に設定します。また、enable_thinking も true に設定します。
非ストリーミング出力はサポートされていません。
# 依存関係をインポートし、クライアントを作成します...
completion = client.chat.completions.create(
model="qwen3.7-max",
messages=[{"role": "user", "content": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください"}],
extra_body={
"enable_thinking": True,
"enable_search": True,
"search_options": {"search_strategy": "agent_max"}
},
stream=True
)
DashScope
enable_search を true に、search_strategy を agent_max に設定します。また、enable_thinking も true に設定します。
非ストリーミング出力はサポートされていません。
from dashscope import Generation
response = Generation.call(
model="qwen3.7-max",
messages=[{"role": "user", "content": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください"}],
enable_search=True,
search_options={"search_strategy": "agent_max"},
enable_thinking=True,
result_format="message",
stream=True,
incremental_output=True
)
サポート対象モデル
推奨モデル
Responses API
Qwen-Max:Qwen3.7-Max シリーズ
Qwen-Plus:Qwen3.7-Plus シリーズ、Qwen3.6-Plus シリーズ、Qwen3.5-Plus シリーズ
Chat Completions API / DashScope
-
Qwen-Max (思考モード) :Qwen3-Max シリーズ
-
Qwen-Plus:Qwen3.7-Plus シリーズ、Qwen3.6-Plus シリーズ、Qwen3.5-Plus シリーズ
その他のモデル
以下のモデルもこのツールをサポートしていますが、推奨モデルほどの性能は発揮しない場合があります。
-
Qwen-Flash:Qwen3.6-Flash シリーズ、Qwen3.5-Flash シリーズ
-
Qwen3.6 オープンソースシリーズ (qwen3.6-27b を除く)
-
Qwen3.5 オープンソースシリーズ
クイックスタート
この例では、Responses API を介して Web エクストラクターを呼び出し、技術ドキュメントを要約します。
APIキーを取得 し、環境変数として設定する 必要があります。
import os
from openai import OpenAI
client = OpenAI(
# 環境変数が設定されていない場合は、次の行を api_key="sk-xxx" に置き換えます (非推奨)。Model Studio の API キーを使用してください。
api_key=os.getenv("DASHSCOPE_API_KEY"),
# シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)
response = client.responses.create(
model="qwen3.7-max",
input="Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
tools=[
{
"type": "web_search"
},
{
"type": "web_extractor"
},
{
"type": "code_interpreter"
}
],
extra_body = {
"enable_thinking": True
}
)
# 中間プロセス出力を表示するには、次の行のコメントを解除します
# print(response.output)
print("="*20+"レスポンス内容"+"="*20)
print(response.output_text)
# ツール呼び出しの回数を出力します
usage = response.usage
print("="*20+"ツール呼び出し回数"+"="*20)
if hasattr(usage, 'x_tools') and usage.x_tools:
print(f"\nWeb抽出回数: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")
print(f"Web 検索回数: {usage.x_tools.get('web_search', {}).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,
// シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const response = await openai.responses.create({
model: "qwen3.7-max",
input: "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
tools: [
{ type: "web_search" },
{ type: "web_extractor" },
{ type: "code_interpreter" }
],
enable_thinking: true
});
console.log("====================レスポンス内容====================");
console.log(response.output_text);
// ツール呼び出しの回数を出力します
console.log("====================ツール呼び出し回数====================");
if (response.usage && response.usage.x_tools) {
console.log(`Web抽出回数: ${response.usage.x_tools.web_extractor?.count || 0}`);
console.log(`Web 検索回数: ${response.usage.x_tools.web_search?.count || 0}`);
}
// 中間プロセス出力を表示するには、次の行のコメントを解除します
// console.log(JSON.stringify(response.output[0], null, 2));
}
main();curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"input": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
"tools": [
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
"enable_thinking": true
}'出力例:
====================レスポンス内容====================
Alibaba Cloud Model Studio の公式ドキュメントに基づき、 コードインタープリター 機能のコアコンテンツを要約しました:
## 1. 機能の位置付け
...
> ドキュメントソース: 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月)
====================ツール呼び出し回数====================
Web抽出回数: 1
ストリーミング出力
Web 抽出には時間がかかる場合があります。ストリーミング出力を有効にすると、中間結果をリアルタイムで受信できます。
Responses API を使用して、中間のツール実行ステータスを取得します。
OpenAI互換 - Responses API
import os
from openai import OpenAI
client = OpenAI(
# 環境変数が設定されていない場合は、次の行を api_key="sk-xxx" に置き換えます (非推奨)。Model Studio の API キーを使用してください。
api_key=os.getenv("DASHSCOPE_API_KEY"),
# シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)
stream = client.responses.create(
model="qwen3.7-max",
input="Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
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 + "思考プロセス" + "="*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 + "ツール呼び出し" + "="*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 + "レスポンス内容" + "="*20)
output_started = True
print(chunk.delta, end='', flush=True)
# レスポンスが完了したら、ツール呼び出しの回数を出力します
elif chunk.type == 'response.completed':
print("\n" + "="*20 + "ツール呼び出し回数" + "="*20)
usage = chunk.response.usage
if hasattr(usage, 'x_tools') and usage.x_tools:
print(f"Web抽出回数: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")
print(f"Web 検索回数: {usage.x_tools.get('web_search', {}).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,
// シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const stream = await openai.responses.create({
model: "qwen3.7-max",
input: "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
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("====================思考プロセス====================");
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" + "====================ツール呼び出し====================");
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" + "====================レスポンス内容====================");
outputStarted = true;
}
process.stdout.write(chunk.delta);
}
// レスポンスが完了したら、ツール呼び出しの回数を出力します
else if (chunk.type === 'response.completed') {
console.log("\n" + "====================ツール呼び出し回数====================");
const usage = chunk.response.usage;
if (usage && usage.x_tools) {
console.log(`Web抽出回数: ${usage.x_tools.web_extractor?.count || 0}`);
console.log(`Web 検索回数: ${usage.x_tools.web_search?.count || 0}`);
}
}
}
}
main();curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"input": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください",
"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" に置き換えます (非推奨)。Model Studio の API キーを使用してください。
api_key=os.getenv("DASHSCOPE_API_KEY"),
# シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)
stream = client.chat.completions.create(
model="qwen3.7-max",
messages=[
{"role": "user", "content": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください"}
],
extra_body={
"enable_thinking": True,
"enable_search": True,
"search_options": {"search_strategy": "agent_max"}
},
stream=True
)
reasoning_started = False
output_started = False
for chunk in stream:
if chunk.choices:
delta = chunk.choices[0].delta
# 思考プロセスを出力します
if hasattr(delta, 'reasoning_content') and delta.reasoning_content:
if not reasoning_started:
print("="*20 + "思考プロセス" + "="*20)
reasoning_started = True
print(delta.reasoning_content, end='', flush=True)
# レスポンス内容を出力します
if delta.content:
if not output_started:
print("\n" + "="*20 + "レスポンス内容" + "="*20)
output_started = True
print(delta.content, end='', flush=True)import OpenAI from "openai";
import process from 'process';
const openai = new OpenAI({
// 環境変数が設定されていない場合は、次の行を apiKey: "sk-xxx" に置き換えます。Model Studio の API キーを使用してください。
apiKey: process.env.DASHSCOPE_API_KEY,
// シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const stream = await openai.chat.completions.create({
model: "qwen3.7-max",
messages: [
{ role: "user", content: "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください" }
],
enable_thinking: true,
enable_search: true,
search_options: { search_strategy: "agent_max" },
stream: true
});
let reasoningStarted = false;
let outputStarted = false;
for await (const chunk of stream) {
if (chunk.choices && chunk.choices.length > 0) {
const delta = chunk.choices[0].delta;
// 思考プロセスを出力します
if (delta.reasoning_content) {
if (!reasoningStarted) {
console.log("====================思考プロセス====================");
reasoningStarted = true;
}
process.stdout.write(delta.reasoning_content);
}
// レスポンス内容を出力します
if (delta.content) {
if (!outputStarted) {
console.log("\n" + "====================レスポンス内容====================");
outputStarted = true;
}
process.stdout.write(delta.content);
}
}
}
}
main();curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"messages": [
{"role": "user", "content": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください"}
],
"enable_thinking": true,
"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" に置き換えます。Model Studio の API キーを使用してください。
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")
# シンガポールリージョン。{WorkspaceId} を実際のワークスペース ID に置き換えます。URL はリージョンによって異なります。
dashscope.base_http_api_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"
response = Generation.call(
model="qwen3.7-max",
messages=[
{"role": "user", "content": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください"}
],
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
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 + "思考プロセス" + "="*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 + "レスポンス内容" + "="*20)
output_started = True
print(message.content, end='', flush=True)
else:
print(f"\nリクエスト失敗: code={chunk.code}, message={chunk.message}")
breakcurl -X POST https://{WorkspaceId}.ap-southeast-1.maas.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.7-max",
"input": {
"messages": [
{
"role": "user",
"content": "Alibaba Cloud Model Studio のコードインタープリターに関する公式ドキュメントにアクセスし、その主な内容を要約してください"
}
]
},
"parameters": {
"enable_thinking": true,
"enable_search": true,
"search_options": {
"search_strategy": "agent_max"
},
"result_format": "message"
}
}'課金
課金には以下が含まれます:
-
モデル呼び出し料金: Web ページから抽出されたコンテンツがプロンプトに追加され、入力トークン数が増加します。これらのトークンは、モデルの標準レートで課金されます。料金の詳細については、Model Studio コンソールをご参照ください。
-
ツール呼び出し料金: Web 抽出と Web 検索が含まれます。
-
1,000 回あたりの Web 検索料金:
-
中国本土およびグローバルデプロイメントスコープ: $0.57341。
-
国際デプロイメントスコープ: $10.00。
-
-
Web エクストラクターは期間限定で無料です。
-