Skip to content

feat: add MiniMax as LLM provider for Python and TypeScript#1416

Open
octo-patch wants to merge 3 commits intoi-am-bee:mainfrom
octo-patch:feature/add-minimax-provider
Open

feat: add MiniMax as LLM provider for Python and TypeScript#1416
octo-patch wants to merge 3 commits intoi-am-bee:mainfrom
octo-patch:feature/add-minimax-provider

Conversation

@octo-patch
Copy link
Copy Markdown

Summary

Add MiniMax as a first-class LLM provider in both Python and TypeScript implementations. MiniMax provides an OpenAI-compatible API, making integration straightforward through existing LiteLLM (Python) and Vercel AI SDK (TypeScript) infrastructure.

Python

  • MiniMaxChatModel extending LiteLLMChatModel with OpenAI-compat routing
  • Registered "minimax" provider in BackendProviders with proper ProviderName/ProviderHumanName
  • Environment variables: MINIMAX_API_KEY, MINIMAX_CHAT_MODEL, MINIMAX_API_BASE, MINIMAX_API_HEADERS
  • Default model: MiniMax-M2.7, default base URL: https://api.minimax.io/v1
  • 15 unit tests (all passing) + 3 integration tests (all passing)
  • Provider example following existing deepseek/qwen pattern

TypeScript

  • MiniMaxChatModel extending VercelChatModel via @ai-sdk/openai
  • MiniMaxClient extending BackendClient with OpenAI provider
  • Registered "MiniMax" in BackendProviders with "minimax" alias
  • Provider example following existing xai pattern
  • 9 unit tests

Documentation

  • Added MiniMax to supported providers table in docs/modules/backend.mdx

Available Models

  • MiniMax-M2.7 (latest, 1M context)
  • MiniMax-M2.7-highspeed (faster variant)
  • MiniMax-M2.5 (204K context)
  • MiniMax-M2.5-highspeed (faster variant)

Changes

  • 14 files changed, 643 additions

Test plan

  • Python unit tests pass (15/15)
  • Python integration tests pass with real MiniMax API (3/3)
  • TypeScript unit tests validate instantiation, env vars, and provider registration
  • CI pipeline validates TypeScript build and tests

Usage

# Python
from beeai_framework.backend import ChatModel
llm = ChatModel.from_name("minimax:MiniMax-M2.7")
response = await llm.run([UserMessage("Hello!")])
// TypeScript
import { MiniMaxChatModel } from 'beeai-framework/adapters/minimax/backend/chat';
const llm = new MiniMaxChatModel('MiniMax-M2.7');

Add MiniMax as a first-class LLM provider in both Python and TypeScript
implementations. MiniMax provides an OpenAI-compatible API, making integration
straightforward through existing LiteLLM (Python) and Vercel AI SDK (TypeScript)
infrastructure.

Python:
- Add MiniMaxChatModel extending LiteLLMChatModel with OpenAI-compat routing
- Register "minimax" provider in BackendProviders with proper ProviderName/ProviderHumanName
- Support MINIMAX_API_KEY, MINIMAX_CHAT_MODEL, MINIMAX_API_BASE env vars
- Default model: MiniMax-M2.7, default base URL: https://api.minimax.io/v1
- 15 unit tests (all passing) + 3 integration tests (all passing)
- Provider example following existing deepseek/qwen pattern

TypeScript:
- Add MiniMaxChatModel extending VercelChatModel via @ai-sdk/openai
- Add MiniMaxClient extending BackendClient with OpenAI provider
- Register "MiniMax" in BackendProviders with "minimax" alias
- Support MINIMAX_API_KEY, MINIMAX_CHAT_MODEL, MINIMAX_API_BASE env vars
- 9 unit tests + provider example following existing xai pattern

Documentation:
- Add MiniMax to supported providers table in docs/modules/backend.mdx

Available models: MiniMax-M2.7, MiniMax-M2.7-highspeed, MiniMax-M2.5,
MiniMax-M2.5-highspeed
@octo-patch octo-patch requested review from a team as code owners March 26, 2026 11:12
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 26, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation python Python related functionality typescript Typescript related functionality labels Mar 26, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the framework's capabilities by integrating MiniMax as a new Large Language Model provider. The changes enable developers to seamlessly utilize MiniMax models within both Python and TypeScript applications, leveraging its OpenAI-compatible API for a consistent experience. This addition enhances the flexibility and choice of LLM backends available to users.

Highlights

  • New LLM Provider Integration: MiniMax has been added as a first-class Large Language Model (LLM) provider for both Python and TypeScript implementations. Its OpenAI-compatible API simplifies integration using existing LiteLLM (Python) and Vercel AI SDK (TypeScript) infrastructure.
  • Python Implementation Details: A MiniMaxChatModel extending LiteLLMChatModel was created, handling OpenAI-compatible routing. The 'minimax' provider is registered in BackendProviders, with support for MINIMAX_API_KEY, MINIMAX_CHAT_MODEL, MINIMAX_API_BASE, and MINIMAX_API_HEADERS environment variables. Default model is MiniMax-M2.7 and base URL is https://api.minimax.io/v1. Comprehensive unit and integration tests are included.
  • TypeScript Implementation Details: A MiniMaxChatModel extending VercelChatModel via @ai-sdk/openai and a MiniMaxClient extending BackendClient were implemented. The 'MiniMax' provider is registered in BackendProviders with a 'minimax' alias. Unit tests validate instantiation, environment variables, and provider registration.
  • Documentation and Examples: The docs/modules/backend.mdx file has been updated to include MiniMax in the supported providers table. Example usage for both Python and TypeScript is provided, demonstrating various functionalities like synchronous calls, streaming, structured output, and tool calling.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the MiniMax AI provider, adding new Python and TypeScript adapters, updating provider registration, and including example usage and tests. The review feedback highlights a missing test case in the TypeScript implementation for both MiniMaxClient and MiniMaxChatModel to verify error handling when the MINIMAX_API_KEY is not provided.

Comment on lines +20 to +46
describe("MiniMaxClient", () => {
const originalEnv = process.env;

beforeEach(() => {
process.env = { ...originalEnv };
});

afterEach(() => {
process.env = originalEnv;
});

it("should create client with explicit settings", () => {
const client = new MiniMaxClient({
apiKey: "test-key",
baseURL: "https://api.minimax.io/v1",
});
expect(client).toBeDefined();
expect(client.instance).toBeDefined();
});

it("should create client from env vars", () => {
process.env.MINIMAX_API_KEY = "test-key-from-env";
const client = new MiniMaxClient({});
expect(client).toBeDefined();
expect(client.instance).toBeDefined();
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The test suite for MiniMaxClient is missing a case to verify behavior when the API key is not provided. The Python implementation includes a test for this scenario, and it's good practice to ensure the TypeScript implementation also fails gracefully with a clear error.

Please add a test case to ensure that an error is thrown when MINIMAX_API_KEY is missing.

Example:

it("should throw an error if API key is missing", () => {
  delete process.env.MINIMAX_API_KEY;
  expect(() => new MiniMaxClient()).toThrow();
});

Comment on lines +48 to +96
describe("MiniMaxChatModel", () => {
const originalEnv = process.env;

beforeEach(() => {
process.env = { ...originalEnv };
process.env.MINIMAX_API_KEY = "test-api-key";
});

afterEach(() => {
process.env = originalEnv;
});

it("should instantiate with default model", () => {
const model = new MiniMaxChatModel();
expect(model).toBeInstanceOf(MiniMaxChatModel);
expect(model.modelId).toBe("MiniMax-M2.7");
});

it("should instantiate with custom model id", () => {
const model = new MiniMaxChatModel("MiniMax-M2.5");
expect(model).toBeInstanceOf(MiniMaxChatModel);
expect(model.modelId).toBe("MiniMax-M2.5");
});

it("should accept highspeed model", () => {
const model = new MiniMaxChatModel("MiniMax-M2.7-highspeed");
expect(model).toBeInstanceOf(MiniMaxChatModel);
expect(model.modelId).toBe("MiniMax-M2.7-highspeed");
});

it("should use env var for model id", () => {
process.env.MINIMAX_CHAT_MODEL = "MiniMax-M2.5-highspeed";
const model = new MiniMaxChatModel();
expect(model.modelId).toBe("MiniMax-M2.5-highspeed");
});

it("should accept custom parameters", () => {
const model = new MiniMaxChatModel("MiniMax-M2.7", { temperature: 0.5 });
expect(model).toBeInstanceOf(MiniMaxChatModel);
});

it("should accept custom client settings", () => {
const model = new MiniMaxChatModel("MiniMax-M2.7", {}, {
apiKey: "custom-key",
baseURL: "https://proxy.example.com/v1",
});
expect(model).toBeInstanceOf(MiniMaxChatModel);
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the MiniMaxClient, the tests for MiniMaxChatModel should include a case for a missing API key to ensure it fails as expected. This ensures consistent and robust error handling across the provider implementation.

Please add a test case to verify that instantiating MiniMaxChatModel without an API key throws an error.

Example:

it("should throw an error if API key is missing", () => {
  delete process.env.MINIMAX_API_KEY;
  expect(() => new MiniMaxChatModel()).toThrow();
});

Copy link
Copy Markdown
Contributor

@Tomas2D Tomas2D left a comment

Choose a reason for hiding this comment

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

Hello @octo-patch, thank you for the PR.

Before I merge it, please make the following changes:

  • Modify tests/examples/test_examples.py to run the the minimax test only if credentials are set
  • Modify tests/examples/examples.test.ts to run the the minimax test only if credentials are set

Add conditional exclusion for minimax provider examples in both Python
and TypeScript test suites, consistent with how other providers handle
missing credentials.
@octo-patch
Copy link
Copy Markdown
Author

Thanks @Tomas2D for the review!

I've made both changes:

  1. Python (): Added conditional exclusion for when is not set, following the same pattern used by other providers.

  2. TypeScript (): Added conditional exclusion for when is not set, consistent with the existing provider pattern.

This ensures the MiniMax examples only run in CI environments where the API key is configured.

@Tomas2D
Copy link
Copy Markdown
Contributor

Tomas2D commented Apr 8, 2026

All good. Can you please address the failing pipeline?

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 Python related functionality size:XL This PR changes 500-999 lines, ignoring generated files. typescript Typescript related functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants