fix: pass api_key directly to litellm completion calls

This commit is contained in:
0xallam
2025-12-06 23:22:32 +02:00
committed by Ahmed Allam
parent 286d53384a
commit 4297c8f6e4
3 changed files with 21 additions and 21 deletions

View File

@@ -25,19 +25,16 @@ from strix.tools import get_tools_prompt
logger = logging.getLogger(__name__)
api_key = os.getenv("LLM_API_KEY")
if api_key:
os.environ.setdefault("LITELLM_API_KEY", api_key)
litellm.api_key = api_key
litellm.drop_params = True
litellm.modify_params = True
api_base = (
_LLM_API_KEY = os.getenv("LLM_API_KEY")
_LLM_API_BASE = (
os.getenv("LLM_API_BASE")
or os.getenv("OPENAI_API_BASE")
or os.getenv("LITELLM_BASE_URL")
or os.getenv("OLLAMA_API_BASE")
)
if api_base:
litellm.api_base = api_base
class LLMRequestFailedError(Exception):
@@ -401,6 +398,11 @@ class LLM:
"timeout": self.config.timeout,
}
if _LLM_API_KEY:
completion_args["api_key"] = _LLM_API_KEY
if _LLM_API_BASE:
completion_args["api_base"] = _LLM_API_BASE
if self._should_include_stop_param():
completion_args["stop"] = ["</function>"]