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

# 网页搜索

## 功能说明

对应工具标识 `web_search`。

`web_search` 让智能体通过融合信息搜索 API 进行全网搜索。详见[融合信息搜索 API 文档](https://www.volcengine.com/docs/85508/1650263)。

导入路径：`from veadk.tools.builtin_tools.web_search import web_search`

## 环境变量与前提

<Warning>
  附加要求：

  1. 配置火山引擎 AK / SK，或使用火山引擎 IAM 授权的临时 StsToken；
  2. 配置用于智能体推理模型的 API Key。
</Warning>

环境变量：

* `MODEL_AGENT_API_KEY`：智能体推理模型的 API Key
* `VOLCENGINE_ACCESS_KEY`：火山引擎 AccessKey
* `VOLCENGINE_SECRET_KEY`：火山引擎 SecretKey

或在 `config.yaml` 中配置：

```yaml title="config.yaml" lines theme={null}
model:
  agent:
    provider: openai
    name: doubao-seed-1-8-251228
    api_base: https://ark.cn-beijing.volces.com/api/v3/
    api_key: your-api-key-here
volcengine:
  # 供 Viking DB 与 web_search 等工具使用
  access_key: your-access-key-here
  secret_key: your-secret-key-here
```

## 使用方法

```python title="examples/tools/web_search/agent.py" lines theme={null}
import asyncio

from veadk import Agent, Runner
from veadk.memory.short_term_memory import ShortTermMemory
from veadk.tools.builtin_tools.web_search import web_search

agent = Agent(
    name="web_search_agent",
    model_name="doubao-seed-1-8-251228",
    description="An agent that answers questions with web search.",
    instruction="You are a helpful assistant. Use the web_search tool when you need fresh information.",
    tools=[web_search],
)

runner = Runner(agent=agent, short_term_memory=ShortTermMemory())


async def main():
    response = await runner.run("杭州今天的天气怎么样？")
    print(response)


if __name__ == "__main__":
    asyncio.run(main())
```
