Hermes Agent ACP 协议 HTTP API — 通过 RESTful 接口实现对 Agent 能力的程序化访问。使用 API 密钥进行身份验证,可集成到任意工作流中。
所有 API 请求均需通过 API 密钥进行身份验证。请将密钥包含在请求头中:
Authorization: Bearer your_api_key_here
备选请求头格式:
X-API-Key: abk_xxxxxxxxxxxx
API 密钥 请在 WebUI → 设置中创建您的 API 密钥
工具调用使 Agent 能够与外部系统进行交互。工具通过注册表模式自动发现,并可在对话过程中被调用。
在主机系统上执行 Shell 命令,适用于系统管理任务。
读取、写入和管理文件,支持带安全验证的路径操作。
网络搜索和内容获取,提供强大的搜索与研究能力。
Python 代码解释器,用于动态计算和数据分析。
{
"name": "web_search",
"description": "Search the web for information",
"parameters": {
"query": {
"type": "string",
"description": "Search query"
}
}
}
会话用于跟踪对话历史,支持自动压缩和智能截断。每个用户拥有独立的会话上下文。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
username |
string | * | 用于会话作用域的用户标识符 |
session_id |
string (UUID) | 指定要继续的会话 ID,如省略则自动生成 | |
message |
string | * | 要发送的消息内容 |
stream |
boolean | 启用 SSE 流式响应(默认值:true) |
# 创建一个新的聊天会话
curl -X POST 'http://localhost:6185/api/v1/chat/new_session' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{"username": "alice", "session_id": "optional-existing-id"}'
配置多个 LLM 后端。Hermes Agent 通过统一的 Provider 接口支持 OpenAI、Anthropic、Gemini、MiniMax、GLM、Ollama 等多种模型。
{
"providers": [
{
"name": "openai",
"provider": "OpenAI",
"model": "gpt-4o",
"api_key": "sk-...",
"base_url": "https://api.openai.com/v1"
},
{
"name": "claude",
"provider": "Anthropic",
"model": "claude-sonnet-4-20250514",
"api_key": "sk-ant-..."
}
]
}
OpenAI、SiliconFlow、302.AI、NewAPI 及任何 OpenAI 兼容 API。
通过 Anthropic API 调用 Claude 模型,支持工具调用。
通过 Google AI 使用 Gemini Pro 和 Ultra 模型。
使用 Ollama、LM Studio 进行自托管模型推理。
import requests
import json
# 发送聊天消息并获取流式响应
url = "http://localhost:6185/api/v1/chat"
headers = {
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
}
payload = {
"message": "Hello, list my files in /tmp",
"username": "alice"
}
response = requests.post(url, headers=headers, json=payload, stream=True)
for line in response.iter_lines():
if line:
print(line.decode('utf-8'))
# 获取用户会话列表
curl -X GET 'http://localhost:6185/api/v1/chat/sessions?username=alice' \
-H 'Authorization: Bearer your_api_key'
# 发送聊天消息
curl -N 'http://localhost:6185/api/v1/chat' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{"message":"Hello","username":"alice"}'
// 通过 UMO 向用户发送主动消息
const response = await fetch('http://localhost:6185/api/v1/im/message', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
platform: 'telegram',
user_id: '123456789',
message: 'Hello from Hermes Agent!'
})
});
Agent 通信协议 (ACP) 是 Hermes Agent 用于在客户端与 Agent 运行时之间进行结构化通信的消息格式。
{
"acp_version": "1.0",
"type": "chat.request" | "chat.response" | "tool.call" | "tool.result",
"payload": {
"session_id": "uuid",
"message": "user input",
"context": {}
},
"metadata": {
"timestamp": "ISO8601",
"user_id": "string"
}
}
用户消息,包含可选的会话上下文,用于继续对话。
Agent 响应,包含文本内容及可选的工具调用。
执行已注册工具的请求,包含相关参数。
工具执行结果,返回给 Agent 进行综合处理。