# 如何在 Hermes Agent 里使用 Unlid

把 Hermes Agent 接到 Unlid：创建一个 API key，把 Hermes Agent 指向下面的 base URL，再选一个模型 id。所有 Unlid 模型都用同样的设置。

## 在你的应用中使用 Unlid

任何允许添加 **OpenAI-compatible** 提供商的应用都能使用 Unlid 的所有模型。你始终只需要这三样：

|  |  |
| --- | --- |
| Base URL | `https://api.unlid.ai/v1` |
| API key | 在 [账户 → API keys](https://unlid.ai/account/keys) 中创建。以 `ul-` 开头，只显示一次。 |
| 模型 | [模型](https://unlid.ai/models.md?lang=zh) 页面中的 id，例如 `glm-5.3-flash-uncensored`。大多数应用会自动拉取模型列表。 |

下面三条规则能解决几乎所有配置问题：

- Base URL **要带** `/v1`，**不要带** `/chat/completions`，应用会自己加上。（Janitor AI 和 goose 例外，见下文。）
- 应用让你选 API 类型时，选 **OpenAI Compatible / Chat Completions**。这是 Unlid 的原生协议。Anthropic（`/v1/messages`）和 OpenAI Responses（`/v1/responses`）端点是为只支持这两种协议的 [Claude Code](https://unlid.ai/docs/clients/claude-code.md?lang=zh) 和 [Codex](https://unlid.ai/docs/clients/codex-cli.md?lang=zh) 准备的；它们会被转换成 Chat Completions，支持的功能更少。
- 如果应用有 **上下文窗口** 设置，按模型页面填写（glm-5.3-flash-uncensored：262,144 token）。默认值太小会截断长对话；太大则会报 `context_length_exceeded`。

不确定 key 能不能用？先在同一台电脑上运行下面的命令，这是区分应用问题和网络问题最快的办法：

```
curl https://api.unlid.ai/v1/models -H "Authorization: Bearer ul-…"
```

## Hermes Agent

运行 `hermes model` → **Custom endpoint**，输入 `https://api.unlid.ai/v1`、你的 key 和 `glm-5.3-flash-uncensored`。或者编辑 `~/.hermes/config.yaml`，并把 `UNLID_API_KEY=ul-…` 写进 `~/.hermes/.env`：

```
model:
  default: glm-5.3-flash-uncensored
  provider: custom
  base_url: https://api.unlid.ai/v1
  key_env: UNLID_API_KEY
  context_length: 262144
```

Hermes 使用工具至少需要 64,000 token 的上下文，请选择上下文窗口足够大的模型。

遇到问题？看 [故障排查](https://unlid.ai/docs/clients.md?lang=zh#troubleshooting)，或 [配置其他应用](https://unlid.ai/docs/clients.md?lang=zh)。
