Web extractor gives models internet access. It fetches URLs, feeds page content into the context, and enables responses grounded in live web data -- summarizing articles, answering questions from current sources, or extracting structured information.
Tip: For math or data analytics tasks, pairweb_extractorwithcode_interpreterfor better accuracy.
How it works
-
Include
web_extractor(and typicallyweb_search) in thetoolsarray of your API request, along with a prompt that references a URL or topic. -
The model identifies URLs, fetches content, and appends it to the context as input tokens.
-
The model generates a response grounded in the retrieved content.
Extracted content increases input tokens. See Billing for pricing details.
Prerequisites
You need:
-
An API key exported as
DASHSCOPE_API_KEY(see Configure API key through environment variables)
Quick start
Use the Responses API to call web extractor. The examples use web_search, web_extractor, and code_interpreter with qwen3-max-2026-01-23 in thinking mode.
First, get an API key and export the API key as an environment variable.
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it",
tools=[
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
extra_body={
"enable_thinking": True
}
)
# Uncomment to view intermediate output
# print(response.output)
print("=" * 20 + "Response" + "=" * 20)
print(response.output_text)
# Print tool invocation count
usage = response.usage
print("=" * 20 + "Tool Invocation Count" + "=" * 20)
if hasattr(usage, 'x_tools') and usage.x_tools:
print(f"Web Extractor invocations: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")import OpenAI from "openai";
import process from 'process';
const openai = new OpenAI({
// If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it",
tools: [
{ type: "web_search" },
{ type: "web_extractor" },
{ type: "code_interpreter" }
],
enable_thinking: true
});
console.log("====================Response====================");
console.log(response.output_text);
// Print tool invocation count
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}`);
}
// Uncomment to view intermediate output
// 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, find the code interpreter topic and summarize it",
"tools": [
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
"enable_thinking": true
}'Running the code above produces a response similar to:
====================Response====================
Based on the official Alibaba Cloud Model Studio documentation, here is a summary of the **Code Interpreter** feature:
## Overview
...
> **Source**: Alibaba Cloud Model Studio Official Documentation - [Qwen Code Interpreter](https://www.alibabacloud.com/help/zh/model-studio/qwen-code-interpreter) and [Assistant API Code Interpreter](https://www.alibabacloud.com/help/zh/model-studio/code-interpreter) (Last updated: December 2025)
====================Tool Invocation Count====================
Web Extractor invocations: 1
Invocation methods
Web extractor supports three APIs. Use Responses API for new integrations -- it provides the most control.
| API | Tool configuration | Streaming required | Notes |
|---|---|---|---|
| Responses API (recommended) | Add web_search and web_extractor to tools |
No | Exposes intermediate tool execution status |
| Chat Completions API | Set enable_search: true, search_strategy: "agent_max" |
Yes | Non-streaming not supported |
| DashScope API | Set enable_search: true, search_strategy: "agent_max" |
Yes | Java SDK not supported |
When usingqwen3-max-2026-01-23, setenable_thinkingtotrue.
Responses API
response = client.responses.create(
model="qwen3-max-2026-01-23",
input="<your-prompt>",
tools=[
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
extra_body={
"enable_thinking": True
}
)
Chat Completions API
completion = client.chat.completions.create(
model="qwen3-max-2026-01-23",
messages=[{"role": "user", "content": "<your-prompt>"}],
extra_body={
"enable_thinking": True,
"enable_search": True,
"search_options": {"search_strategy": "agent_max"}
},
stream=True
)
DashScope API
from dashscope import Generation
response = Generation.call(
model="qwen3-max-2026-01-23",
messages=[{"role": "user", "content": "<your-prompt>"}],
enable_search=True,
search_options={"search_strategy": "agent_max"},
enable_thinking=True,
result_format="message",
stream=True,
incremental_output=True
)
Stream responses
Web extraction can take time. Stream responses to receive reasoning, tool calls, and output in real time.
Tip: Responses API exposes tool execution status, making it ideal for streaming.
Responses API
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it",
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:
# Reasoning process
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)
# Tool invocation completion
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
# Response content
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)
# Response completed -- print tool invocation count
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({
// If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it",
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) {
// Reasoning process
if (chunk.type === 'response.reasoning_summary_text.delta') {
if (!reasoningStarted) {
console.log("====================Reasoning Process====================");
reasoningStarted = true;
}
process.stdout.write(chunk.delta);
}
// Tool invocation completion
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;
}
}
// Response content
else if (chunk.type === 'response.output_text.delta') {
if (!outputStarted) {
console.log("\n" + "====================Response====================");
outputStarted = true;
}
process.stdout.write(chunk.delta);
}
// Response completed -- print tool invocation count
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, find the code interpreter topic and summarize it",
"tools": [
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
"enable_thinking": true,
"stream": true
}'Chat Completions API
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it"}
],
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({
// If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it" }
],
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, find the code interpreter topic and summarize it"}
],
"enable_search": true,
"search_options": {"search_strategy": "agent_max"},
"stream": true
}'DashScope API
The Java SDK is not supported.
import os
import dashscope
from dashscope import Generation
# If the environment variable is not configured, replace with: 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, find the code interpreter topic and summarize it"}
],
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
# Reasoning process
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)
# Response content
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)
# Save the last usage info
if hasattr(chunk, 'usage') and chunk.usage:
last_usage = chunk.usage
# Print tool invocation count
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, find the code interpreter topic and summarize it"
}
]
},
"parameters": {
"enable_thinking": true,
"enable_search": true,
"search_options": {
"search_strategy": "agent_max"
},
"result_format": "message"
}
}'Streaming event types
When streaming with Responses API, these events track extraction and generation progress:
| Event type | Description |
|---|---|
response.reasoning_summary_text.delta |
Reasoning text from the model's thinking process |
response.output_item.done |
Tool call completed. Check item.type for web_extractor_call to get results |
response.output_text.delta |
Response text chunks |
response.completed |
Response complete. The usage field contains tool invocation counts |
Supported models
International
| Model family | Model IDs |
|---|---|
| Qwen-Max | qwen3-max, qwen3-max-2026-01-23 (thinking mode) |
| Qwen-Plus | qwen3.5-plus, qwen3.5-plus-2026-02-15 |
| Qwen-Flash | qwen3.5-flash, qwen3.5-flash-2026-02-23 |
| Open-source Qwen | qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b |
Global
| Model family | Model IDs |
|---|---|
| Qwen-Plus | qwen3.5-plus, qwen3.5-plus-2026-02-15 |
| Qwen-Flash | qwen3.5-flash, qwen3.5-flash-2026-02-23 |
| Open-source Qwen | qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b |
Chinese Mainland
| Model family | Model IDs |
|---|---|
| Qwen-Max | qwen3-max, qwen3-max-2026-01-23 (thinking mode) |
| Qwen-Plus | qwen3.5-plus, qwen3.5-plus-2026-02-15 |
| Qwen-Flash | qwen3.5-flash, qwen3.5-flash-2026-02-23 |
| Open-source Qwen | qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b |
Billing
Web extractor costs:
| Component | Details |
|---|---|
| Model cost | Extracted web content is appended to the prompt, which increases input tokens. Billed at the model's standard token price. See Models for pricing. |
| Tool cost | Includes charges for both web extractor and web search invocations. |
Web search pricing (per 1,000 invocations):
| Region | Price |
|---|---|
| Chinese Mainland and Global | $0.57341 |
| International | $10.00 |
The web extractor tool itself is free for a limited time.