> ## 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/guides/features/server-tools/web-search)
* [日期时间工具](/zh/guides/features/server-tools/datetime)
