fix(runtime-provider): accept api_key_env alias in named custom providers - #44669
Closed
liuhao1024 wants to merge 1 commit into
Closed
liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…ders `_get_named_custom_provider()` only checked `key_env` when resolving the API key env var name for `providers:` dict entries, silently ignoring the documented `api_key_env` alias. This caused named custom providers configured with `api_key_env:` to fall through to "no-key-required" → 401. The same omission existed in the legacy `custom_providers:` list path and in `_resolve_named_custom_runtime`'s key_env candidate builder. Fix all three locations to accept both `key_env` and `api_key_env`, matching the pattern already used in `auxiliary_client.py:3652` and `runtime_provider.py:1544`. Fixes NousResearch#44666
Contributor
|
Duplicate of #44667 (earliest open PR for the same fix). Both accept the |
3 tasks
Contributor
Author
|
Closing as duplicate of #44667 which was opened earlier and covers the same fix ( |
8 tasks
23 tasks
This was referenced Aug 3, 2026
Open
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.
What does this PR do?
Accepts the
api_key_envconfig alias in_get_named_custom_provider(), so providers defined underproviders:(or legacycustom_providers:) using the documentedapi_key_env:field correctly resolve the API key instead of silently falling through to"no-key-required"→ 401.Related Issue
Fixes #44666
Type of Change
Changes Made
hermes_cli/runtime_provider.py: Acceptapi_key_envas an alias forkey_envin three locations — theproviders:dict scan (line 542), the legacycustom_providers:list scan (line 629), and the_resolve_named_custom_runtimekey_env candidate (line 761). Matches the pattern already used inauxiliary_client.py:3652.tests/hermes_cli/test_user_providers_model_switch.py: Three regression tests —api_key_envin providers dict, priority when bothkey_envandapi_key_envare set, andapi_key_envin legacy custom_providers list.How to Test
api_key_env:in config.yaml:MY_API_KEY=sk-testin.envhermes config set model.provider myprovider— should NOT send"no-key-required"as bearer tokenpython -m pytest tests/hermes_cli/test_user_providers_model_switch.py -k api_key_env -xvsChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
hermes_cli/runtime_provider.py—_get_named_custom_provider()(callers: 8),_resolve_named_custom_runtime()(callers: 3)key_envusersauxiliary_client.py:3652already checks bothkey_envandapi_key_env;runtime_provider.py:1544iterates both keys for error messages