HERMES-GIELIE/api
Carly 2.0 cc6709c9d5 fix: pass api_key to AIAgent for non-Anthropic /anthropic providers
When the user's config uses a non-Anthropic provider with an
Anthropic-compatible endpoint (e.g. MiniMax at
https://api.minimax.io/anthropic), chat in the WebUI fails silently
with APIConnectionError on every request, while the hermes CLI and
messaging gateway work fine with the same config.

Root cause: both api/routes.py and api/streaming.py constructed
AIAgent using only (model, provider, base_url) from
resolve_model_provider() and never passed api_key. When the base URL
ends in /anthropic, AIAgent uses the anthropic_messages adapter, but
only falls back to ANTHROPIC_TOKEN when provider == "anthropic" (a
safety check to avoid leaking Anthropic credentials to third parties).
For MiniMax and similar providers the effective key becomes "", and
the auth failure surfaces as a generic "Connection error" after three
retries.

The CLI and gateway resolve the key via
hermes_cli.runtime_provider.resolve_runtime_provider(), which reads
MINIMAX_API_KEY (and similar) from ~/.hermes/.env. This patch does the
same before creating the AIAgent in both chat paths.

Fixes #77
2026-04-04 15:03:02 -05:00
..
__init__.py Hermes Web UI — Sprints 11-14: multi-provider models, settings, session QoL, alerts, polish 2026-03-31 07:02:47 +00:00
auth.py fix(auth): redirect to /login when auth is enabled and accessing root 2026-04-03 06:21:04 -07:00
config.py feat: token usage toggle (setting + /usage command) + timestamp fixes 2026-04-03 19:11:36 -07:00
helpers.py feat: Sprint 19 — password auth, security headers, login page 2026-04-03 05:53:26 -07:00
models.py feat: Sprint 23 — agentic transparency + polish 2026-04-03 18:33:49 -07:00
profiles.py fix(review): 4 issues found in agent review of PR #45 2026-04-03 13:58:43 -07:00
routes.py fix: pass api_key to AIAgent for non-Anthropic /anthropic providers 2026-04-04 15:03:02 -05:00
streaming.py fix: pass api_key to AIAgent for non-Anthropic /anthropic providers 2026-04-04 15:03:02 -05:00
upload.py fix: stop leaking stack traces to clients in HTTP 500 responses 2026-04-03 06:41:32 -07:00
workspace.py fix: workspace isolation, session filtering, and clean migration path 2026-04-03 20:01:12 +00:00