Skip to main content
Chamada de ferramentas

Web extractor

Os LLMs não acessam dados de páginas da web diretamente. O web extractor acessa uma URL e extrai seu conteúdo para o modelo.

Uso

Existem três formas de chamar o web extractor. Os parâmetros obrigatórios variam conforme o método:
  • OpenAI-compatible - Responses API
  • OpenAI-compatible - Chat Completions API
  • DashScope
Adicione web_search e web_extractor ao parâmetro tools.
Ao usar qwen3-max-2026-01-23 , defina enable_thinking como true .
Para maior precisão em problemas matemáticos ou de análise de dados, ative também a ferramenta 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)

Modelos suportados

Modelos recomendados

  • Responses API
  • Chat Completions API / DashScope
Qwen-Max: série Qwen3,8-Max, série Qwen3,7-MaxQwen-Plus: série Qwen3,7-Plus, série Qwen3,6-Plus, série Qwen3,5-PlusDeepSeek: deepseek-v4-flash, deepseek-v4-flash-0731, deepseek-v4-proGLM: glm-5.2Série open-source Qwen3,8

Outros modelos

Os modelos abaixo também suportam esta ferramenta, mas podem não ter o mesmo desempenho dos modelos recomendados. O suporte está disponível apenas pela Responses API.
  • Qwen-Flash: série Qwen3,7-Flash, série Qwen3,6-Flash, série Qwen3,5-Flash
  • Série open-source Qwen3,6 (exceto qwen3.6-27b)
  • Série open-source Qwen3,5

Primeiros passos

Este exemplo chama o web extractor pela Responses API para resumir um documento técnico.
É necessário get an API key e configure it as an environment variable .
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)}")
Exemplo de saída:
====================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/en/model-studio/qwen-code-interpreter) and [Assistant API Code Interpreter](https://www.alibabacloud.com/help/en/model-studio/code-interpreter) (Updated: December 2025)
====================Tool Call Count====================

Web extraction count: 1

Saída com streaming

A extração da web pode ser demorada. Ative a saída com streaming para receber resultados intermediários em tempo real.
Use a Responses API para obter o status intermediário da execução das ferramentas.
  • OpenAI-compatible - Responses API
  • OpenAI-compatible - Chat Completions API
  • DashScope
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_summary_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)}")

Faturamento

O faturamento inclui:
  • Taxas de chamada do modelo: o conteúdo extraído da página da web é adicionado ao prompt, aumentando a contagem de tokens de entrada. Esses tokens são cobrados à tarifa padrão do modelo. Para detalhes de preços, consulte o console do Model Studio.
  • Taxas de chamada de ferramentas: incluem extração da web e busca na web.
    • Tarifa de busca na web por 1.000 chamadas:
      • Região China (Beijing): $0.57341.
      • Região Singapore: $10,00.
    • O web extractor é gratuito por tempo limitado.
Plano de Tokens
Playground de Modelos
Inferência do Modelo
Avaliação
Compressão de Modelos
Estatísticas e Monitoramento
Suporte