Call web extractor through the Responses API to summarize a web page. The examples below use web_search and web_extractor with qwen4-max in thinking mode.
Python
Node.js
curl
Copy
import osfrom openai import OpenAIclient = OpenAI( # If the environment variable is not configured, replace with: api_key="sk-xxx" api_key=os.getenv("DASHSCOPE_API_KEY"), # Singapore (ap-southeast-1). For another region, replace ap-southeast-1 in the URL. # API keys are region-specific. See https://docs.qwencloud.com/developer-guides/getting-started/regions base_url="https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1")response = client.responses.create( model="qwen4-max", input="Please visit the official QwenCloud documentation, find the code interpreter topic and summarize it", tools=[ {"type": "web_search"}, {"type": "web_extractor"} ], extra_body={ "enable_thinking": True })# Uncomment to view intermediate output# print(response.output)print("=" * 20 + "Response" + "=" * 20)print(response.output_text)# Print tool invocation countusage = getattr(response, "tool_usage", {})print("=" * 20 + "Tool Invocation Count" + "=" * 20)if usage: print(f"Web Extractor invocations: {usage.get('web_extractor', {}).get('num_requests')}")
Copy
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, // Singapore (ap-southeast-1). For another region, replace ap-southeast-1 in the URL. // API keys are region-specific. See https://docs.qwencloud.com/developer-guides/getting-started/regions baseURL: "https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1"});async function main() { const response = await openai.responses.create({ model: "qwen4-max", input: "Please visit the official QwenCloud documentation, find the code interpreter topic and summarize it", tools: [ { type: "web_search" }, { type: "web_extractor" } ], enable_thinking: true }); console.log("====================Response===================="); console.log(response.output_text); // Print tool invocation count console.log("====================Tool Invocation Count===================="); if (response.tool_usage) { console.log(`Web Extractor invocations: ${response.tool_usage.web_extractor?.num_requests}`); console.log(`Web Search invocations: ${response.tool_usage.web_search?.num_requests}`); } // Uncomment to view intermediate output // console.log(JSON.stringify(response.output[0], null, 2));}main();
Copy
# Singapore (ap-southeast-1). For another region, replace ap-southeast-1 in the URL.# API keys are region-specific. See https://docs.qwencloud.com/developer-guides/getting-started/regionscurl -X POST https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1/responses \-H "Authorization: Bearer $DASHSCOPE_API_KEY" \-H "Content-Type: application/json" \-d '{ "model": "qwen4-max", "input": "Please visit the official QwenCloud documentation, find the code interpreter topic and summarize it", "tools": [ {"type": "web_search"}, {"type": "web_extractor"} ], "enable_thinking": true}'
The response contains the model's generated text plus metadata about tool usage.
Field
Description
output_text
The model's final text response, grounded in the extracted web content
output[]
Array of intermediate items including web_extractor_call objects (each with goal and output fields showing what URL was fetched and the extracted content)
usage.x_tools.web_extractor.count
Number of web extractor invocations in this request
Web extractor supports two APIs. The Responses API provides the most control over tool behavior -- use it for new integrations.
API
Tool configuration
Streaming required
Notes
Responses API (recommended)
Add web_search and web_extractor to tools
No
Exposes intermediate tool execution status
Anthropic-compatible
Add web_search (and web_fetch for web extractor) to tools
No
Targets Anthropic clients like Claude Code
When using qwen4-max or qwen3.8-max, set enable_thinking to true.
Responses API
Anthropic-compatible
Copy
response = client.responses.create( model="qwen4-max", input="Summarize the content at https://example.com/article", tools=[ {"type": "web_search"}, {"type": "web_extractor"} ], extra_body={ "enable_thinking": True })
Add the Anthropic server-side web fetch tool (name set to web_fetch) to the tools parameter to enable the web extractor. You must also add the web search tool (name set to web_search) in the same request. The endpoint is https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic.
This method targets Anthropic official clients such as Claude Code. In those clients, a plain natural-language question triggers the web extractor with no extra configuration.
When you call the API directly with the Anthropic SDK or over HTTP, pass the client identifier x-anthropic-billing-header: cc_entrypoint=cli; in system. Otherwise the web extractor does not take effect.
About the tool version: The date suffix in type (for example web_fetch_20250910 and web_search_20250305) is determined by the version of the Anthropic official client, and a newer client may send a different dated version. QwenCloud identifies both tools by their category and does not validate the date suffix, so you do not need to pin type to a specific version. Simply pass the value your client actually sends.
If you add the web fetch tool without the web search tool, the request fails with the InvalidParameter error: The web_extractor tool must be executed with web_search tool.
Copy
# Import dependencies and create the client...message = client.messages.create( model="qwen4-max", max_tokens=4096, # Pass the client identifier system=[{"type": "text", "text": "x-anthropic-billing-header: cc_entrypoint=cli;"}], messages=[{"role": "user", "content": "Read the QwenCloud code interpreter documentation and summarize the key points."}], tools=[ # Enabling the web extractor requires the web search tool as well # The date suffix in type depends on the client version. The values below are the ones current Claude Code sends. {"type": "web_search_20250305", "name": "web_search", "max_uses": 5}, {"type": "web_fetch_20250910", "name": "web_fetch", "max_uses": 5} ])
The extraction process is returned as server_tool_use (fetch request) and web_fetch_tool_result (fetch results) content blocks. The number of fetches is reported in usage.server_tool_use.web_fetch_requests.
For general streaming concepts (SSE protocol, how to enable streaming, and token usage), see Streaming output. This section covers only the event types specific to web extractor.
Web extraction can take time. Use streaming to receive reasoning steps, tool calls, and response text as they happen. The Responses API exposes intermediate execution status for each tool call, making it the best choice for streaming.When streaming with the Responses API, the following event types indicate progress through the extraction and generation pipeline:
Event type
Description
response.reasoning_text.delta
Incremental reasoning text from the model's thinking process
response.output_item.done
A tool call has completed. Check item.type for web_extractor_call to get the extraction result
response.output_text.delta
Incremental response text
response.completed
The response is complete. The usage field contains tool invocation counts
To handle the web_extractor_call event in a stream, check for the event type and read its goal and output fields:
Copy
for chunk in stream: if chunk.type == 'response.output_item.done': if hasattr(chunk, 'item') and chunk.item.type == 'web_extractor_call': print(f"Fetched: {chunk.item.goal}") print(f"Content: {chunk.item.output}") elif chunk.type == 'response.output_text.delta': print(chunk.delta, end='', flush=True) elif chunk.type == 'response.completed': usage = getattr(chunk.response, "tool_usage", {}) if usage: print(f"Web Extractor invocations: {usage.get('web_extractor', {}).get('num_requests')}")
deepseek-v4.1-flash-1017 supports the built-in web_extractor tool in the Responses API and web_fetch in the Anthropic-compatible API in all regions: Singapore, China North 2 (Beijing), Germany (Frankfurt), China (Hong Kong), Japan (Tokyo), and US (Virginia).kimi-k3.1-pro (deployed on QwenCloud) supports the built-in web_extractor tool in the Responses API and web_fetch in the Anthropic-compatible API in all regions: Singapore, China North 2 (Beijing), Germany (Frankfurt), China (Hong Kong), Japan (Tokyo), and US (Virginia).
When extraction fails, the model does not raise an error. Instead, the web_extractor_call item in the response output returns empty or partial content, and the model generates its response based on whatever context is available.Common failure scenarios:
Scenario
Behavior
URL is unreachable (404, 500, DNS failure)
Extraction returns empty content; model responds using other available context
Page load times out
Partial or empty content returned
Non-HTML content (PDF, images)
Content may not be extracted; model falls back to other tools or general knowledge
To verify whether extraction succeeded, inspect the web_extractor_call items in response.output or check usage.x_tools.web_extractor.count for the number of successful invocations.
The prices listed below are list prices. For current promotions and discounted pricing, visit the Model Marketplace.
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 Pricing for pricing.
Web search fee
Per 1,000 search invocations: $10.00 in Singapore, $0.573411 in China North 2 (Beijing), Germany (Frankfurt), China (Hong Kong), Japan (Tokyo), and US (Virginia). Web extractor typically triggers web search internally.
Web extractor fee
Free for a limited time.
For qwen4-max Responses, read tool counts from the top-level tool_usage: web_search.num_requests is the billed search count, web_extractor.num_requests is the billed extraction count, and pdf_page_parser.num_requests is the parsed page count. For streaming, read these fields from response.completed.response.tool_usage. Output item counts do not determine these counts. Legacy counters apply only to models that still return them.