fix(nebius): centralize Token Factory API base

This commit is contained in:
Dylan 2026-08-13 17:31:07 +02:00
parent 8812573511
commit 9b6b765ae2
3 changed files with 5 additions and 3 deletions

View file

@ -290,7 +290,7 @@ def get_llm_provider(
elif endpoint == litellm.NscaleConfig.API_BASE_URL:
custom_llm_provider = "nscale"
dynamic_api_key = litellm.NscaleConfig.get_api_key()
elif endpoint == "api.tokenfactory.nebius.com/v1":
elif endpoint == litellm.NebiusConfig.API_BASE_URL.removeprefix("https://"):
custom_llm_provider = "nebius"
dynamic_api_key = api_key or get_secret_str("NEBIUS_API_KEY")
elif endpoint == "dashscope-intl.aliyuncs.com/compatible-mode/v1":
@ -608,7 +608,7 @@ def _get_openai_compatible_provider_info(
api_base = api_base or get_secret("LLAMA_API_BASE") or "https://api.llama.com/compat/v1"
dynamic_api_key = api_key or get_secret_str("LLAMA_API_KEY")
elif custom_llm_provider == "nebius":
api_base = api_base or get_secret("NEBIUS_API_BASE") or "https://api.tokenfactory.nebius.com/v1"
api_base = api_base or get_secret("NEBIUS_API_BASE") or litellm.NebiusConfig.API_BASE_URL
dynamic_api_key = api_key or get_secret_str("NEBIUS_API_KEY")
elif custom_llm_provider == "ollama":
api_base = api_base or get_secret("OLLAMA_API_BASE") or "http://localhost:11434"

View file

@ -6,6 +6,8 @@ from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig
class NebiusConfig(OpenAIGPTConfig):
API_BASE_URL = "https://api.tokenfactory.nebius.com/v1"
def map_openai_params(
self,
non_default_params: dict,

View file

@ -6684,7 +6684,7 @@ def embedding(
api_base
or litellm.api_base
or get_secret_str("NEBIUS_API_BASE")
or "https://api.tokenfactory.nebius.com/v1"
or litellm.NebiusConfig.API_BASE_URL
)
response = openai_chat_completions.embedding(