Bug Description
The /model command in the messaging gateway (Telegram, Discord, Matrix, etc.) fails to switch models on custom providers (e.g. LiteLLM) when the endpoint requires authentication.
Error message:
Note: could not reach this custom endpoint's model listing at http://127.0.0.1:8000/v1/models. Hermes will still save glm-5.1, but the endpoint should expose /models for verification.
Root Cause
In gateway/run.py, the /model command handler reads default, provider, and base_url from the model: section of config.yaml, but does not read api_key. The variable current_api_key stays as an empty string, so probe_api_models() sends unauthenticated requests to the endpoint. Servers that require a bearer token (like LiteLLM) reject the probe with HTTP 401.
Affected code (gateway/run.py, inside the /model command handler):
model_cfg = cfg.get("model", {})
if isinstance(model_cfg, dict):
current_model = model_cfg.get("default", "")
current_provider = model_cfg.get("provider", current_provider)
current_base_url = model_cfg.get("base_url", "")
# ⬇️ missing: current_api_key = model_cfg.get("api_key", "")
Note: the TUI gateway (tui_gateway/server.py) does not have this bug — it correctly reads api_key from getattr(agent, "api_key", "").
Reproduction
- Configure a custom provider with auth:
model:
default: glm-5-turbo
provider: custom
base_url: http://127.0.0.1:8000/v1
api_key: <your-key>
- Start the messaging gateway
- Send
/model glm-5.1 via any connected platform
- Observe: model switch rejected with "could not reach this custom endpoint's model listing"
Proposed Fix
Add one line after the current_base_url assignment:
current_base_url = model_cfg.get("base_url", "")
+ current_api_key = model_cfg.get("api_key", "")
Environment
- Hermes Agent v0.12.0+ (2026.04.30)
- Provider: custom (LiteLLM)
- Gateway platforms: Matrix (likely affects all platforms)
Bug Description
The
/modelcommand in the messaging gateway (Telegram, Discord, Matrix, etc.) fails to switch models on custom providers (e.g. LiteLLM) when the endpoint requires authentication.Error message:
Root Cause
In
gateway/run.py, the/modelcommand handler readsdefault,provider, andbase_urlfrom themodel:section ofconfig.yaml, but does not readapi_key. The variablecurrent_api_keystays as an empty string, soprobe_api_models()sends unauthenticated requests to the endpoint. Servers that require a bearer token (like LiteLLM) reject the probe with HTTP 401.Affected code (
gateway/run.py, inside the/modelcommand handler):Note: the TUI gateway (
tui_gateway/server.py) does not have this bug — it correctly readsapi_keyfromgetattr(agent, "api_key", "").Reproduction
/model glm-5.1via any connected platformProposed Fix
Add one line after the
current_base_urlassignment:current_base_url = model_cfg.get("base_url", "") + current_api_key = model_cfg.get("api_key", "")Environment