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 Kankute38cf66df012d
diff --git a/litellm/llms/minimax/chat/__init__.py b/litellm/llms/minimax/chat/__init__.pynew file mode 100644index 00000000000..45bcfd03b49--- /dev/null+++ b/litellm/llms/minimax/chat/__init__.py@@ -0,0 +1,4 @@+"""+MiniMax OpenAI-compatible chat API+"""+diff --git a/litellm/llms/minimax/chat/transformation.py b/litellm/llms/minimax/chat/transformation.pynew file mode 100644index 00000000000..ed80ff8aed1--- /dev/null+++ b/litellm/llms/minimax/chat/transformation.py@@ -0,0 +1,83 @@+"""+MiniMax OpenAI transformation config - extends OpenAI chat config for MiniMax's OpenAI-compatible API+"""+from typing import Optional++import litellm+from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig+from litellm.secret_managers.main import get_secret_str+++class MinimaxChatConfig(OpenAIGPTConfig):+ """+ MiniMax OpenAI configuration that extends OpenAIGPTConfig.+ MiniMax provides an OpenAI-compatible API at:+ - International: https://api.minimax.io/v1+ - China: https://api.minimaxi.com/v1++ Supported models:+ - MiniMax-M2.1+ - MiniMax-M2.1-lightning+ - MiniMax-M2+ """++ @staticmethod+ def get_api_key(api_key: Optional[str] = None) -> Optional[str]:+ """+ Get MiniMax API key from environment or parameters.+ """+ return (+ api_key+ or get_secret_str("MINIMAX_API_KEY")+ or litellm.api_key+ )++ @staticmethod+ def get_api_base(+ api_base: Optional[str] = None,+ ) -> str:+ """+ Get MiniMax API base URL.+ Defaults to international endpoint: https://api.minimax.io/v1+ For China, set to: https://api.minimaxi.com/v1+ """+ return (+ api_base+ or get_secret_str("MINIMAX_API_BASE")+ or "https://api.minimax.io/v1"+ )++ def get_complete_url(+ self,+ api_base: Optional[str],+ api_key: Optional[str],+ model: str,+ optional_params: dict,+ litellm_params: dict,+ stream: Optional[bool] = None,+ ) -> str:+ """+ Get the complete URL for MiniMax OpenAI API.+ Override to ensure we use MiniMax's endpoint.+ """+ # Get the base URL (either provided or default MiniMax endpoint)+ base_url = self.get_api_base(api_base=api_base)++ # Ensure it ends with /chat/completions+ if base_url.endswith("/chat/completions"):+ return base_url+ elif base_url.endswith("/v1"):+ return f"{base_url}/chat/completions"+ elif base_url.endswith("/"):+ return f"{base_url}v1/chat/completions"+ else:+ return f"{base_url}/v1/chat/completions"++ def get_supported_openai_params(self, model: str) -> list:+ """+ Get supported OpenAI parameters for MiniMax.+ Adds reasoning_split to the list of supported params.+ """+ base_params = super().get_supported_openai_params(model=model)+ return base_params + ["reasoning_split"]+