Skip to content

feat: add MiniMax as native LLM provider with M2.7 default#4843

Open
octo-patch wants to merge 3 commits intocrewAIInc:mainfrom
octo-patch:feat/add-minimax-provider
Open

feat: add MiniMax as native LLM provider with M2.7 default#4843
octo-patch wants to merge 3 commits intocrewAIInc:mainfrom
octo-patch:feat/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Mar 13, 2026

Summary

Add first-class support for MiniMax as a native LLM provider in CrewAI, enabling users to use MiniMax models without the LiteLLM fallback.

What's included

  • Native MiniMax provider (crewai/llms/providers/minimax/) — uses the OpenAI-compatible SDK pointed at MiniMax's API endpoint
  • Model routingMiniMax-M2.5 and MiniMax-M2.5-highspeed are recognized automatically by the factory, supporting bare model names, minimax/ prefix, and explicit provider="minimax" kwarg
  • MiniMax-specific constraints handled automatically:
    • temperature clamped to (0.0, 1.0] (zero is rejected by MiniMax API)
    • response_format intentionally omitted (not supported)
    • Default base URL: https://api.minimax.io/v1
  • Context window: 204,800 tokens for both models
  • 11 unit tests covering routing, configuration, temperature clamping, and API key validation
  • README updated with MiniMax usage example

Usage

import os
os.environ["MINIMAX_API_KEY"] = "your-key"

from crewai import LLM

llm = LLM(model="MiniMax-M2.5")
# or
llm = LLM(model="MiniMax-M2.5-highspeed")
# or with explicit provider
llm = LLM(model="MiniMax-M2.5", provider="minimax")

Models

Model Context Window Description
MiniMax-M2.5 204,800 tokens Default model — peak performance, ultimate value
MiniMax-M2.5-highspeed 204,800 tokens Same performance, faster and more agile

Test plan

  • All 11 unit tests pass (pytest lib/crewai/tests/llms/minimax/)
  • Integration test: LLM(model="MiniMax-M2.5") routes to MiniMaxCompletion
  • Integration test: API call with real MiniMax API key returns valid response
  • minimax/MiniMax-M2.5 prefix routing works correctly
  • Temperature=0 is clamped to 0.01 automatically
  • Default base URL is https://api.minimax.io/v1

Note

Medium Risk
Adds a new native LLM provider and updates model-routing logic, which could affect how LLM() selects providers and handles streaming/tool calls for prefixed models. Risk is mitigated by targeted unit tests but still touches core LLM factory behavior.

Overview
Adds native MiniMax LLM support so LLM(model="MiniMax-M2.7") (or minimax/-prefixed models / provider="minimax") routes to a first-class provider instead of falling back to LiteLLM.

Updates CLI/provider constants to include minimax, prompt for MINIMAX_API_KEY, and registers MiniMax models; extends LLM provider inference/validation, supported native providers, and context window sizing for MiniMax.

Introduces MiniMaxCompletion (OpenAI-SDK-based) with MiniMax-specific behaviors (default base URL, temperature clamping, no response_format), plus unit tests and a README usage snippet.

Written by Cursor Bugbot for commit 6b1f148. This will update automatically on new commits. Configure here.

Add first-class support for MiniMax's OpenAI-compatible API, enabling
users to use MiniMax-M2.5 and MiniMax-M2.5-highspeed models natively
without requiring the LiteLLM fallback.

Changes:
- Add MiniMaxCompletion provider (llms/providers/minimax/)
- Register MiniMax models in constants and routing logic
- Add MiniMax to CLI provider selection
- Document MiniMax usage in README

Usage:
  export MINIMAX_API_KEY="your-key"
  llm = LLM(model="MiniMax-M2.5")
return self._finalize_streaming(
full_response, tool_calls, usage_data, params,
available_functions, from_task, from_agent,
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing after-LLM-call hooks in sync streaming path

Medium Severity

The sync streaming path (_handle_streaming_finalize_streaming) returns the text response directly without calling _invoke_after_llm_call_hooks. The sync non-streaming path in the same file (_handle_completion) does call this hook. The OpenAI provider's equivalent streaming path also calls it (wrapping the finalized string result in _invoke_after_llm_call_hooks before returning). This means registered after_llm_call hooks silently won't fire for sync streaming MiniMax calls.

Additional Locations (1)
Fix in Cursor Fix in Web

if temperature is not None and temperature <= 0:
temperature = 0.01
if temperature is None:
temperature = 1.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Temperature values above 1.0 not clamped or validated

Low Severity

The code clamps temperature values ≤ 0 to 0.01 to satisfy MiniMax's (0.0, 1.0] constraint, but values > 1.0 are silently passed through to the API, which will reject them. Since the code already partially validates this constraint, the upper bound check appears to be an oversight.

Fix in Cursor Fix in Web

Add 11 unit tests covering MiniMax provider routing, model selection,
base URL configuration, temperature clamping, and API key validation.
@octo-patch octo-patch force-pushed the feat/add-minimax-provider branch from 2c98147 to 53fcad6 Compare March 13, 2026 14:25
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 4 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

except Exception as e:
if is_context_length_exceeded(e):
raise LLMContextLengthExceededError(str(e)) from e
raise
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Async completion missing specific error handling present in sync

Medium Severity

The _ahandle_completion async method only has a generic Exception handler, while its sync counterpart _handle_completion explicitly catches NotFoundError (converting to ValueError) and APIConnectionError (converting to ConnectionError) with specific error messages and failed-event emissions. This means callers of acall() receive raw OpenAI SDK exception types (NotFoundError, APIConnectionError) while callers of call() receive standard Python exceptions (ValueError, ConnectionError). The OpenAI provider handles both exception types in its async path, making MiniMax inconsistent with both itself and other providers.

Additional Locations (1)
Fix in Cursor Fix in Web

return int(size * CONTEXT_WINDOW_USAGE_RATIO)

def supports_multimodal(self) -> bool:
return False
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MiniMax provider largely duplicates OpenAI provider code

Low Severity

MiniMaxCompletion is ~720 lines that closely mirror OpenAICompletion since MiniMax uses an OpenAI-compatible API with the same SDK. Methods like _extract_token_usage, _finalize_streaming, _handle_completion, _ahandle_completion, and the streaming handlers are near-identical to their OpenAI counterparts. This duplication increases the maintenance burden — any bug fix in shared logic (e.g., tool-call handling, streaming finalization) needs to be applied in both files independently.

Fix in Cursor Fix in Web

- Add MiniMax-M2.7 and MiniMax-M2.7-highspeed to model list
- Set MiniMax-M2.7 as default model
- Keep all previous models (M2.5, M2.5-highspeed) as alternatives
- Update CLI model selection, context window mappings, and constants
- Update tests to cover M2.7 models and verify ordering
- Update README with M2.7 as recommended model
@octo-patch octo-patch changed the title feat: add MiniMax as a native LLM provider feat: add MiniMax as native LLM provider with M2.7 default Mar 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

This PR is stale because it has been open for 45 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant