From f3a0261bb48ef1125cd2dbc3f0dae507344a71ef Mon Sep 17 00:00:00 2001 From: Grayson Chen Date: Wed, 19 Mar 2025 21:09:03 +0800 Subject: [PATCH] feat: Add support for custom OPENROUTER_API_BASE via get_secret in completion function --- litellm/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/litellm/main.py b/litellm/main.py index 64049c31d1..fcf711d2dd 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -2245,7 +2245,12 @@ def completion( # type: ignore # noqa: PLR0915 additional_args={"headers": headers}, ) elif custom_llm_provider == "openrouter": - api_base = api_base or litellm.api_base or "https://openrouter.ai/api/v1" + api_base = ( + api_base + or litellm.api_base + or get_secret("OPENROUTER_API_BASE") + or "https://openrouter.ai/api/v1" + ) api_key = ( api_key