From d39735ba06f9a771aa2964bf1e572ee70f6b1642 Mon Sep 17 00:00:00 2001 From: Manideep Malyala Date: Tue, 18 Aug 2026 04:13:00 +0530 Subject: [PATCH] fix(config): resolve LLM CONNECTION FAILED by injecting api credentials directly into LitellmModel instead of mutating global module state --- strix/config/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/strix/config/models.py b/strix/config/models.py index e632bb06..eb2a2c5c 100644 --- a/strix/config/models.py +++ b/strix/config/models.py @@ -483,6 +483,11 @@ class StrixProvider(MultiProvider): ) else: model = super().get_model(model_name) + if type(model).__name__ == "LitellmModel": + if llm.api_key: + model.api_key = llm.api_key + if llm.api_base: + model.base_url = llm.api_base if llm.disable_streaming: model = _NonStreamingModel(model) # The wrapper emits its single event only once the whole request @@ -562,11 +567,9 @@ def configure_sdk_model_defaults(settings: Settings) -> None: _configure_openrouter_attribution(llm.model) if llm.api_key: set_default_openai_key(llm.api_key, use_for_tracing=False) - _configure_litellm_default("api_key", llm.api_key) _mirror_api_key_to_provider_env(llm.model, llm.api_key) if llm.api_base: os.environ["OPENAI_BASE_URL"] = llm.api_base - _configure_litellm_default("api_base", llm.api_base) set_default_openai_api("chat_completions") else: set_default_openai_api("responses")