Support OPENAI_BASE_URL in addition to OPENAI_API_BASE

Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
This commit is contained in:
Adrian Cole 2025-04-15 07:51:28 +08:00
parent 64bb89c70f
commit 6e44a91960
15 changed files with 128 additions and 16 deletions

View file

@ -1515,6 +1515,7 @@ def completion( # type: ignore # noqa: PLR0915
api_base = (
api_base
or litellm.api_base
or get_secret("OPENAI_BASE_URL")
or get_secret("OPENAI_API_BASE")
or "https://api.openai.com/v1"
)
@ -1642,6 +1643,7 @@ def completion( # type: ignore # noqa: PLR0915
api_base = (
api_base # for deepinfra/perplexity/anyscale/groq/friendliai we check in get_llm_provider and pass in the api base from there
or litellm.api_base
or get_secret("OPENAI_BASE_URL")
or get_secret("OPENAI_API_BASE")
or "https://api.openai.com/v1"
)
@ -1695,6 +1697,7 @@ def completion( # type: ignore # noqa: PLR0915
api_base = (
api_base # for deepinfra/perplexity/anyscale/groq/friendliai we check in get_llm_provider and pass in the api base from there
or litellm.api_base
or get_secret("OPENAI_BASE_URL")
or get_secret("OPENAI_API_BASE")
or "https://api.openai.com/v1"
)
@ -3481,6 +3484,7 @@ def embedding( # noqa: PLR0915
api_base = (
api_base
or litellm.api_base
or get_secret_str("OPENAI_BASE_URL")
or get_secret_str("OPENAI_API_BASE")
or "https://api.openai.com/v1"
)
@ -5150,6 +5154,7 @@ def transcription(
api_base = (
api_base
or litellm.api_base
or get_secret("OPENAI_BASE_URL")
or get_secret("OPENAI_API_BASE")
or "https://api.openai.com/v1"
) # type: ignore
@ -5320,6 +5325,7 @@ def speech( # noqa: PLR0915
api_base = (
api_base # for deepinfra/perplexity/anyscale/groq/friendliai we check in get_llm_provider and pass in the api base from there
or litellm.api_base
or get_secret("OPENAI_BASE_URL")
or get_secret("OPENAI_API_BASE")
or "https://api.openai.com/v1"
) # type: ignore