Todos los productos
Search
Centro de documentos

Alibaba Cloud Model Studio:Extractor web

Última actualización: Oct 19, 2026

Los LLM no pueden acceder directamente a los datos de páginas web. El extractor web accede a una URL y extrae su contenido para el modelo.

Uso

El extractor web se puede invocar de cuatro maneras. Los parámetros requeridos difieren para cada método:

Compatible con OpenAI - Responses API

Agregue web_search y web_extractor al parámetro tools.

Para obtener una mayor precisión en problemas matemáticos o de análisis de datos, habilite también la herramienta code_interpreter.

# Import dependencies and create a client...
response = client.responses.create(
    model="qwen3.8-max",
    input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    tools=[
        # To enable web extraction, also enable the web search tool
        {"type": "web_search"},
        {"type": "web_extractor"},
        {"type": "code_interpreter"}
    ],
    extra_body={
      # Thinking mode must be enabled
      "enable_thinking": True
    }
)

print(response.output_text)

Compatible con OpenAI - Chat Completions API

Establezca enable_search en true y search_strategy en agent_max. También establezca enable_thinking en true.

No se admite la salida sin transmisión.

# Import dependencies and create a client...
completion = client.chat.completions.create(
    model="qwen3.8-max",
    messages=[{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content"}],
    extra_body={
        "enable_thinking": True,
        "enable_search": True,
        "search_options": {"search_strategy": "agent_max"}
    },
    stream=True
)

DashScope

Establezca enable_search en true y search_strategy en agent_max. También establezca enable_thinking en true.

No se admite la salida sin transmisión.

from dashscope import Generation

response = Generation.call(
    model="qwen3.8-max",
    messages=[{"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content"}],
    enable_search=True,
    search_options={"search_strategy": "agent_max"},
    enable_thinking=True,
    result_format="message",
    stream=True,
    incremental_output=True
)

Compatible con Anthropic

Agregue la herramienta de obtención web del lado del servidor de Anthropic (name establecido en web_fetch) al parámetro tools para habilitar el extractor web. También debe agregar la herramienta de búsqueda web (name establecido en web_search) en la misma solicitud. El endpoint es https://{WorkspaceId}.{region}.maas.aliyuncs.com/apps/anthropic.

Este método está dirigido a clientes oficiales de Anthropic, como Claude Code. En esos clientes, una pregunta simple en lenguaje natural activa el extractor web sin necesidad de configuración adicional.

Cuando llama a la API directamente con el SDK de Anthropic o a través de HTTP, pase el identificador de cliente x-anthropic-billing-header: cc_entrypoint=cli; en system. De lo contrario, el extractor web no surtirá efecto.

Acerca de la versión de la herramienta: El sufijo de fecha en type (por ejemplo, web_fetch_20250910 y web_search_20250305) está determinado por la versión del cliente oficial de Anthropic, y un cliente más reciente puede enviar una versión con fecha diferente. Model Studio identifica ambas herramientas por su categoría y no valida el sufijo de fecha, por lo que no necesita fijar type a una versión específica. Simplemente pase el valor que su cliente envía realmente.

Si agrega la herramienta de obtención web sin la herramienta de búsqueda web, la solicitud fallará con el error InvalidParameter: The web_extractor tool must be executed with web_search tool.

Modelos compatibles: series Max, Flash y de código abierto de Qwen3.8 (excluyendo Omni); series Max, Plus y Flash de Qwen3.7; series Qwen3.6-Plus y Qwen3.6-Flash; series Qwen3.5-Plus y Qwen3.5-Flash; deepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash-0731, deepseek-v4.1-flash-1017; glm-5.2; kimi-k3.

# Import dependencies and create the client...
message = client.messages.create(
    model="qwen3.8-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 Alibaba Cloud Model Studio 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}
    ]
)

El proceso de extracción se devuelve como bloques de contenido server_tool_use (solicitud de obtención) y web_fetch_tool_result (resultados de obtención). El número de obtenciones se reporta en usage.server_tool_use.web_fetch_requests.

Modelos admitidos

deepseek-v4.1-flash-1017 admite la herramienta integrada web_extractor en la Responses API y web_fetch en la API compatible con Anthropic en las seis regiones y los alcances de implementación correspondientes indicados en la página del modelo.

Modelos recomendados

API de respuestas

Qwen-Max: serie Qwen3.8-Max, serie Qwen3.7-Max

Qwen-Plus: serie Qwen3.7-Plus, serie Qwen3.6-Plus, serie Qwen3.5-Plus

DeepSeek: deepseek-v4-flash-0731, deepseek-v4-pro

GLM: glm-5.2

Serie de código abierto Qwen3.8

Chat Completions API / DashScope

  • Qwen-Max (modo de pensamiento): serie Qwen3-Max
  • Qwen-Plus: serie Qwen3.5-Plus

Otros modelos

Los siguientes modelos también admiten esta herramienta, pero es posible que no tengan un rendimiento tan bueno como los modelos recomendados. Solo se admite a través de la Responses API.

  • Qwen-Flash: serie Qwen3.7-Flash, serie Qwen3.6-Flash, serie Qwen3.5-Flash
  • Serie de código abierto Qwen3.6 (excepto qwen3.6-27b)
  • Serie de código abierto Qwen3.5

Introducción

Este ejemplo invoca el extractor web a través de la Responses API para resumir un documento técnico.

Debe obtener una clave de API y configurarla como variable de entorno.

import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the next line with api_key="sk-xxx", using your Model Studio API key.
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)

response = client.responses.create(
    model="qwen3.8-max",
    input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    tools=[
        {
            "type": "web_search"
        },
        {
            "type": "web_extractor"
        },
        {
            "type": "code_interpreter"
        }
    ],
    extra_body = {
        "enable_thinking": True
    }
)
# Uncomment the following line to view intermediate process outputs
# print(response.output)
print("="*20+"Response Content"+"="*20)
print(response.output_text)
# Print the number of tool calls
usage = response.usage
print("="*20+"Tool Call Count"+"="*20)
if hasattr(usage, 'x_tools') and usage.x_tools:
    print(f"\nWeb extraction count: {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 the next line with apiKey: "sk-xxx", using your Model Studio API key.
    apiKey: process.env.DASHSCOPE_API_KEY,
    // Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.responses.create({
        model: "qwen3.8-max",
        input: "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
        tools: [
            { type: "web_search" },
            { type: "web_extractor" },
            { type: "code_interpreter" }
        ],
        enable_thinking: true
    });

    console.log("====================Response Content====================");
    console.log(response.output_text);

    // Print the number of tool calls
    console.log("====================Tool Call Count====================");
    if (response.usage && response.usage.x_tools) {
        console.log(`Web extraction count: ${response.usage.x_tools.web_extractor?.count || 0}`);
        console.log(`Web search count: ${response.usage.x_tools.web_search?.count || 0}`);
    }
    // Uncomment the following line to view intermediate process outputs
    // console.log(JSON.stringify(response.output[0], null, 2));
}

main();
# Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
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.8-max",
    "input": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    "tools": [
        {"type": "web_search"},
        {"type": "web_extractor"},
        {"type": "code_interpreter"}
    ],
    "enable_thinking": true
}'

Salida de ejemplo:

====================Response Content====================
Based on the official Alibaba Cloud Model Studio documentation, I have summarized the core content of the **code interpreter** feature for you:

## 1. Feature Positioning

...

> **Document Source**: Alibaba Cloud Model Studio official documentation - [Qwen Code Interpreter](https://www.alibabacloud.com/help/model-studio/qwen-code-interpreter) and [Assistant API Code Interpreter](https://www.alibabacloud.com/help/model-studio/code-interpreter) (Updated: December 2025)
====================Tool Call Count====================

Web extraction count: 1

Salida por secuencias

La extracción web puede llevar mucho tiempo. Habilite la salida de transmisión para recibir resultados intermedios en tiempo real.

Utilice la Responses API para recuperar el estado de ejecución intermedio de la herramienta.

Compatible con OpenAI - Responses API

import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the next line with api_key="sk-xxx" (not recommended), using your Model Studio API key.
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)

stream = client.responses.create(
    model="qwen3.8-max",
    input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its 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:
    # Print the thinking process
    if chunk.type == 'response.reasoning_text.delta':
        if not reasoning_started:
            print("="*20 + "Thinking Process" + "="*20)
            reasoning_started = True
        print(chunk.delta, end='', flush=True)
    # Print when tool call is complete
    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 Call" + "="*20)
                print(chunk.item.goal)
                print(chunk.item.output)
            elif chunk.item.type == 'reasoning':
                reasoning_started = False
    # Print the response content
    elif chunk.type == 'response.output_text.delta':
        if not output_started:
            print("\n" + "="*20 + "Response Content" + "="*20)
            output_started = True
        print(chunk.delta, end='', flush=True)
    # When the response is complete, print the number of tool calls
    elif chunk.type == 'response.completed':
        print("\n" + "="*20 + "Tool Call Count" + "="*20)
        usage = chunk.response.usage
        if hasattr(usage, 'x_tools') and usage.x_tools:
            print(f"Web extraction count: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")
            print(f"Web search count: {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 the next line with apiKey: "sk-xxx", using your Model Studio API key.
    apiKey: process.env.DASHSCOPE_API_KEY,
    // Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const stream = await openai.responses.create({
        model: "qwen3.8-max",
        input: "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its 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) {
        // Print the thinking process
        if (chunk.type === 'response.reasoning_text.delta') {
            if (!reasoningStarted) {
                console.log("====================Thinking Process====================");
                reasoningStarted = true;
            }
            process.stdout.write(chunk.delta);
        }
        // Print when tool call is complete
        else if (chunk.type === 'response.output_item.done') {
            if (chunk.item && chunk.item.type === 'web_extractor_call') {
                console.log("\n" + "====================Tool Call====================");
                console.log(chunk.item.goal);
                console.log(chunk.item.output);
            } else if (chunk.item && chunk.item.type === 'reasoning') {
                reasoningStarted = false;
            }
        }
        // Print the response content
        else if (chunk.type === 'response.output_text.delta') {
            if (!outputStarted) {
                console.log("\n" + "====================Response Content====================");
                outputStarted = true;
            }
            process.stdout.write(chunk.delta);
        }
        // When the response is complete, print the number of tool calls
        else if (chunk.type === 'response.completed') {
            console.log("\n" + "====================Tool Call Count====================");
            const usage = chunk.response.usage;
            if (usage && usage.x_tools) {
                console.log(`Web extraction count: ${usage.x_tools.web_extractor?.count || 0}`);
                console.log(`Web search count: ${usage.x_tools.web_search?.count || 0}`);
            }
        }
    }
}

main();
# Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
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.8-max",
    "input": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    "tools": [
        {"type": "web_search"},
        {"type": "web_extractor"},
        {"type": "code_interpreter"}
    ],
    "enable_thinking": true,
    "stream": true
}'

Compatible con OpenAI - Chat Completions API

import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the next line with api_key="sk-xxx" (not recommended), using your Model Studio API key.
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)

stream = client.chat.completions.create(
    model="qwen3.8-max",
    messages=[
        {"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content"}
    ],
    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
        # Print the thinking process
        if hasattr(delta, 'reasoning_content') and delta.reasoning_content:
            if not reasoning_started:
                print("="*20 + "Thinking Process" + "="*20)
                reasoning_started = True
            print(delta.reasoning_content, end='', flush=True)
        # Print the response content
        if delta.content:
            if not output_started:
                print("\n" + "="*20 + "Response Content" + "="*20)
                output_started = True
            print(delta.content, end='', flush=True)
import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    // If the environment variable is not configured, replace the next line with apiKey: "sk-xxx", using your Model Studio API key.
    apiKey: process.env.DASHSCOPE_API_KEY,
    // Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const stream = await openai.chat.completions.create({
        model: "qwen-max",
        messages: [
            { role: "user", content: "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content" }
        ],
        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;
            // Print the thinking process
            if (delta.reasoning_content) {
                if (!reasoningStarted) {
                    console.log("====================Thinking Process====================");
                    reasoningStarted = true;
                }
                process.stdout.write(delta.reasoning_content);
            }
            // Print the response content
            if (delta.content) {
                if (!outputStarted) {
                    console.log("\n" + "====================Response Content====================");
                    outputStarted = true;
                }
                process.stdout.write(delta.content);
            }
        }
    }
}

main();
# Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
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": "qwen-max",
    "messages": [
        {"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content"}
    ],
    "enable_thinking": true,
    "enable_search": true,
    "search_options": {"search_strategy": "agent_max"},
    "stream": true
}'

DashScope

El SDK de Java no es compatible.

import os
import dashscope
from dashscope import Generation

# If the environment variable is not configured, replace the next line with dashscope.api_key = "sk-xxx", using your Model Studio API key.
dashscope.api_key = os.getenv("DASHSCOPE_API_KEY")
# Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
dashscope.base_http_api_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"

response = Generation.call(
    model="qwen3.8-max",
    messages=[
        {"role": "user", "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its 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

for chunk in response:
    if chunk.status_code == 200:
        message = chunk.output.choices[0].message

        # Print the thinking process
        if hasattr(message, 'reasoning_content') and message.reasoning_content:
            if not reasoning_started:
                print("="*20 + "Thinking Process" + "="*20)
                reasoning_started = True
            print(message.reasoning_content, end='', flush=True)

        # Print the response content
        if hasattr(message, 'content') and message.content:
            if not output_started:
                print("\n" + "="*20 + "Response Content" + "="*20)
                output_started = True
            print(message.content, end='', flush=True)
    else:
        print(f"\nRequest failed: code={chunk.code}, message={chunk.message}")
        break
# Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
curl -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": "qwen-max",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": "Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content"
            }
        ]
    },
    "parameters": {
        "enable_thinking": true,
        "enable_search": true,
        "search_options": {
            "search_strategy": "agent_max"
        },
        "result_format": "message"
    }
}'

Facturación

La facturación incluye:

  • Tarifas de llamada del modelo: El contenido extraído de la página web se agrega al prompt, lo que aumenta el recuento de tokens de entrada. Estos tokens se facturan a la tarifa estándar del modelo. Para obtener detalles sobre los precios, consulte la consola de Model Studio.

  • Tarifas de llamada de herramientas: Incluye extracción web y búsqueda web.

    • Tarifas de búsqueda web por 1,000 llamadas:

      • Regiones de China (Pekín), EE. UU. (Virginia), China (Hong Kong), Japón (Tokio) y Alemania (Fráncfort): $0.57341.
      • Región de Singapur: $10.00.
    • El extractor web es gratuito por tiempo limitado.