Skip to main content

MiniMax

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

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
  • Node.js
  • HTTP

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?

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.
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
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
  • Node.js
  • HTTP
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)

Video understanding

  • OpenAI compatible
  • Python
  • Node.js
  • HTTP
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)

File limits

  • Image files
  • Video 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.

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

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. The minimum number of cached tokens is 512, compared to 1024 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

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.
Token Plan
Model Playground
Fine-tuning
Model Compression
Statistics and Monitoring
Support