Skip to content

Python: feat: add MiniMax provider with M3 as default model#5121

Open
octo-patch wants to merge 3 commits into
microsoft:mainfrom
octo-patch:feature/add-minimax-provider
Open

Python: feat: add MiniMax provider with M3 as default model#5121
octo-patch wants to merge 3 commits into
microsoft:mainfrom
octo-patch:feature/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Apr 6, 2026

Summary

This PR adds a new agent-framework-minimax package that integrates MiniMax's Anthropic-compatible API into the Microsoft Agent Framework, with MiniMax-M3 as the default model.

What's added

  • New package python/packages/minimax/agent_framework_minimax/ with:
    • MiniMaxClient — fully-featured client (with middleware, telemetry, and function invocation)
    • RawMiniMaxClient — lightweight client without layers
  • Supported models: MiniMax-M3 (default, 512K context, up to 128K output, supports image input), MiniMax-M2.7, and MiniMax-M2.7-highspeed
  • Uses MiniMax's Anthropic-compatible API (https://api.minimax.io/anthropic)
  • Filters out Anthropic-specific parameters not supported by MiniMax (betas, top_k, service_tier, etc.)
  • Unit tests and integration tests included

Usage

import asyncio
from agent_framework_minimax import MiniMaxClient
from agent_framework import Message

async def main():
    client = MiniMaxClient(model="MiniMax-M3")
    response = await client.get_response([Message(role="user", contents=["Hello from MiniMax!"])])
    print(response.messages[0].text)

asyncio.run(main())

Environment Variables

Variable Required Description
MINIMAX_API_KEY Yes MiniMax API key
MINIMAX_CHAT_MODEL No Default model (defaults to MiniMax-M3)
MINIMAX_BASE_URL No Override base URL

API Documentation

octo-patch and others added 2 commits April 6, 2026 11:50
- Add agent-framework-minimax package with Anthropic-compatible API integration
- Support MiniMax-M2.7 and MiniMax-M2.7-highspeed models
- Add MINIMAX_API_KEY environment variable support
- Add unit and integration tests
- Add MiniMax-M3 to model list and set as default
- Keep MiniMax-M2.7 and MiniMax-M2.7-highspeed
- Update related tests and documentation
Copilot AI review requested due to automatic review settings June 5, 2026 06:24
@moonbox3 moonbox3 added documentation Improvements or additions to documentation python labels Jun 5, 2026
@octo-patch octo-patch changed the title feat: add MiniMax provider support feat: add MiniMax provider with M3 as default model Jun 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new agent-framework-minimax Python package implementing a MiniMax (Anthropic-compatible) chat client, along with packaging metadata, documentation, and tests.

Changes:

  • Introduces RawMiniMaxClient / MiniMaxClient with MiniMax-specific defaults and unsupported-parameter filtering.
  • Adds unit + integration tests and pytest fixtures for the MiniMax package.
  • Adds package metadata (pyproject.toml), README, and licensing/docs files.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
python/packages/minimax/agent_framework_minimax/_chat_client.py Implements MiniMax chat clients and settings, including unsupported param filtering and base URL/model defaults.
python/packages/minimax/agent_framework_minimax/init.py Exposes public package API and __version__.
python/packages/minimax/tests/test_minimax_client.py Adds unit/integration coverage for settings, client behavior, and API-call shaping.
python/packages/minimax/tests/conftest.py Adds pytest fixtures for env setup and an Anthropic-client mock.
python/packages/minimax/pyproject.toml Defines package metadata, dependencies, and test/lint tooling configuration.
python/packages/minimax/README.md Documents installation and usage (basic + streaming) and supported models.
python/packages/minimax/LICENSE Adds MIT license for the new package.
python/packages/minimax/AGENTS.md Adds package-level agent/developer notes and usage reference.

Comment on lines +2 to +14
import os
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from agent_framework import (
ChatMiddlewareLayer,
FunctionInvocationLayer,
Message,
)
from agent_framework._tools import normalize_function_invocation_configuration

USER_MESSAGE = [Message(role="user", contents=["Hello"])]
from agent_framework.observability import ChatTelemetryLayer
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed in fd69caa — moved ChatTelemetryLayer above the USER_MESSAGE assignment and removed the unused patch import.

Comment on lines +21 to +28
def minimax_unit_test_env(monkeypatch, exclude_list, override_env_param_dict): # type: ignore
"""Fixture to set environment variables for MiniMaxSettings."""
if exclude_list is None:
exclude_list = []

if override_env_param_dict is None:
override_env_param_dict = {}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — removed the dead None branches in fd69caa. The fixtures always return a list/dict so the checks were unreachable.

Comment on lines +42 to +46
MINIMAX_MODELS: Final[list[str]] = [
"MiniMax-M3",
"MiniMax-M2.7",
"MiniMax-M2.7-highspeed",
]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — switched MINIMAX_MODELS to Final[tuple[str, ...]] backed by a tuple literal in fd69caa. Verified in and MINIMAX_MODELS[0] usages in the tests still pass.


def test_raw_minimax_client_custom_base_url(minimax_unit_test_env: dict[str, str]) -> None:
"""Test that RawMiniMaxClient respects a custom base_url."""
custom_url = "https://api.minimaxi.com/anthropic"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with https://example.com/anthropic in fd69caa — clearer placeholder that won’t be confused for a real MiniMax host.

@github-actions github-actions Bot changed the title feat: add MiniMax provider with M3 as default model Python: feat: add MiniMax provider support Jun 5, 2026
@octo-patch octo-patch changed the title Python: feat: add MiniMax provider support Python: feat: add MiniMax provider with M3 as default model Jun 5, 2026
- Move ChatTelemetryLayer import above USER_MESSAGE assignment and drop
  unused `patch` import (test_minimax_client.py): fixes Ruff E402 and
  removes dead import.
- Drop dead `if exclude_list is None` / `if override_env_param_dict is None`
  branches in conftest.py — the fixtures always return a list/dict.
- Use `Final[tuple[str, ...]]` for MINIMAX_MODELS so the constant is truly
  immutable (no `.append` foot-gun).
- Replace `api.minimaxi.com` placeholder URL in custom base-url test with
  `example.com/anthropic` to make intent clearer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants