Files
zalo-hermes-bot/scripts/enable-hermes-api-server.sh
T
2026-09-14 22:32:32 +07:00

34 lines
925 B
Bash
Executable File

#!/usr/bin/env bash
# Enable Hermes API Server on the local gateway (one-time helper).
# Docs: https://hermes-agent.nousresearch.com/docs/user-guide/features/api-server
set -euo pipefail
HERMES_ENV="${HERMES_HOME:-$HOME/.hermes}/.env"
KEY="${1:-change-me-local-dev}"
mkdir -p "$(dirname "$HERMES_ENV")"
touch "$HERMES_ENV"
set_kv() {
local k="$1" v="$2"
if grep -q "^${k}=" "$HERMES_ENV" 2>/dev/null; then
sed -i "s|^${k}=.*|${k}=${v}|" "$HERMES_ENV"
else
printf '%s=%s\n' "$k" "$v" >>"$HERMES_ENV"
fi
}
set_kv API_SERVER_ENABLED true
set_kv API_SERVER_KEY "$KEY"
echo "Updated $HERMES_ENV"
echo " API_SERVER_ENABLED=true"
echo " API_SERVER_KEY=${KEY}"
echo
echo "Restart gateway:"
echo " systemctl --user restart hermes-gateway"
echo "Smoke:"
echo " curl -sS http://127.0.0.1:8642/v1/models -H \"Authorization: Bearer ${KEY}\""
echo
echo "Put the same key in zalo-hermes-bot/.env as HERMES_API_KEY"