> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 網頁搜尋工具

> 為模型提供即時網頁搜尋能力。ARouter 執行搜尋並注入帶引用的結構化結果——無需客戶端程式碼。

`web_search` Server Tool 使模型能夠在推理過程中搜尋網頁。模型決定何時需要搜尋，ARouter 執行搜尋，結果會自動注入回模型的上下文中。

<Note>
  這是已棄用的 `web` 外掛程式和 `:online` 模型後綴的推薦替代方案。
</Note>

## 快速開始

```json theme={null}
{
  "model": "openai/gpt-5.4",
  "messages": [{"role": "user", "content": "What happened in AI research this week?"}],
  "tools": [{"type": "arouter", "arouter": {"id": "web_search"}}]
}
```

## 設定

| 參數                  | 類型         | 預設值 | 描述                                                   |
| ------------------- | ---------- | --- | ---------------------------------------------------- |
| `id`                | `string`   | —   | 必須為 `"web_search"`                                   |
| `max_results`       | `integer`  | `5` | 回傳的最大搜尋結果數量                                          |
| `engine`            | `string`   | 自動  | 搜尋引擎：`"native"`、`"exa"`、`"parallel"` 或 `"firecrawl"` |
| `include_domains`   | `string[]` | —   | 將結果限制在這些網域（支援萬用字元）                                   |
| `exclude_domains`   | `string[]` | —   | 排除這些網域的結果（支援萬用字元）                                    |
| `max_total_results` | `integer`  | —   | 限制一次請求中多次搜尋的總結果數                                     |

## 引擎選擇

| 引擎            | 描述                            | 適用場景    |
| ------------- | ----------------------------- | ------- |
| （未設定）         | 如果提供商支援則使用 native，否則使用 Exa    | 通用      |
| `"native"`    | 提供商內建搜尋（OpenAI、Anthropic、xAI） | 最佳引用品質  |
| `"exa"`       | Exa 的神經網路+關鍵字混合搜尋             | 研究、小眾話題 |
| `"parallel"`  | Parallel 的搜尋 API              | 快速廣泛查詢  |
| `"firecrawl"` | Firecrawl 深度爬取（BYOK）          | 完整頁面內容  |

## 解析引用

```json theme={null}
{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "According to recent research...",
      "annotations": [{
        "type": "url_citation",
        "url_citation": {
          "url": "https://arxiv.org/abs/2501.12345",
          "title": "Scaling Laws for LLMs",
          "content": "We study the relationship between...",
          "start_index": 32, "end_index": 96
        }
      }]
    }
  }]
}
```

## 定價

| 引擎                           | 費用                           |
| ---------------------------- | ---------------------------- |
| Exa                          | 每 1,000 條結果 \$4.00           |
| Parallel                     | 每 1,000 條結果 \$4.00           |
| Native（OpenAI、Anthropic、xAI） | 按提供商費率直通                     |
| Firecrawl                    | BYOK——使用你的 Firecrawl API key |

## 從 Web 外掛程式遷移

**之前（已棄用）：**

```json theme={null}
{"model": "openai/gpt-5.4:online", "messages": [...]}
```

**之後（推薦）：**

```json theme={null}
{"model": "openai/gpt-5.4", "tools": [{"type": "arouter", "arouter": {"id": "web_search"}}], "messages": [...]}
```
