> ## 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.

# 伺服器工具

> 為模型提供即時能力，如網頁搜尋和日期時間。Server Tools 由 ARouter 代表模型執行，無需任何客戶端邏輯。

Server Tools 是 ARouter 在推理過程中代表模型執行的能力。與使用者自訂的函式呼叫（由你的程式碼執行函式）不同，Server Tools 完全由 ARouter 處理——模型決定何時呼叫，ARouter 執行它們，結果會自動注入回對話中。

<Note>
  Server Tools 目前處於 **beta** 階段。介面已穩定，但仍在持續新增更多工具。
</Note>

## 可用的 Server Tools

| 工具 ID        | 描述               | 定價      |
| ------------ | ---------------- | ------- |
| `web_search` | 搜尋網頁並回傳帶引用的結構化結果 | 按搜尋次數計費 |
| `datetime`   | 回傳任意時區的當前日期和時間   | 免費      |

## Server Tools vs Plugins vs 使用者自訂工具

|         | Server Tools | Plugins    | 使用者自訂工具 |
| ------- | ------------ | ---------- | ------- |
| 誰來執行？   | ARouter      | ARouter    | 你的應用程式  |
| 模型控制呼叫？ | 是            | 否（每次請求都套用） | 是       |
| 結構化引用？  | 是            | 是（僅網頁）     | 不適用     |
| 支援串流傳輸？ | 是            | 是          | 是       |

## 快速開始

```json theme={null}
{
  "model": "openai/gpt-5.4",
  "messages": [{"role": "user", "content": "What are the top AI news stories today?"}],
  "tools": [{"type": "arouter", "arouter": {"id": "web_search"}}]
}
```

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const response = await client.chat.completions.create({
      model: "openai/gpt-5.4",
      messages: [{ role: "user", content: "What are the top AI news stories today?" }],
      tools: [{ type: "arouter", arouter: { id: "web_search" } } as any],
    });
    console.log(response.choices[0].message.content);
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    response = client.chat.completions.create(
        model="openai/gpt-5.4",
        messages=[{"role": "user", "content": "What are the top AI news stories today?"}],
        tools=[{"type": "arouter", "arouter": {"id": "web_search"}}],
    )
    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.arouter.ai/v1/chat/completions \
      -H "Authorization: Bearer lr_live_xxxx" \
      -H "Content-Type: application/json" \
      -d '{"model": "openai/gpt-5.4", "messages": [{"role": "user", "content": "Top AI news today?"}], "tools": [{"type": "arouter", "arouter": {"id": "web_search"}}]}'
    ```
  </Tab>
</Tabs>

## 用量追蹤

```json theme={null}
{
  "usage": {
    "prompt_tokens": 450, "completion_tokens": 210, "total_tokens": 660, "cost": 0.00234,
    "server_tool_calls": {"web_search": 2}
  }
}
```

## 下一步

* [網頁搜尋工具](/zh-Hant/guides/features/server-tools/web-search)
* [日期時間工具](/zh-Hant/guides/features/server-tools/datetime)
