The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Integration with Nebius AI Studio added (#11143)
Akim Tsvigunacaa80294c2c
diff --git a/README.md b/README.mdindex 01a60310522..cbb6b4807bd 100644--- a/README.md+++ b/README.md@@ -335,6 +335,8 @@ curl 'http://0.0.0.0:4000/key/generate' \| [Galadriel](https://docs.litellm.ai/docs/providers/galadriel) | ✅ | ✅ | ✅ | ✅ | | || [Novita AI](https://novita.ai/models/llm?utm_source=github_litellm&utm_medium=github_readme&utm_campaign=github_link) | ✅ | ✅ | ✅ | ✅ | | || [Featherless AI](https://docs.litellm.ai/docs/providers/featherless_ai) | ✅ | ✅ | ✅ | ✅ | | |+| [Nebius AI Studio](https://docs.litellm.ai/docs/providers/nebius) | ✅ | ✅ | ✅ | ✅ | ✅ | |+[**Read the Docs**](https://docs.litellm.ai/docs/)## Contributingdiff --git a/docs/my-website/docs/embedding/supported_embedding.md b/docs/my-website/docs/embedding/supported_embedding.mdindex 6257ca2dba4..24c1895d1d2 100644--- a/docs/my-website/docs/embedding/supported_embedding.md+++ b/docs/my-website/docs/embedding/supported_embedding.md@@ -469,7 +469,7 @@ response = embedding(print(response)```-## Supported Models+### Supported ModelsAll models listed here https://docs.voyageai.com/embeddings/#models-and-specifics are supported| Model Name | Function Call |@@ -478,7 +478,7 @@ All models listed here https://docs.voyageai.com/embeddings/#models-and-specific| voyage-lite-01 | `embedding(model="voyage/voyage-lite-01", input)` || voyage-lite-01-instruct | `embedding(model="voyage/voyage-lite-01-instruct", input)` |-## Provider-specific Params+### Provider-specific Params:::info@@ -540,3 +540,28 @@ curl -X POST 'http://0.0.0.0:4000/v1/embeddings' \```</TabItem></Tabs>++## Nebius AI Studio Embedding Models++### Usage - Embedding+```python+from litellm import embedding+import os++os.environ['NEBIUS_API_KEY'] = ""+response = embedding(+ model="nebius/BAAI/bge-en-icl",+ input=["Good morning from litellm!"],+)+print(response)+```++### Supported Models+All supported models can be found here: https://studio.nebius.ai/models/embedding++| Model Name | Function Call |+|--------------------------|-----------------------------------------------------------------|+| BAAI/bge-en-icl | `embedding(model="nebius/BAAI/bge-en-icl", input)` |+| BAAI/bge-multilingual-gemma2 | `embedding(model="nebius/BAAI/bge-multilingual-gemma2", input)` |+| intfloat/e5-mistral-7b-instruct | `embedding(model="nebius/intfloat/e5-mistral-7b-instruct", input)` |+diff --git a/docs/my-website/docs/providers/nebius.md b/docs/my-website/docs/providers/nebius.mdnew file mode 100644index 00000000000..26b5098c9f2--- /dev/null+++ b/docs/my-website/docs/providers/nebius.md@@ -0,0 +1,195 @@+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++# Nebius AI Studio+https://docs.nebius.com/studio/inference/quickstart++:::tip++**Litellm provides support to all models from Nebius AI Studio. To use a model, set `model=nebius/<any-model-on-nebius-ai-studio>` as a prefix for litellm requests. The full list of supported models is provided at https://studio.nebius.ai/ **++:::++## API Key+```python+import os+# env variable+os.environ['NEBIUS_API_KEY']+```++## Sample Usage: Text Generation+```python+from litellm import completion+import os++os.environ['NEBIUS_API_KEY'] = "insert-your-nebius-ai-studio-api-key"+response = completion(+ model="nebius/Qwen/Qwen3-235B-A22B",+ messages=[+ {+ "role": "user",+ "content": "What character was Wall-e in love with?",+ }+ ],+ max_tokens=10,+ response_format={ "type": "json_object" },+ seed=123,+ stop=["\n\n"],+ temperature=0.6, # either set temperature or `top_p`+ top_p=0.01, # to get as deterministic results as possible+ tool_choice="auto",+ tools=[],+ user="user",+)+print(response)+```++## Sample Usage - Streaming+```python+from litellm import completion+import os++os.environ['NEBIUS_API_KEY'] = ""+response = completion(+ model="nebius/Qwen/Qwen3-235B-A22B",+ messages=[+ {+ "role": "user",+ "content": "What character was Wall-e in love with?",+ }+ ],+ stream=True,+ max_tokens=10,+ response_format={ "type": "json_object" },+ seed=123,+ stop=["\n\n"],+ temperature=0.6, # either set temperature or `top_p`+ top_p=0.01, # to get as deterministic results as possible+ tool_choice="auto",+ tools=[],+ user="user",+)++for chunk in response:+ print(chunk)+```++## Sample Usage - Embedding+```python+from litellm import embedding+import os++os.environ['NEBIUS_API_KEY'] = ""+response = embedding(+ model="nebius/BAAI/bge-en-icl",+ input=["What character was Wall-e in love with?"],+)+print(response)+```+++## Usage with LiteLLM Proxy Server++Here's how to call a Nebius AI Studio model with the LiteLLM Proxy Server++1. Modify the config.yaml++ ```yaml+ model_list:+ - model_name: my-model+ litellm_params:+ model: nebius/<your-model-name> # add nebius/ prefix to use Nebius AI Studio as provider+ api_key: api-key # api key to send your model+ ```+2. Start the proxy+ ```bash+ $ litellm --config /path/to/config.yaml+ ```++3. Send Request to LiteLLM Proxy Server++ <Tabs>++ <TabItem value="openai" label="OpenAI Python v1.0.0+">++ ```python+ import openai+ client = openai.OpenAI(+ api_key="litellm-proxy-key", # pass litellm proxy key, if you're using virtual keys+ base_url="http://0.0.0.0:4000" # litellm-proxy-base url+ )++ response = client.chat.completions.create(+ model="my-model",+ messages = [+ {+ "role": "user",+ "content": "What character was Wall-e in love with?"+ }+ ],+ )++ print(response)+ ```+ </TabItem>++ <TabItem value="curl" label="curl">++ ```shell+ curl --location 'http://0.0.0.0:4000/chat/completions' \+ --header 'Authorization: litellm-proxy-key' \+ --header 'Content-Type: application/json' \+ --data '{+ "model": "my-model",+ "messages": [+ {+ "role": "user",+ "content": "What character was Wall-e in love with?"+ }+ ],+ }'+ ```+ </TabItem>++ </Tabs>++## Supported Parameters++The Nebius provider supports the following parameters:++### Chat Completion Parameters++| Parameter | Type | Description |+| --------- | ---- | ----------- |+| frequency_penalty | number | Penalizes new tokens based on their frequency in the text |+| function_call | string/object | Controls how the model calls functions |+| functions | array | List of functions for which the model may generate JSON inputs |+| logit_bias | map | Modifies the likelihood of specified tokens |+| max_tokens | integer | Maximum number of tokens to generate |+| n | integer | Number of completions to generate |+| presence_penalty | number | Penalizes tokens based on if they appear in the text so far |+| response_format | object | Format of the response, e.g., {"type": "json"} |+| seed | integer | Sampling seed for deterministic results |+| stop | string/array | Sequences where the API will stop generating tokens |+| stream | boolean | Whether to stream the response |+| temperature | number | Controls randomness (0-2) |+| top_p | number | Controls nucleus sampling |+| tool_choice | string/object | Controls which (if any) function to call |+| tools | array | List of tools the model can use |+| user | string | User identifier |++### Embedding Parameters++| Parameter | Type | Description |+| --------- | ---- | ----------- |+| input | string/array | Text to embed |+| user | string | User identifier |++## Error Handling++The integration uses the standard LiteLLM error handling. Common errors include:++- **Authentication Error**: Check your API key+- **Model Not Found**: Ensure you're using a valid model name+- **Rate Limit Error**: You've exceeded your rate limits+- **Timeout Error**: Request took too long to completediff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.jsindex 89020a7f3bd..60073bc1e25 100644--- a/docs/my-website/sidebars.js+++ b/docs/my-website/sidebars.js@@ -379,7 +379,8 @@ const sidebars = {"providers/custom_llm_server","providers/petals","providers/snowflake",- "providers/featherless_ai"+ "providers/featherless_ai",+ "providers/nebius"],},{diff --git a/litellm/__init__.py b/litellm/__init__.pyindex bbb937a538c..99127bec19c 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -203,6 +203,7 @@ aleph_alpha_key: Optional[str] = Nonenlp_cloud_key: Optional[str] = Nonenovita_api_key: Optional[str] = Nonesnowflake_key: Optional[str] = None+nebius_key: Optional[str] = Nonecommon_cloud_provider_auth_params: dict = {"params": ["project", "region_name", "token"],"providers": ["vertex_ai", "bedrock", "watsonx", "azure", "vertex_ai_beta"],@@ -299,6 +300,7 @@ custom_prometheus_metadata_labels: List[str] = []#### REQUEST PRIORITIZATION ####priority_reservation: Optional[Dict[str, float]] = None+######## Networking Settings ########use_aiohttp_transport: bool = Trueforce_ipv4: bool = False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6.@@ -444,6 +446,8 @@ assemblyai_models: List = []snowflake_models: List = []llama_models: List = []nscale_models: List = []+nebius_models: List = []+nebius_embedding_models: List = []def is_bedrock_pricing_only_model(key: str) -> bool:@@ -601,6 +605,10 @@ def add_known_models():sambanova_models.append(key)elif value.get("litellm_provider") == "novita":novita_models.append(key)+ elif value.get("litellm_provider") == "nebius-chat-models":+ nebius_models.append(key)+ elif value.get("litellm_provider") == "nebius-embedding-models":+ nebius_embedding_models.append(key)elif value.get("litellm_provider") == "assemblyai":assemblyai_models.append(key)elif value.get("litellm_provider") == "jina_ai":@@ -744,6 +752,7 @@ models_by_provider: dict = {"galadriel": galadriel_models,"sambanova": sambanova_models,"novita": novita_models,+ "nebius": nebius_models + nebius_embedding_models,"assemblyai": assemblyai_models,"jina_ai": jina_ai_models,"snowflake": snowflake_models,@@ -782,6 +791,7 @@ all_embedding_models = (+ bedrock_embedding_models+ vertex_embedding_models+ fireworks_ai_embedding_models+ + nebius_embedding_models)####### IMAGE GENERATION MODELS ###################@@ -1060,6 +1070,7 @@ from .llms.azure.chat.o_series_transformation import AzureOpenAIO1Configfrom .llms.watsonx.completion.transformation import IBMWatsonXAIConfigfrom .llms.watsonx.chat.transformation import IBMWatsonXChatConfigfrom .llms.watsonx.embed.transformation import IBMWatsonXEmbeddingConfig+from .llms.nebius.chat.transformation import NebiusConfigfrom .main import * # type: ignorefrom .integrations import *from .exceptions import (diff --git a/litellm/constants.py b/litellm/constants.pyindex 50df19bb7f9..f1ed7380119 100644--- a/litellm/constants.py+++ b/litellm/constants.py@@ -231,12 +231,14 @@ LITELLM_CHAT_PROVIDERS = ["meta_llama","featherless_ai","nscale",+ "nebius",]LITELLM_EMBEDDING_PROVIDERS_SUPPORTING_INPUT_ARRAY_OF_TOKENS = ["openai","azure","hosted_vllm",+ "nebius",]@@ -321,7 +323,6 @@ DEFAULT_CHAT_COMPLETION_PARAM_VALUES = {"web_search_options": None,}-openai_compatible_endpoints: List = ["api.perplexity.ai","api.endpoints.anyscale.com/v1",@@ -341,6 +342,7 @@ openai_compatible_endpoints: List = ["api.llama.com/compat/v1/","api.featherless.ai/v1","inference.api.nscale.com/v1",+ "api.studio.nebius.ai/v1",]@@ -375,6 +377,7 @@ openai_compatible_providers: List = ["meta_llama","featherless_ai","nscale",+ "nebius",]openai_text_completion_compatible_providers: List = ([ # providers that support `/v1/completions`@@ -384,6 +387,7 @@ openai_text_completion_compatible_providers: List = ("meta_llama","llamafile","featherless_ai",+ "nebius",])_openai_like_providers: List = [@@ -542,6 +546,27 @@ featherless_ai_models: List = ["ProdeusUnity/Stellar-Odyssey-12b-v0.0",]+nebius_models: List = [+ "Qwen/Qwen3-235B-A22B",+ "Qwen/Qwen3-30B-A3B-fast",+ "Qwen/Qwen3-32B",+ "Qwen/Qwen3-14B",+ "nvidia/Llama-3_1-Nemotron-Ultra-253B-v1",+ "deepseek-ai/DeepSeek-V3-0324",+ "deepseek-ai/DeepSeek-V3-0324-fast",+ "deepseek-ai/DeepSeek-R1",+ "deepseek-ai/DeepSeek-R1-fast",+ "meta-llama/Llama-3.3-70B-Instruct-fast",+ "Qwen/Qwen2.5-32B-Instruct-fast",+ "Qwen/Qwen2.5-Coder-32B-Instruct-fast",+]++nebius_embedding_models: List = [+ "BAAI/bge-en-icl",+ "BAAI/bge-multilingual-gemma2",+ "intfloat/e5-mistral-7b-instruct",+]+BEDROCK_INVOKE_PROVIDERS_LITERAL = Literal["cohere","anthropic",diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.pyindex f792d249b3f..79e7020eb2a 100644--- a/litellm/litellm_core_utils/get_llm_provider_logic.py+++ b/litellm/litellm_core_utils/get_llm_provider_logic.py@@ -227,7 +227,7 @@ def get_llm_provider( # noqa: PLR0915dynamic_api_key = api_key or get_secret_str("LLAMA_API_KEY")elif endpoint == "https://api.featherless.ai/v1":custom_llm_provider = "featherless_ai"- dynamic_api_key = get_secret_str("FEATHERLESS_AI_API_KEY")+ dynamic_api_key = get_secret_str("FEATHERLESS_AI_API_KEY")elif endpoint == litellm.NscaleConfig.API_BASE_URL:custom_llm_provider = "nscale"dynamic_api_key = litellm.NscaleConfig.get_api_key()@@ -467,6 +467,13 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915or "https://api.llama.com/compat/v1") # type: ignoredynamic_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.studio.nebius.ai/v1"+ ) # type: ignore+ dynamic_api_key = api_key or get_secret_str("NEBIUS_API_KEY")elif (custom_llm_provider == "ai21_chat") or (custom_llm_provider == "ai21" and model in litellm.ai21_chat_models):@@ -627,7 +634,7 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915dynamic_api_key,) = litellm.FeatherlessAIConfig()._get_openai_compatible_provider_info(api_base, api_key- )+ )elif custom_llm_provider == "nscale":(api_base,diff --git a/litellm/litellm_core_utils/get_supported_openai_params.py b/litellm/litellm_core_utils/get_supported_openai_params.pyindex 043444cfc6a..461b962dbc1 100644--- a/litellm/litellm_core_utils/get_supported_openai_params.py+++ b/litellm/litellm_core_utils/get_supported_openai_params.py@@ -137,6 +137,9 @@ def get_supported_openai_params( # noqa: PLR0915)elif custom_llm_provider == "sambanova":return litellm.SambanovaConfig().get_supported_openai_params(model=model)+ elif custom_llm_provider == "nebius":+ if request_type == "chat_completion":+ return litellm.NebiusConfig().get_supported_openai_params(model=model)elif custom_llm_provider == "replicate":return litellm.ReplicateConfig().get_supported_openai_params(model=model)elif custom_llm_provider == "huggingface":diff --git a/litellm/llms/nebius/chat/transformation.py b/litellm/llms/nebius/chat/transformation.pynew file mode 100644index 00000000000..cb713147718--- /dev/null+++ b/litellm/llms/nebius/chat/transformation.py@@ -0,0 +1,27 @@+"""+Nebius AI Studio Chat Completions API - Transformation++This is OpenAI compatible - no translation needed / occurs+"""++from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig+++class NebiusConfig(OpenAIGPTConfig):+ def map_openai_params(+ self,+ non_default_params: dict,+ optional_params: dict,+ model: str,+ drop_params: bool,+ ) -> dict:+ """+ map max_completion_tokens param to max_tokens+ """+ supported_openai_params = self.get_supported_openai_params(model=model)+ for param, value in non_default_params.items():+ if param == "max_completion_tokens":+ optional_params["max_tokens"] = value+ elif param in supported_openai_params:+ optional_params[param] = value+ return optional_paramsdiff --git a/litellm/llms/nebius/embedding/transformation.py b/litellm/llms/nebius/embedding/transformation.pynew file mode 100644index 00000000000..d56b7def13c--- /dev/null+++ b/litellm/llms/nebius/embedding/transformation.py@@ -0,0 +1,5 @@+"""+Calls handled in openai/++as Nebius AI Studio is an openai-compatible endpoint.+"""diff --git a/litellm/main.py b/litellm/main.pyindex afdbb2d2e05..453560a6a73 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -1775,6 +1775,7 @@ def completion( # type: ignore # noqa: PLR0915or custom_llm_provider == "mistral"or custom_llm_provider == "openai"or custom_llm_provider == "together_ai"+ or custom_llm_provider == "nebius"or custom_llm_provider in litellm.openai_compatible_providersor "ft:gpt-3.5-turbo" in model # finetune gpt-3.5-turbo): # allow user to make an openai call with a custom base@@ -3918,6 +3919,27 @@ def embedding( # noqa: PLR0915api_key = (api_key or litellm.api_key or get_secret_str("FIREWORKS_AI_API_KEY"))+ response = openai_chat_completions.embedding(+ model=model,+ input=input,+ api_base=api_base,+ api_key=api_key,+ logging_obj=logging,+ timeout=timeout,+ model_response=EmbeddingResponse(),+ optional_params=optional_params,+ client=client,+ aembedding=aembedding,+ )+ elif custom_llm_provider == "nebius":+ api_key = api_key or litellm.api_key or get_secret_str("NEBIUS_API_KEY")+ api_base = (+ api_base+ or litellm.api_base+ or get_secret_str("NEBIUS_API_BASE")+ or "api.studio.nebius.ai/v1"+ )+response = openai_chat_completions.embedding(model=model,input=input,diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 0b679619747..1447fe1d81e 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -13274,5 +13274,133 @@"max_output_tokens": 4096,"litellm_provider": "featherless_ai","mode": "chat"+ },+ "nebius/deepseek-ai/DeepSeek-V3-0324": {+ "max_tokens": 128000,+ "max_input_tokens": 64000,+ "max_output_tokens": 64000,+ "input_cost_per_token": 0.0000005,+ "output_cost_per_token": 0.0000015,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/deepseek-ai/DeepSeek-V3-0324-fast": {+ "max_tokens": 128000,+ "max_input_tokens": 64000,+ "max_output_tokens": 64000,+ "input_cost_per_token": 0.000002,+ "output_cost_per_token": 0.000006,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/deepseek-ai/DeepSeek-R1": {+ "max_tokens": 128000,+ "max_input_tokens": 64000,+ "max_output_tokens": 64000,+ "input_cost_per_token": 0.0000005,+ "output_cost_per_token": 0.0000015,+ "litellm_provider": "nebius",+ "supports_function_calling": false,+ "mode": "chat"+ },+ "nebius/deepseek-ai/DeepSeek-R1-fast": {+ "max_tokens": 128000,+ "max_input_tokens": 64000,+ "max_output_tokens": 64000,+ "input_cost_per_token": 0.000002,+ "output_cost_per_token": 0.000006,+ "litellm_provider": "nebius",+ "supports_function_calling": false,+ "mode": "chat"+ },+ "nebius/meta-llama/Llama-3.3-70B-Instruct": {+ "max_tokens": 128000,+ "max_input_tokens": 128000,+ "max_output_tokens": 8192,+ "input_cost_per_token": 0.00000013,+ "output_cost_per_token": 0.0000004,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/Qwen/Qwen3-235B-A22B": {+ "max_tokens": 40000,+ "max_input_tokens": 32000,+ "max_output_tokens": 8000,+ "input_cost_per_token": 0.0000002,+ "output_cost_per_token": 0.0000006,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/Qwen/Qwen3-30B-A3B": {+ "max_tokens": 40000,+ "max_input_tokens": 32000,+ "max_output_tokens": 8000,+ "input_cost_per_token": 0.0000001,+ "output_cost_per_token": 0.0000003,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/Qwen/Qwen3-30B-A3B-fast": {+ "max_tokens": 40000,+ "max_input_tokens": 32000,+ "max_output_tokens": 8000,+ "input_cost_per_token": 0.0000003,+ "output_cost_per_token": 0.0000009,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/Qwen/Qwen3-32B": {+ "max_tokens": 40000,+ "max_input_tokens": 32000,+ "max_output_tokens": 8000,+ "input_cost_per_token": 0.0000001,+ "output_cost_per_token": 0.0000003,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "mode": "chat"+ },+ "nebius/Qwen/Qwen2.5-VL-72B-Instruct": {+ "max_tokens": 32000,+ "max_input_tokens": 24000,+ "max_output_tokens": 8000,+ "input_cost_per_token": 0.00000025,+ "output_cost_per_token": 0.00000075,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "supports_vision": true,+ "mode": "chat"+ },+ "nebius/google/gemma-3-27b-it-fast": {+ "max_tokens": 128000,+ "max_input_tokens": 64000,+ "max_output_tokens": 64000,+ "input_cost_per_token": 0.0000002,+ "output_cost_per_token": 0.0000006,+ "litellm_provider": "nebius",+ "supports_function_calling": true,+ "supports_vision": true,+ "mode": "chat"+ },+ "nebius/BAAI/bge-en-icl": {+ "max_tokens": 32000,+ "max_input_tokens": 32000,+ "input_cost_per_token": 0.00000001,+ "output_cost_per_token": 0.0,+ "litellm_provider": "nebius",+ "mode": "embedding"+ },+ "nebius/BAAI/bge-multilingual-gemma2": {+ "max_tokens": 32000,+ "max_input_tokens": 32000,+ "input_cost_per_token": 0.00000001,+ "output_cost_per_token": 0.0,+ "litellm_provider": "nebius",+ "mode": "embedding"}}diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 310a4332f08..17136b0575c 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -2226,6 +2226,7 @@ class LlmProviders(str, Enum):LLAMAFILE = "llamafile"LM_STUDIO = "lm_studio"GALADRIEL = "galadriel"+ NEBIUS = "nebius"INFINITY = "infinity"DEEPGRAM = "deepgram"NOVITA = "novita"diff --git a/litellm/utils.py b/litellm/utils.pyindex 04682239516..ee09cd9bed3 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -1828,6 +1828,7 @@ def supports_response_schema(litellm.LlmProviders.PREDIBASE,litellm.LlmProviders.FIREWORKS_AI,litellm.LlmProviders.LM_STUDIO,+ litellm.LlmProviders.NEBIUS,]if custom_llm_provider in PROVIDERS_GLOBALLY_SUPPORT_RESPONSE_SCHEMA:@@ -2849,6 +2850,7 @@ def pre_process_optional_params(and custom_llm_provider != "bedrock"and custom_llm_provider != "ollama_chat"and custom_llm_provider != "openrouter"+ and custom_llm_provider != "nebius"and custom_llm_provider not in litellm.openai_compatible_providers):if custom_llm_provider == "ollama":@@ -3564,6 +3566,17 @@ def get_optional_params( # noqa: PLR0915else False),)+ elif custom_llm_provider == "nebius":+ optional_params = litellm.NebiusConfig().map_openai_params(+ non_default_params=non_default_params,+ optional_params=optional_params,+ model=model,+ drop_params=(+ drop_params+ if drop_params is not None and isinstance(drop_params, bool)+ else False+ ),+ )elif custom_llm_provider == "azure":if litellm.AzureOpenAIO1Config().is_o_series_model(model=model):optional_params = litellm.AzureOpenAIO1Config().map_openai_params(@@ -3979,6 +3992,9 @@ def get_api_key(llm_provider: str, dynamic_api_key: Optional[str]):or get_secret("TOGETHERAI_API_KEY")or get_secret("TOGETHER_AI_TOKEN"))+ # nebius+ elif llm_provider == "nebius":+ api_key = api_key or litellm.nebius_key or get_secret("NEBIUS_API_KEY")return api_key@@ -5028,6 +5044,11 @@ def validate_environment( # noqa: PLR0915keys_in_environment = Trueelse:missing_keys.append("NOVITA_API_KEY")+ elif custom_llm_provider == "nebius":+ if "NEBIUS_API_KEY" in os.environ:+ keys_in_environment = True+ else:+ missing_keys.append("NEBIUS_API_KEY")else:## openai - chatcompletion + text completionif (@@ -5115,6 +5136,11 @@ def validate_environment( # noqa: PLR0915keys_in_environment = Trueelse:missing_keys.append("NOVITA_API_KEY")+ elif model in litellm.nebius_models:+ if "NEBIUS_API_KEY" in os.environ:+ keys_in_environment = True+ else:+ missing_keys.append("NEBIUS_API_KEY")if api_key is not None:new_missing_keys = []@@ -6460,6 +6486,8 @@ class ProviderConfigManager:return litellm.FeatherlessAIConfig()elif litellm.LlmProviders.NOVITA == provider:return litellm.NovitaConfig()+ elif litellm.LlmProviders.NEBIUS == provider:+ return litellm.NebiusConfig()elif litellm.LlmProviders.BEDROCK == provider:bedrock_route = BedrockModelInfo.get_bedrock_route(model)bedrock_invoke_provider = litellm.BedrockLLM.get_bedrock_invoke_provider(diff --git a/tests/litellm/llms/nebius/test_nebius_chat_transformation.py b/tests/litellm/llms/nebius/test_nebius_chat_transformation.pynew file mode 100644index 00000000000..9d32679c5e2--- /dev/null+++ b/tests/litellm/llms/nebius/test_nebius_chat_transformation.py@@ -0,0 +1,110 @@+"""+Unit tests for Nebius AI Studio configuration.++These tests validate the NebiusConfig class which extends OpenAIGPTConfig.+Nebius AI Studio is an OpenAI-compatible provider with minor customizations.+"""++import os+import sys++sys.path.insert(+ 0, os.path.abspath("../../../../..")+) # Adds the parent directory to the system path++import pytest+import litellm+from litellm import completion+from litellm.llms.nebius.chat.transformation import NebiusConfig+++class TestNebiusConfig:+ """Test class for Nebius AI Studio functionality"""++ def test_default_api_base(self):+ """Test that default API base is used when none is provided"""+ config = NebiusConfig()+ headers = {}+ api_key = "fake-nebius-key"++ # Call validate_environment without specifying api_base+ result = config.validate_environment(+ headers=headers,+ model="nebius/Qwen/Qwen3-4B",+ messages=[{"role": "user", "content": "Hey"}],+ optional_params={},+ litellm_params={},+ api_key=api_key,+ api_base=None, # Not providing api_base+ )++ # Verify headers are still set correctly+ assert result["Authorization"] == f"Bearer {api_key}"+ assert result["Content-Type"] == "application/json"++ # We can't directly test the api_base value here since validate_environment+ # only returns the headers, but we can verify it doesn't raise an exception+ # which would happen if api_base handling was incorrect++ @pytest.mark.respx()+ def test_nebius_completion_mock(self, respx_mock):+ """+ Mock test for Nebius AI Studio completion using the model format from docs.+ This test mocks the actual HTTP request to test the integration properly.+ """++ litellm.use_aiohttp_transport = False # since this uses respx, we need to set use_aiohttp_transport to False++ # Set up environment variables for the test+ api_key = "fake-nebius-key"+ api_base = "https://api.studio.nebius.ai/v1"+ model = "nebius/Qwen/Qwen3-4B"+ model_name = "Qwen3-4B" # The actual model name without provider prefix++ # Mock the HTTP request to the Nebius AI Studio API+ respx_mock.post(f"{api_base}/chat/completions").respond(+ json={+ "id": "chatcmpl-123",+ "object": "chat.completion",+ "created": 1677652288,+ "model": model_name,+ "choices": [+ {+ "index": 0,+ "message": {+ "role": "assistant",+ "content": '```python\nprint("Hey from LiteLLM!")\n```\n\nThis simple Python code prints a greeting message from LiteLLM.',+ },+ "finish_reason": "stop",+ }+ ],+ "usage": {+ "prompt_tokens": 9,+ "completion_tokens": 12,+ "total_tokens": 21,+ },+ },+ status_code=200,+ )++ # Make the actual API call through LiteLLM+ response = completion(+ model=model,+ messages=[+ {"role": "user", "content": "write code for saying hey from LiteLLM"}+ ],+ api_key=api_key,+ api_base=api_base,+ )++ # Verify response structure+ assert response is not None+ assert hasattr(response, "choices")+ assert len(response.choices) > 0+ assert hasattr(response.choices[0], "message")+ assert hasattr(response.choices[0].message, "content")+ assert response.choices[0].message.content is not None++ # Check for specific content in the response+ assert "```python" in response.choices[0].message.content+ assert "Hey from LiteLLM" in response.choices[0].message.contentdiff --git a/tests/litellm/llms/nebius/test_nebius_embedding_transformation.py b/tests/litellm/llms/nebius/test_nebius_embedding_transformation.pynew file mode 100644index 00000000000..da34964bacb--- /dev/null+++ b/tests/litellm/llms/nebius/test_nebius_embedding_transformation.py@@ -0,0 +1,40 @@+import litellm+from unittest.mock import patch+++def mock_embedding_response(*args, **kwargs):+ """Mock response mimicking litellm.embedding output."""++ class MockResponse:+ def __init__(self):+ self.data = [{"embedding": [0.1, 0.2, 0.3]}] # Example embedding vector+ self.usage = litellm.Usage() # Mock Usage object+ self.model = kwargs.get("model", "nebius/BAAI/bge-en-icl")+ self.object = "embedding"++ def __getitem__(self, key):+ return getattr(self, key)++ return MockResponse()+++def test_nebius_embeddings():+ """Mocked test for Nebius embeddings using MagicMock."""+ with patch("litellm.embedding", side_effect=mock_embedding_response) as mock_embed:+ response = litellm.embedding(+ model="nebius/BAAI/bge-en-icl",+ input=["good morning from litellm"],+ )++ # Assertions to verify that the mock was called correctly+ mock_embed.assert_called_once_with(+ model="nebius/BAAI/bge-en-icl",+ input=["good morning from litellm"],+ )++ # Assertions to check the structure of the mocked response+ assert isinstance(response.data, list)+ assert "embedding" in response.data[0]+ assert isinstance(response.data[0]["embedding"], list)+ assert response.model == "nebius/BAAI/bge-en-icl"+ assert response.object == "embedding"diff --git a/tests/local_testing/test_embedding.py b/tests/local_testing/test_embedding.pyindex 151352c77d3..a153b2b02d0 100644--- a/tests/local_testing/test_embedding.py+++ b/tests/local_testing/test_embedding.py@@ -1165,3 +1165,4 @@ async def test_embedding_with_extra_headers(sync_mode):mock_post.assert_called_once()assert "my-test-param" in mock_post.call_args.kwargs["headers"]+\ No newline at end of filediff --git a/tests/local_testing/test_streaming.py b/tests/local_testing/test_streaming.pyindex 9ac2d86c003..ffeda23edde 100644--- a/tests/local_testing/test_streaming.py+++ b/tests/local_testing/test_streaming.py@@ -4022,4 +4022,4 @@ def test_is_delta_empty():tool_calls=None,audio=None,)- )+ )\ No newline at end of file