Skip to content

fix(gateway): read api_key from model config in /model command handler#19683

Open
Cyrene963 wants to merge 1 commit into
NousResearch:mainfrom
Cyrene963:fix/model-command-api-key
Open

fix(gateway): read api_key from model config in /model command handler#19683
Cyrene963 wants to merge 1 commit into
NousResearch:mainfrom
Cyrene963:fix/model-command-api-key

Conversation

@Cyrene963

Copy link
Copy Markdown

Summary

Fixes #18681

The /model command handler in the messaging gateway reads model.default, model.provider, and model.base_url from config.yaml, but did not read model.api_key. This caused probe_api_models() to send unauthenticated requests to custom endpoints that require bearer tokens, resulting in 401 errors.

Fix

Added one line after the current_base_url assignment:

current_api_key = model_cfg.get("api_key", "")

This matches the pattern already used in tui_gateway/server.py which correctly reads the API key from the agent object.

Testing

Verified that the /model command now correctly passes the API key when probing custom endpoints with authentication.

Closes #18681

The /model command handler in the messaging gateway read
model.default, model.provider, and model.base_url from config
but did not read model.api_key. This caused probe_api_models()
to send unauthenticated requests to custom endpoints that
require bearer tokens, resulting in 401 errors.

Fixes NousResearch#18681
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 4, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #18685 — same one-line fix (read api_key from model config in /model handler). Both address #18681.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #18685

@Cyrene963

Copy link
Copy Markdown
Author

Closing as duplicate of #18685 (LeonSGP43) — same one-line fix for reading api_key from model config in /model handler.

Local patch remains active in Cyrene963/hermes-patches until #18685 is merged.

@Cyrene963 Cyrene963 closed this May 4, 2026
@Cyrene963 Cyrene963 reopened this May 25, 2026
@Cyrene963

Copy link
Copy Markdown
Author

Re-evaluating closure status for #19683

I closed this as a duplicate earlier, but I rechecked the referenced upstream PR(s) and none of them are merged yet:

Because the underlying fix does not appear to have landed upstream, closing this solely as a duplicate may have been premature. I am reopening this PR so it can remain trackable unless maintainers prefer a different canonical PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gateway): /model command fails on custom providers — api_key not read from config

2 participants