配置 Hermes Agent 对接 OpenWebUI 的步骤如下:
    
    1. 启用 API Server
    
    在 config.yaml 中配置 api_server 平台:
    
    yaml
    platforms:
      api_server:
        enabled: true
        host: 0.0.0.0
        port: 8642
    
    
    或者用命令设置:
    bash
    hermes config set platforms.api_server.enabled true
    hermes config set platforms.api_server.host 0.0.0.0
    hermes config set platforms.api_server.port 8642
    
    
    2. 设置 API Key
    
    在 ~/.hermes/.env 中添加:
    bash
    API_SERVER_HOST=0.0.0.0
    API_SERVER_KEY=sk-hermes-your-random-key-here
    
    
    3. 重启 Gateway
    
    bash
    hermes gateway restart
    
    
    验证 API Server 是否正常运行:
    bash
    curl http://localhost:8642/health
    
    
    4. 启动 OpenWebUI Docker 容器
    
    bash
    docker run -d \
      --name open-webui \
      --network bridge \
      --add-host=host.docker.internal:host-gateway \
      --restart unless-stopped \
      -p 0.0.0.0:8011:8080 \
      -v open-webui-data:/app/backend/data \
      -e OPENAI_API_BASE_URL=http://host.docker.internal:8642/v1 \
      -e OPENAI_API_KEY="sk-hermes-your-random-key-here" \
      -e WEBUI_SECRET_KEY="your-webui-secret" \
      ghcr.io/open-webui/open-webui:latest
    
    
    关键注意事项
    
    - --add-host=host.docker.internal:host-gateway 在 Linux Docker 上是必须的,容器才能访问宿主机的 API Server
    - OPENAI_API_KEY 必须和 .env 中的 API_SERVER_KEY 完全一致
    - Gateway 必须绑定 0.0.0.0,不能只绑 127.0.0.1(容器无法访问宿主机的 localhost)
    - OpenWebUI 启动较慢,需要 60-90 秒才能完全就绪
    
    5. 首次登录 OpenWebUI
    
    打开浏览器访问 http://你的IP:8011,必须先注册/登录,否则模型列表不会显示(/api/models 返回 401)。
    
    6. 验证连接
    
    bash
    docker exec open-webui curl -s http://host.docker.internal:8642/health
    
    
    如果看到 OLLAMA_BASE_URL 相关的 404 错误,那是正常的(OpenWebUI 会轮询 Ollama 接口,Hermes API 不支持这些端点,忽略即可)。

 

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐