diff --git a/python/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb b/python/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb index 0d1bdf26ba80..f6f81149db68 100644 --- a/python/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb +++ b/python/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb @@ -481,6 +481,18 @@ "await model_client.close()" ] }, + { + "cell_type": "markdown", + "source": "## MiniMax (experimental)\n\n[MiniMax](https://www.minimax.io/) offers an [OpenAI-compatible API](https://platform.minimaxi.com/document/Fast%20access?key=66701332a427f0c8a5701643).\nSo you can use the {py:class}`~autogen_ext.models.openai.OpenAIChatCompletionClient` with the MiniMax API.\n\nAvailable models:\n* `MiniMax-M2.7` — Latest flagship model, 204K context window, supports vision, function calling, and structured output.\n* `MiniMax-M2.7-highspeed` — Same capabilities as M2.7 with optimized inference speed.\n* `MiniMax-M2.5` — Previous generation, 204K context window.\n* `MiniMax-M2.5-highspeed` — Same capabilities as M2.5 with optimized inference speed.\n\n```{note}\nMiniMax requires `temperature` to be in (0.0, 1.0] — a value of 0 is not accepted.\n```", + "metadata": {} + }, + { + "cell_type": "code", + "source": "from autogen_core.models import UserMessage\nfrom autogen_ext.models.openai import OpenAIChatCompletionClient\n\nmodel_client = OpenAIChatCompletionClient(\n model=\"MiniMax-M2.7\",\n # api_key=\"MINIMAX_API_KEY\",\n)\n\nresponse = await model_client.create([UserMessage(content=\"What is the capital of France?\", source=\"user\")])\nprint(response)\nawait model_client.close()", + "metadata": {}, + "execution_count": null, + "outputs": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -599,4 +611,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/python/packages/autogen-core/src/autogen_core/models/_model_client.py b/python/packages/autogen-core/src/autogen_core/models/_model_client.py index e70bacdcf57d..a0104605f3da 100644 --- a/python/packages/autogen-core/src/autogen_core/models/_model_client.py +++ b/python/packages/autogen-core/src/autogen_core/models/_model_client.py @@ -45,6 +45,8 @@ class ModelFamily: LLAMA_3_3_70B = "llama-3.3-70b" LLAMA_4_SCOUT = "llama-4-scout" LLAMA_4_MAVERICK = "llama-4-maverick" + MINIMAX_M2_5 = "minimax-m2.5" + MINIMAX_M2_7 = "minimax-m2.7" CODESRAL = "codestral" OPEN_CODESRAL_MAMBA = "open-codestral-mamba" MISTRAL = "mistral" @@ -84,6 +86,9 @@ class ModelFamily: "llama-3.3-70b", "llama-4-scout", "llama-4-maverick", + # minimax_models + "minimax-m2.5", + "minimax-m2.7", # mistral_models "codestral", "open-codestral-mamba", @@ -143,6 +148,10 @@ def is_llama(family: str) -> bool: ModelFamily.LLAMA_4_MAVERICK, ) + @staticmethod + def is_minimax(family: str) -> bool: + return family in (ModelFamily.MINIMAX_M2_5, ModelFamily.MINIMAX_M2_7) + @staticmethod def is_mistral(family: str) -> bool: return family in ( diff --git a/python/packages/autogen-ext/src/autogen_ext/models/openai/_model_info.py b/python/packages/autogen-ext/src/autogen_ext/models/openai/_model_info.py index 91e86c1c67e4..fb2db1aaaaa2 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/openai/_model_info.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/openai/_model_info.py @@ -41,6 +41,11 @@ "claude-3-7-sonnet": "claude-3-7-sonnet-20250219", "claude-4-sonnet": "claude-sonnet-4-20250514", "claude-4-opus": "claude-opus-4-20250514", + # MiniMax models + "minimax-m2.5": "MiniMax-M2.5", + "minimax-m2.5-highspeed": "MiniMax-M2.5-highspeed", + "minimax-m2.7": "MiniMax-M2.7", + "minimax-m2.7-highspeed": "MiniMax-M2.7-highspeed", # Llama models "llama-3.3-8b": "Llama-3.3-8B-Instruct", "llama-3.3-70b": "Llama-3.3-70B-Instruct", @@ -409,6 +414,38 @@ "structured_output": False, "multiple_system_messages": True, }, + "MiniMax-M2.5": { + "vision": True, + "function_calling": True, + "json_output": True, + "family": ModelFamily.MINIMAX_M2_5, + "structured_output": True, + "multiple_system_messages": True, + }, + "MiniMax-M2.5-highspeed": { + "vision": True, + "function_calling": True, + "json_output": True, + "family": ModelFamily.MINIMAX_M2_5, + "structured_output": True, + "multiple_system_messages": True, + }, + "MiniMax-M2.7": { + "vision": True, + "function_calling": True, + "json_output": True, + "family": ModelFamily.MINIMAX_M2_7, + "structured_output": True, + "multiple_system_messages": True, + }, + "MiniMax-M2.7-highspeed": { + "vision": True, + "function_calling": True, + "json_output": True, + "family": ModelFamily.MINIMAX_M2_7, + "structured_output": True, + "multiple_system_messages": True, + }, "Llama-3.3-8B-Instruct": { "vision": False, "function_calling": True, @@ -487,6 +524,10 @@ "claude-3-7-sonnet-20250219": 200000, "claude-sonnet-4-20250514": 200000, "claude-opus-4-20250514": 200000, + "MiniMax-M2.5": 204800, + "MiniMax-M2.5-highspeed": 204800, + "MiniMax-M2.7": 204800, + "MiniMax-M2.7-highspeed": 204800, "Llama-3.3-8B-Instruct": 128000, "Llama-3.3-70B-Instruct": 128000, "Llama-4-Scout-17B-16E-Instruct-FP8": 128000, @@ -496,6 +537,7 @@ GEMINI_OPENAI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/" ANTHROPIC_OPENAI_BASE_URL = "https://api.anthropic.com/v1/" LLAMA_API_BASE_URL = "https://api.llama.com/compat/v1/" +MINIMAX_API_BASE_URL = "https://api.minimax.io/v1" def resolve_model(model: str) -> str: diff --git a/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py b/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py index a80e912534ab..23327c7e9194 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py @@ -1480,6 +1480,11 @@ def __init__(self, **kwargs: Unpack[OpenAIClientConfiguration]): copied_args["base_url"] = _model_info.LLAMA_API_BASE_URL if "api_key" not in copied_args and "LLAMA_API_KEY" in os.environ: copied_args["api_key"] = os.environ["LLAMA_API_KEY"] + if copied_args["model"].startswith("MiniMax-"): + if "base_url" not in copied_args: + copied_args["base_url"] = _model_info.MINIMAX_API_BASE_URL + if "api_key" not in copied_args and "MINIMAX_API_KEY" in os.environ: + copied_args["api_key"] = os.environ["MINIMAX_API_KEY"] client = _openai_client_from_config(copied_args) create_args = _create_args_from_config(copied_args)