Call web extractor through the Responses API to summarize a web page. The examples below use web_search and web_extractor with qwen3-max-2026-01-23 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"), base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1")response = client.responses.create( model="qwen3-max-2026-01-23", input="Please visit the official Qwen Cloud 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 = response.usageprint("=" * 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)}")
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, baseURL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"});async function main() { const response = await openai.responses.create({ model: "qwen3-max-2026-01-23", input: "Please visit the official Qwen Cloud 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.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();
Copy
curl -X POST https://dashscope-intl.aliyuncs.com/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 Qwen Cloud 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
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_summary_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 = 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)}")
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.