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
Add: chat completion transformation for minmax
Sameer Kankuteb1b8d19d9712
diff --git a/litellm/__init__.py b/litellm/__init__.pyindex b20b3c5f8e1..dfcee0e2d3c 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -1482,6 +1482,7 @@ if TYPE_CHECKING:from .llms.bytez.chat.transformation import BytezChatConfig as BytezChatConfigfrom .llms.compactifai.chat.transformation import CompactifAIChatConfig as CompactifAIChatConfigfrom .llms.empower.chat.transformation import EmpowerChatConfig as EmpowerChatConfig+ from .llms.minimax.chat.transformation import MinimaxChatConfig as MinimaxChatConfigfrom .llms.aiohttp_openai.chat.transformation import AiohttpOpenAIChatConfig as AiohttpOpenAIChatConfigfrom .llms.huggingface.chat.transformation import HuggingFaceChatConfig as HuggingFaceChatConfigfrom .llms.huggingface.embedding.transformation import HuggingFaceEmbeddingConfig as HuggingFaceEmbeddingConfigdiff --git a/litellm/_lazy_imports.py b/litellm/_lazy_imports.pyindex 6f96f9f8ff3..044fad924ac 100644--- a/litellm/_lazy_imports.py+++ b/litellm/_lazy_imports.py@@ -165,6 +165,7 @@ LLM_CONFIG_NAMES = ("BytezChatConfig","CompactifAIChatConfig","EmpowerChatConfig",+ "MinimaxChatConfig","AiohttpOpenAIChatConfig","HuggingFaceChatConfig","HuggingFaceEmbeddingConfig",@@ -750,6 +751,14 @@ def _lazy_import_llm_configs(name: str) -> Any: # noqa: PLR0915_globals["EmpowerChatConfig"] = _EmpowerChatConfigreturn _EmpowerChatConfig+ if name == "MinimaxChatConfig":+ from .llms.minimax.chat.transformation import (+ MinimaxChatConfig as _MinimaxChatConfig,+ )++ _globals["MinimaxChatConfig"] = _MinimaxChatConfig+ return _MinimaxChatConfig+if name == "AiohttpOpenAIChatConfig":from .llms.aiohttp_openai.chat.transformation import (AiohttpOpenAIChatConfig as _AiohttpOpenAIChatConfig,diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.pyindex 3b0a3a5e1a5..164e2a73e65 100644--- a/litellm/litellm_core_utils/get_llm_provider_logic.py+++ b/litellm/litellm_core_utils/get_llm_provider_logic.py@@ -270,6 +270,9 @@ def get_llm_provider( # noqa: PLR0915elif endpoint == "api.minimax.io/anthropic" or endpoint == "api.minimaxi.com/anthropic":custom_llm_provider = "minimax"dynamic_api_key = get_secret_str("MINIMAX_API_KEY")+ elif endpoint == "api.minimax.io/v1" or endpoint == "api.minimaxi.com/v1":+ custom_llm_provider = "minimax"+ dynamic_api_key = get_secret_str("MINIMAX_API_KEY")elif endpoint == "platform.publicai.co/v1":custom_llm_provider = "publicai"dynamic_api_key = get_secret_str("PUBLICAI_API_KEY")diff --git a/litellm/main.py b/litellm/main.pyindex 60fe3eb2dec..fe2c2f333fc 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -68,7 +68,6 @@ from litellm.constants import (DEFAULT_MOCK_RESPONSE_PROMPT_TOKEN_COUNT,)from litellm.exceptions import LiteLLMUnknownProvider-from litellm.llms.openai_like.json_loader import JSONProviderRegistryfrom litellm.integrations.custom_logger import CustomLoggerfrom litellm.litellm_core_utils.asyncify import run_async_functionfrom litellm.litellm_core_utils.audio_utils.utils import (@@ -98,6 +97,7 @@ from litellm.llms.base_llm.base_model_iterator import (from litellm.llms.bedrock.common_utils import BedrockModelInfofrom litellm.llms.cohere.common_utils import CohereModelInfofrom litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler+from litellm.llms.openai_like.json_loader import JSONProviderRegistryfrom litellm.llms.vertex_ai.common_utils import (VertexAIModelRoute,get_vertex_ai_model_route,@@ -2247,6 +2247,42 @@ def completion( # type: ignore # noqa: PLR0915logging.post_call(input=messages, api_key=api_key, original_response=response)+ elif custom_llm_provider == "minimax":+ api_key = (+ api_key+ or get_secret_str("MINIMAX_API_KEY")+ or litellm.api_key+ )++ api_base = (+ api_base+ or litellm.api_base+ or get_secret_str("MINIMAX_API_BASE")+ or "https://api.minimax.io/v1"+ )++ response = base_llm_http_handler.completion(+ model=model,+ messages=messages,+ api_base=api_base,+ custom_llm_provider=custom_llm_provider,+ model_response=model_response,+ encoding=_get_encoding(),+ logging_obj=logging,+ optional_params=optional_params,+ timeout=timeout,+ litellm_params=litellm_params,+ shared_session=shared_session,+ acompletion=acompletion,+ stream=stream,+ api_key=api_key,+ headers=headers,+ client=client,+ provider_config=provider_config,+ )+ logging.post_call(+ input=messages, api_key=api_key, original_response=response+ )elif (model in litellm.open_ai_chat_completion_modelsor custom_llm_provider == "custom_openai"diff --git a/litellm/utils.py b/litellm/utils.pyindex c0e4dd8c052..d073c7866c2 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -7224,6 +7224,8 @@ class ProviderConfigManager:return litellm.IBMWatsonXAIConfig()elif litellm.LlmProviders.EMPOWER == provider:return litellm.EmpowerChatConfig()+ elif litellm.LlmProviders.MINIMAX == provider:+ return litellm.MinimaxChatConfig()elif litellm.LlmProviders.GITHUB == provider:return litellm.GithubChatConfig()elif litellm.LlmProviders.COMPACTIFAI == provider: