> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/integrations/cn/ai-studio-integrations/hermes-agent.md).

# Hermes 代理

Oxylabs AI Studio 可让您的 Hermes Agent 获取实时网页搜索和清洗后的、可供 LLM 直接使用的数据，以便将实时上下文和结构化页面内容作为其推理工作流的一部分。

[**Hermes 代理**](https://github.com/NousResearch/hermes-agent) 是一个可插拔的代理框架，通过可替换的后端集成网页搜索和提取。该 `hermes-web-oxylabs` 插件注册 [**Oxylabs AI Studio**](https://aistudio.oxylabs.io/) 作为可用后端之一，直接调用 AI Studio 的 REST API（无需厂商 SDK）为代理提供：

* 排序后的网页搜索结果——标题、URL、描述
* 可供研究、比较和后续推理的干净页面数据，格式为 Markdown
* 更新鲜的网页上下文，以获得更准确的答案

## 要求

* [Hermes 代理](https://github.com/NousResearch/hermes-agent) 已安装并带有 `hermes` CLI
* Oxylabs AI Studio [API 密钥](https://aistudio.oxylabs.io/api-key) （AI Studio 使用单一 API 密钥，没有单独的用户名/密码）

## 设置

{% stepper %}
{% step %}

### 安装插件

将 Oxylabs 注册为 Hermes 可用于搜索和提取的网页提供方：

```bash
hermes plugins install oxylabs/hermes-web-oxylabs --enable
```

{% endstep %}

{% step %}

### 设置你的 API 密钥

```bash
export OXYLABS_API_KEY="your-api-key-here"
```

或者将其添加到 Hermes `.env` file 而不是你的 shell 配置中：

```bash
# ~/.hermes/.env
OXYLABS_API_KEY=your-api-key-here
```

{% endstep %}

{% step %}

### 选择实现

将 Oxylabs 设置为以下项的后端： **搜索**, **提取**，或 **两者**.

#### **网页搜索**

```bash
hermes config set web.search_backend oxylabs
```

对于请求 10 条或更少结果的查询，插件会调用 AI Studio 的 `/search/instant` 端点并内联返回结果。对于更大的结果集，它会提交到 `/search/run` 并轮询直到完成。

{% hint style="info" %}
**搜索** 仅返回列表（标题、URL、描述），页面内容会通过 [提取](#web-extraction).
{% endhint %}

#### **网页提取**

```bash
hermes config set web.extract_backend oxylabs
```

每个 URL 都会提交到 AI Studio 的 `/scrape` 端点并轮询直到完成（每个 URL 最多 60 秒）。

一批 URL 会并发处理，某个 URL 失败不会阻塞整个批次，并会返回一个 `错误` 字段而不是内容。

#### 搜索 + 提取（完整后端）

如果你希望 Oxylabs 同时处理 **搜索** 并 **提取**，则设置共享的 `后端` 键，而不是上面的两个：

```yaml
web:
  backend: "oxylabs"
```

{% endstep %}

{% step %}

### 重启 Hermes

后端和 API 密钥的更改只会在会话开始时读取。请启动新会话或重启当前会话：

```bash
hermes restart
```

{% endstep %}

{% step %}

### 验证

运行一个需要当前网页上下文的任务（例如，读取特定 URL 的请求）。如果响应包含搜索结果或页面内容，则集成成功。

如果 `未配置 OXYLABS_API_KEY` 并返回错误，则说明未获取到该密钥。返回到 [步骤 2](#set-your-api-key)，然后再次重启。

{% hint style="info" %}
一旦选择 Oxylabs 作为 `后端`，缺少密钥时只会返回错误，而不会回退到其他提供方。
{% endhint %}
{% endstep %}
{% endstepper %}

### 覆盖端点（可选）

Hermes `web_extract` 工具支持通过以下方式覆盖 API 基础 URL：

```bash
export OXYLABS_API_URL="https://your-custom-endpoint"
```

用于测试或自托管部署。默认值： `https://api-aistudio.oxylabs.io`.

{% hint style="info" %}
Oxylabs AI Studio 支持更高级的功能（`format`, `render_javascript`, `geo_location`）目前通过 Hermes 分发器不支持，后续可能可用。
{% endhint %}

## 更多资源

请参阅我们的 [GitHub 仓库](https://github.com/oxylabs/hermes-web-oxylabs) 以查看完整代码参考。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/integrations/cn/ai-studio-integrations/hermes-agent.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
