MiniMax

Updated at:

This document explains how to call the model inference service provided by MiniMax through Alibaba Cloud Model Studio.

ImportantThis document applies only to the China (Beijing) region. To use the models, you must obtain an API key from the China (Beijing) region.

Service activation

  1. Go to the Model Studio console, search for MiniMax, find the MiniMax model card, and click Activate Now.
  2. In the pop-up dialog box, confirm the activation and authorization.

After completing these steps, you can call the MiniMax model services.

Quick start

Before you begin, ensure you have obtained an API key and configured it as an environment variable. If you call the API using an SDK, you must also install the SDK.

OpenAI compatible

Python

Sample code

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="MiniMax/MiniMax-M2.7",
    messages=[{"role": "user", "content": "Who are you?"}],
    stream=True,
)

reasoning_content = ""  # Full reasoning process
answer_content = ""     # Full response
is_answering = False    # Flag to indicate if the response phase has started

print("\n" + "=" * 20 + "Reasoning Process" + "=" * 20 + "\n")

for chunk in completion:
    if chunk.choices:
        delta = chunk.choices[0].delta
        # Collect only the reasoning content
        if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
            if not is_answering:
                print(delta.reasoning_content, end="", flush=True)
            reasoning_content += delta.reasoning_content
        # When content is received, start building the response
        if hasattr(delta, "content") and delta.content:
            if not is_answering:
                print("\n" + "=" * 20 + "Full Response" + "=" * 20 + "\n")
                is_answering = True
            print(delta.content, end="", flush=True)
            answer_content += delta.content

Response

====================Reasoning Process====================

The user is asking who I am. According to the system prompt, I should respond as "MiniMax-M2.7" and mention that I was developed by MiniMax.

This is a simple self-introduction question, so I should answer it concisely.

====================Full Response====================

Hello! I am **MiniMax-M2.7**, an AI assistant developed by **MiniMax**.

I can help you with various tasks such as answering questions, providing information, and engaging in conversation. How can I assist you today?

Node.js

Sample code

import OpenAI from "openai";
import process from 'process';

// Initialize the OpenAI client
const openai = new OpenAI({
    // If the environment variable is not set, provide your Alibaba Cloud Model Studio API key directly. For example: apiKey: "sk-xxx"
    apiKey: process.env.DASHSCOPE_API_KEY,
    // China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // Full reasoning process
let answerContent = ''; // Full response
let isAnswering = false; // Flag to indicate if the response phase has started

async function main() {
    const messages = [{ role: 'user', content: 'Who are you?' }];

    const stream = await openai.chat.completions.create({
        model: 'MiniMax/MiniMax-M2.7',
        messages,
        stream: true,
    });

    console.log('\n' + '='.repeat(20) + 'Reasoning Process' + '='.repeat(20) + '\n');

    for await (const chunk of stream) {
        if (chunk.choices?.length) {
            const delta = chunk.choices[0].delta;
            // Collect only the reasoning content
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // When content is received, start building the response
            if (delta.content !== undefined && delta.content) {
                if (!isAnswering) {
                    console.log('\n' + '='.repeat(20) + 'Full Response' + '='.repeat(20) + '\n');
                    isAnswering = true;
                }
                process.stdout.write(delta.content);
                answerContent += delta.content;
            }
        }
    }
}

main();

Response

====================Reasoning Process====================

The user is asking who I am. According to the system prompt, I should respond as "MiniMax-M2.7" and mention that I was developed by MiniMax.

This is a simple self-introduction question, so I should answer it concisely.

====================Full Response====================

Hello! I am **MiniMax-M2.7**, an AI assistant developed by **MiniMax**.

I can help you with various tasks such as answering questions, providing information, and engaging in conversation. How can I assist you today?

HTTP

Sample code

curl

# China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "MiniMax/MiniMax-M2.7",
    "messages": [
        {
            "role": "user",
            "content": "Who are you?"
        }
    ]
}'

Response

{
    "choices": [
        {
            "message": {
                "content": "\n\nHello! I am an AI assistant developed by MiniMax. My name is MiniMax-M2.7.\n\nI can help you with a variety of tasks, such as answering questions, providing information, engaging in conversation, assisting with writing, and analyzing problems. How can I help you?",
                "reasoning_content": "The user asked 'Who are you?'.\n\nI should introduce myself as an AI assistant.\n\nLet me write a brief self-introduction.",
                "role": "assistant"
            },
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null
        }
    ],
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 40,
        "completion_tokens": 84,
        "total_tokens": 124,
        "completion_tokens_details": {
            "reasoning_tokens": 36
        }
    },
    "created": 1769161313,
    "system_fingerprint": null,
    "model": "MiniMax/MiniMax-M2.7",
    "id": "chatcmpl-30d4de0f-92fe-93d2-a1bf-e8153ae937df"
}

Differences between MiniMax-M3.1-Flash and MiniMax-M3

CapabilityMiniMax/MiniMax-M3.1-FlashMiniMax/MiniMax-M3
Thinking modeAlways enabled and cannot be disabledAdaptive thinking by default; can be disabled
Thinking effortSupports low, medium, high, xhigh, and max; defaults to maxDoes not support reasoning_effort
Thinking outputAlways returned separately in reasoning_content; does not support setting reasoning_split to falseReturned separately in reasoning_content when reasoning_split is true, or inside content with <think> tags when it is false
Context window1M tokens1M tokens
Image and video inputSupportedSupported
Prompt cachingSupportedSupported
Default rate limits200 RPM and 10,000,000 TPM500 RPM and 20,000,000 TPM

The service may also enforce per-second limits based on RPS (RPM/60) and TPS (TPM/60). For more information, see Rate limits.

The following example calls MiniMax/MiniMax-M3.1-Flash and sets the thinking effort using reasoning_effort:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

response = client.chat.completions.create(
    model="MiniMax/MiniMax-M3.1-Flash",
    reasoning_effort="max",
    messages=[{"role": "user", "content": "Analyze the main trade-offs of a microservices architecture."}],
)

print(response.choices[0].message.reasoning_content)
print(response.choices[0].message.content)

Migrate from MiniMax-M3

If you only change the model ID to MiniMax/MiniMax-M3.1-Flash, also account for the following differences:

  • Remove thinking: {"type":"disabled"} or reasoning_effort: "none". MiniMax-M3.1-Flash cannot disable thinking and returns an HTTP 400 error for these settings.
  • Do not set reasoning_split to false. When sharing calling code between MiniMax-M3 and MiniMax-M3.1-Flash, set it to true and consistently read thinking content from reasoning_content. With the OpenAI Python SDK, pass extra_body={"reasoning_split": True}. For HTTP requests, place it at the top level of the request body. The thinking parameter uses the same placement.
  • Read thinking content from reasoning_content, not reasoning_details. To remain compatible with MiniMax-M3, first check whether reasoning_content exists. MiniMax-M3.1-Flash does not require parsing <think> tags from content.
  • Reserve enough output length. Thinking tokens count toward max_tokens or max_completion_tokens. If the limit is too small, finish_reason can be length while the answer is empty.
  • In multi-turn function calling, append the complete assistant message, including reasoning_content and tool_calls, to the conversation history to preserve thinking continuity.

Multimodal examples

MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3 support text, image, and video input and produce text output.

Important

  • MiniMax/MiniMax-M3.1-Flash always performs thinking. Use reasoning_effort to adjust the thinking effort.
  • MiniMax/MiniMax-M3 uses the thinking parameter. The default value is adaptive; set it to disabled to disable thinking.

Image understanding

MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3 can recognize and analyze one or more images. The following example uses MiniMax/MiniMax-M3. To use MiniMax/MiniMax-M3.1-Flash, change the model ID and optionally set reasoning_effort.

OpenAI compatible

Notethinking is not a standard OpenAI parameter. In the OpenAI Python SDK, pass it through extra_body. In the Node.js SDK, pass it as a top-level parameter.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

# Single image example (with adaptive thinking mode)
completion = client.chat.completions.create(
    model="MiniMax/MiniMax-M3",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is depicted in the image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                }
            ]
        }
    ],
    extra_body={"thinking": {"type": "adaptive"}}  # Adaptive thinking mode
)

# Output reasoning process
if hasattr(completion.choices[0].message, 'reasoning_content') and completion.choices[0].message.reasoning_content:
    print("\n" + "=" * 20 + "Reasoning Process" + "=" * 20 + "\n")
    print(completion.choices[0].message.reasoning_content)

# Output response
print("\n" + "=" * 20 + "Full Response" + "=" * 20 + "\n")
print(completion.choices[0].message.content)

# Multi-image example (with thinking mode enabled, uncomment to use)
# completion = client.chat.completions.create(
#     model="MiniMax/MiniMax-M3",
#     messages=[
#         {
#             "role": "user",
#             "content": [
#                 {"type": "text", "text": "What do these images depict?"},
#                 {
#                     "type": "image_url",
#                     "image_url": {"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"}
#                 },
#                 {
#                     "type": "image_url",
#                     "image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"}
#                 }
#             ]
#         }
#     ],
#     extra_body={"thinking": {"type": "adaptive"}}
# )
#
# # Output reasoning process and response
# if hasattr(completion.choices[0].message, 'reasoning_content') and completion.choices[0].message.reasoning_content:
#     print("\nReasoning process:\n" + completion.choices[0].message.reasoning_content)
# print("\nFull response:\n" + completion.choices[0].message.content)

Node.js

import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

// Single image example (with adaptive thinking mode)
const completion = await openai.chat.completions.create({
    model: 'MiniMax/MiniMax-M3',
    messages: [
        {
            role: 'user',
            content: [
                { type: 'text', text: 'What is depicted in the image?' },
                {
                    type: 'image_url',
                    image_url: {
                        url: 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg'
                    }
                }
            ]
        }
    ],
    thinking: {"type": "adaptive"}  // Adaptive thinking mode
});

// Output reasoning process
if (completion.choices[0].message.reasoning_content) {
    console.log('\n' + '='.repeat(20) + 'Reasoning Process' + '='.repeat(20) + '\n');
    console.log(completion.choices[0].message.reasoning_content);
}

// Output response
console.log('\n' + '='.repeat(20) + 'Full Response' + '='.repeat(20) + '\n');
console.log(completion.choices[0].message.content);

// Multi-image example (with thinking mode enabled, uncomment to use)
// const multiCompletion = await openai.chat.completions.create({
//     model: 'MiniMax/MiniMax-M3',
//     messages: [
//         {
//             role: 'user',
//             content: [
//                 { type: 'text', text: 'What do these images depict?' },
//                 {
//                     type: 'image_url',
//                     image_url: { url: 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg' }
//                 },
//                 {
//                     type: 'image_url',
//                     image_url: { url: 'https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png' }
//                 }
//             ]
//         }
//     ],
//     thinking: {"type": "adaptive"}
// });
//
// // Output reasoning process and response
// if (multiCompletion.choices[0].message.reasoning_content) {
//     console.log('\nReasoning process:\n' + multiCompletion.choices[0].message.reasoning_content);
// }
// console.log('\nFull response:\n' + multiCompletion.choices[0].message.content);

HTTP

curl

# China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "MiniMax/MiniMax-M3",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What is depicted in the image?"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                }
            ]
        }
    ],
    "thinking": {"type": "adaptive"}
}'

# Multi-image example (uncomment to use)
# China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
# curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
# -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
# -H "Content-Type: application/json" \
# -d '{
#     "model": "MiniMax/MiniMax-M3",
#     "messages": [
#         {
#             "role": "user",
#             "content": [
#                 {
#                     "type": "text",
#                     "text": "What do these images depict?"
#                 },
#                 {
#                     "type": "image_url",
#                     "image_url": {
#                         "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
#                     }
#                 },
#                 {
#                     "type": "image_url",
#                     "image_url": {
#                         "url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"
#                     }
#                 }
#             ]
#         }
#     ],
#     "thinking": {"type": "adaptive"}
# }'

Video understanding

OpenAI compatible

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="MiniMax/MiniMax-M3",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video_url",
                    "video_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                    },
                    "fps": 2
                },
                {
                    "type": "text",
                    "text": "What is the content of this video?"
                }
            ]
        }
    ]
)

print(completion.choices[0].message.content)

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.chat.completions.create({
        model: "MiniMax/MiniMax-M3",
        messages: [
            {
                role: "user",
                content: [
                    {
                        type: "video_url",
                        video_url: {
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                        },
                        fps: 2
                    },
                    {
                        type: "text",
                        text: "What is the content of this video?"
                    }
                ]
            }
        ]
    });

    console.log(response.choices[0].message.content);
}

main();

HTTP

curl

# China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "MiniMax/MiniMax-M3",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "video_url",
            "video_url": {
              "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
            },
            "fps": 2
          },
          {
            "type": "text",
            "text": "What is the content of this video?"
          }
        ]
      }
    ]
  }'

File limits

Image files

  • Input methods: Public URLs and Base64 encoding are supported.
  • Supported image formats: PNG, JPEG, WEBP, GIF
  • Image size: Each image must not exceed 10 MB.

Video files

  • Video size and duration: The video file must not exceed 50 MB, and the duration must not exceed 30 minutes.
  • Video formats: MP4, AVI, MOV, MKV.
  • Audio understanding: Audio tracks in video files are not supported.

Other features

MiniMax/MiniMax-M3.1-Flash supports multi-turn conversations, deep thinking, function calling, and context caching.

ModelMulti-round conversationDeep thinkingFunction callingStructured outputWeb searchPrefix-based completionContext caching
MiniMax/MiniMax-M3.1-FlashSupportedSupportedSupportedNot supportedNot supportedNot supportedSupported
MiniMax/MiniMax-M3SupportedSupportedSupportedNot supportedNot supportedNot supportedSupported
MiniMax/MiniMax-M2.7SupportedSupportedSupportedNot supportedNot supportedNot supportedSupported
MiniMax/MiniMax-M2.5SupportedSupportedSupportedNot supportedNot supportedNot supportedSupported

The context caching is implicit and enabled automatically. It differs from the implicit caching service of Alibaba Cloud Model Studio as follows:

  • The cached input token price is 10% of the regular input price for MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M2.5, and 20% for MiniMax/MiniMax-M3 and MiniMax/MiniMax-M2.7. For MiniMax/MiniMax-M3, MiniMax/MiniMax-M2.7, and MiniMax/MiniMax-M2.5, the minimum cacheable input is 512 tokens, compared with 1,024 tokens for Model Studio models.
  • For MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3, n supports only 1, so each request can generate only one completion.
  • MiniMax/MiniMax-M3.1-Flash does not support stop. Passing this parameter does not truncate the output at the specified stop sequence. The request may still succeed and return finish_reason: "stop", but this does not mean that the specified stop sequence took effect.
  • MiniMax/MiniMax-M3.1-Flash does not support using parallel_tool_calls to control whether tool calls are parallel. Setting it to false does not guarantee sequential tool calls, and the model may still return multiple tool_calls in one turn.
  • For MiniMax/MiniMax-M3.1-Flash, tool_choice supports only auto. Other values may return an error or have no effect. For example, specifying a named function does not guarantee that the model calls that function. For MiniMax/MiniMax-M3, tool_choice supports only none and auto.

Default parameter values

The following parameters cannot be modified.

Modeltemperaturetop_p
MiniMax/MiniMax-M3.1-Flash1.00.95
MiniMax/MiniMax-M31.00.95
MiniMax/MiniMax-M2.71.00.9
MiniMax/MiniMax-M2.51.00.9

Model list and billing

MiniMax-M3.1-Flash is the latest multimodal reasoning model. It supports a 1-million-token context window, image and video understanding, and five thinking-effort levels. It is recommended for complex agentic tasks, software development, and cybersecurity. MiniMax-M3 can disable thinking and is suitable for scenarios that switch between thinking and non-thinking modes. MiniMax-M2.7 excels at programming and text summarization.

For information about model context length and pricing, see the Model Studio console.

Billing is based on the number of input and output tokens.

Error code

If a model call fails and returns an error message, see Error messages to resolve the issue.