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

# 火山引擎搜索

## 功能说明

对应工具标识 `vesearch`。

`vesearch` 通过火山引擎的[联网问答 Agent](https://www.volcengine.com/docs/85508/1512748) 进行搜索。该工具从环境变量读取自己的凭证，无需在 `Agent` 上传入 `api_key`。

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

## 环境变量与前提

<Warning>
  附加要求：

  1. 配置用于智能体推理模型的 API Key；
  2. 配置联网问答 Agent 的智能体 ID（在[控制台](https://console.volcengine.com/ask-echo/my-agent)创建智能体后获取），写入环境变量 `TOOL_VESEARCH_ENDPOINT`；
  3. 配置联网问答 Agent 的 API Key，写入环境变量 `TOOL_VESEARCH_API_KEY`。
</Warning>

环境变量：

* `MODEL_AGENT_API_KEY`：智能体推理模型的 API Key
* `TOOL_VESEARCH_ENDPOINT`：联网问答 Agent 的智能体 ID（**必须配置在环境变量中**）
* `TOOL_VESEARCH_API_KEY`：联网问答 Agent 的 API Key

## 使用方法

```python title="examples/tools/vesearch/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.vesearch import vesearch

agent = Agent(
    name="vesearch_agent",
    model_name="doubao-seed-2-1-pro-260628",
    description="An agent that answers questions with veSearch.",
    instruction="You are a helpful assistant. Use the vesearch tool to look things up online.",
    tools=[vesearch],
)

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


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


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

## 参数与结果验证

| 参数 | 类型 | 默认值 | 说明 |
| :- | :- | :- | :- |
| `query` | `str` | 必填 | 联网问答的查询文本 |

`TOOL_VESEARCH_ENDPOINT` 填写已创建的智能体 ID，不是 HTTP URL。工具调用联网问答服务并返回文本摘要；失败时也可能返回错误文本，因此不能仅以返回类型判断成功。请求超时为 30 秒，`CLOUD_PROVIDER=byteplus` 不会自动更换此服务

```python lines theme={null}
from veadk.tools.builtin_tools.vesearch import vesearch

answer = vesearch("What is AgentKit?")
print(answer)
```

该调用只需联网问答服务的配置，不调用外层推理模型；通过 `Runner` 使用时才需要额外配置智能体模型
