Files
nexus/wiki/concepts/OpenAI兼容API.md
2026-05-03 05:42:12 +08:00

37 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "OpenAI兼容API"
type: concept
tags: []
last_updated: 2026-05-02
---
## Definition
Hermes Agent 内置的 API Server 暴露的标准 OpenAI Chat Completions 接口格式,允许任何兼容 OpenAI API 的客户端(如 n8n、curl、Postman直接调用无需额外 SDK 或中间件。
## Details
- 默认端口 **8642**,端点路径 `/v1/chat/completions`
- 认证方式Bearer Token通过 `API_SERVER_KEY` 配置)
- 健康检查端点:`GET /v1/health`,返回 `{"status": "ok"}`
- 支持 `X-Hermes-Session-Id` header 实现会话保持v0.7.0+
- 模型名称默认为 `hermes-agent`,可在 Profile 级别自定义
## Usage
- [[n8n]] 的 HTTP Request 节点通过 POST 到该端点实现 Agent 调用
- curl 验证命令:
```bash
curl http://localhost:8642/v1/chat/completions \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "hermes-agent", "messages": [{"role": "user", "content": "Hello!"}]}'
```
## Related
- [[HermesAgent]] — API Server 的宿主框架
- [[X-Hermes-Session-Id]] — API 的会话保持机制
- [[工作流编排]] — 该 API 的主要应用场景
## Aliases
- OpenAI Compatible API
- OpenAI-compatible API endpoint
- Hermes API Server