MiniMax

Updated at:

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

Important

This 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"
}

Multimodal examples

MiniMax/MiniMax-M3 supports not only text-based conversations but also powerful multimodal understanding capabilities. This section describes how to enable the model to understand image and video content.

Important

MiniMax-M3 uses the thinking parameter to control the thinking mode. The default mode is adaptive (adaptive):

  • Non-thinking mode (thinking.type: "disabled"): The model outputs the result directly without a reasoning process.

  • Adaptive mode (thinking.type: "adaptive" or not set): The model autonomously determines whether thinking is needed and outputs a reasoning process (reasoning_content) when applicable.

Image understanding

The image understanding feature enables the MiniMax-M3 model to recognize and analyze image content. You can pass in one or more images.

OpenAI compatible

Note

thinking 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

Model

Multi-round conversation

Deep thinking

Function Calling

Structured output

Web search

Prefix-based completion

Context caching

MiniMax/MiniMax-M3

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

MiniMax/MiniMax-M2.7

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

MiniMax/MiniMax-M2.5

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

MiniMax/MiniMax-M2.1

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

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

  • The discount for cached input tokens is 20% for MiniMax/MiniMax-M3 and MiniMax/MiniMax-M2.7, and 10% for MiniMax/MiniMax-M2.5 and MiniMax/MiniMax-M2.1. The minimum number of cached tokens is 512, compared to 256 for Model Studio.

  • MiniMax/MiniMax-M3 does not support the n parameter (only one completion can be generated per request), and tool_choice supports only none and auto.

Default parameter values

The following parameters cannot be modified.

Model

temperature

top_p

MiniMax/MiniMax-M3

1.0

0.95

MiniMax/MiniMax-M2.7

1.0

0.9

MiniMax/MiniMax-M2.5

1.0

0.9

MiniMax/MiniMax-M2.1

1.0

0.9

Model list and billing

MiniMax-M3 is the latest multimodal reasoning model that supports image and video understanding. This model is recommended. MiniMax-M2.7 excels at tasks such as 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.