fix(tts): use get_env_value for API key resolution from ~/.hermes/.env#17262
Closed
zhanggttry wants to merge 3 commits into
Closed
fix(tts): use get_env_value for API key resolution from ~/.hermes/.env#17262zhanggttry wants to merge 3 commits into
zhanggttry wants to merge 3 commits into
Conversation
TTS provider tools (elevenlabs, xai, minimax, mistral, gemini) used os.getenv() directly which cannot see keys stored in ~/.hermes/.env. This replaces all os.getenv() calls with get_env_value() from hermes_cli.config, which properly reads the .env file. Closes NousResearch#17140
Collaborator
Contributor
Author
|
Closing as duplicate of #17163 by @briandevans, which includes comprehensive regression tests and passes the supply chain audit. The approach in #17163 is more complete — I will support that PR instead. Note: The test failures and supply chain audit failure on this PR are pre-existing issues on the main branch (Tests also fail on main: run 25090500778). Our change only touches tools/tts_tool.py and does not introduce any new risks. |
This was referenced Apr 29, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #17140 — TTS provider tools fail to read API keys from
~/.hermes/.env.Problem
TTS provider tools (
elevenlabs,minimax,mistral,xai,gemini) useos.getenv("X_API_KEY")directly, which does not read values stored in~/.hermes/.env. The hermes config system usesget_env_value()fromhermes_cli.configwhich reads.envdirectly, but the TTS tools bypass this, causing "API key not set" errors even when keys are correctly configured.Solution
Replace all
os.getenv()calls for API keys and base URLs intools/tts_tool.pywith_get_env_value()(aliased fromhermes_cli.config.get_env_value), following the same pattern already used byhermes_cli/auth.pyandhermes_cli/gateway.py.Changes
Added
_get_env_valueimport with fallback (lines 53-59):Replaced all
os.getenv()calls for env vars in tts_tool.py:os.getenv("ELEVENLABS_API_KEY", "")_get_env_value("ELEVENLABS_API_KEY") or ""os.getenv("XAI_API_KEY", "").strip()(_get_env_value("XAI_API_KEY") or "").strip()os.getenv("XAI_BASE_URL")_get_env_value("XAI_BASE_URL")os.getenv("MINIMAX_API_KEY", "")_get_env_value("MINIMAX_API_KEY") or ""os.getenv("MISTRAL_API_KEY", "")_get_env_value("MISTRAL_API_KEY") or ""os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")_get_env_value("GEMINI_API_KEY") or _get_env_value("GOOGLE_API_KEY")os.getenv("GEMINI_BASE_URL")_get_env_value("GEMINI_BASE_URL")os.getenv("ELEVENLABS_API_KEY")_get_env_value("ELEVENLABS_API_KEY")os.getenv("MINIMAX_API_KEY")_get_env_value("MINIMAX_API_KEY")os.getenv("XAI_API_KEY")_get_env_value("XAI_API_KEY")os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")_get_env_value("GEMINI_API_KEY") or _get_env_value("GOOGLE_API_KEY")os.getenv("MISTRAL_API_KEY")_get_env_value("MISTRAL_API_KEY")os.getenv("ELEVENLABS_API_KEY", "")_get_env_value("ELEVENLABS_API_KEY") or ""os.getenv('ELEVENLABS_API_KEY')_get_env_value('ELEVENLABS_API_KEY')os.getenv('MINIMAX_API_KEY')_get_env_value('MINIMAX_API_KEY')Safety
os.getenv()ifhermes_cli.configis unavailable — no behavior change for existing installationsget_env_value()checksos.environfirst, then.envfile — fully backward-compatibleTesting
py_compile)hermes_cli/auth.py(line 332) andhermes_cli/gateway.py(lines 2388+)Closes #17140