Skip to main content
Third-party model integration tutorial

MiniMax

Call MiniMax models on Alibaba Cloud Model Studio.

This document applies only to the Chinese mainland region. To use the model, get an API key from the Chinese mainland region.

Getting started

Prerequisites: Create an API key and set it as an environment variable. If you call the model using a SDK, install the OpenAI or DashScope SDK.
  • OpenAI compatible
  • DashScope
  • 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-M2.5",
    messages=[{"role": "user", "content": "Who are you?"}],
    stream=True,
)

reasoning_content = ""  # Full chain-of-thought
answer_content = ""     # Full response
is_answering = False    # Whether response has started

print("\n" + "=" * 20 + "Chain of thought" + "=" * 20 + "\n")

for chunk in completion:
    if chunk.choices:
        delta = chunk.choices[0].delta
        # Collect only chain-of-thought 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
        # Start response when content arrives
        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

====================Chain of thought====================

The user asked "Who are you?".

I should reply and introduce myself as an AI assistant.
====================Full response====================

Hello! I am MiniMax-M2.5, an AI assistant. I can help you answer questions, provide information, hold conversations, and more. How can I help you?

Other features

Model

Multi-turn conversation

Deep thinking

Function calling

Structured output

Web search

Partial mode

Context Cache

MiniMax-M2.5

Supported

Supported

Supported

Not supported

Supported

Not supported

Supported

Implicit cache only.

Default parameter values

Model

temperature

top_p

presence_penalty

MiniMax-M2.5

1.0

0.95

0.0

Models and billing

MiniMax-M2.5 excels at coding, office work, text summarization, and other tasks, with fast output speed. We recommend using this model. For model context window and pricing information, see Recommended models. Billing is based on the number of input and output tokens.

Error codes

If a model call fails and returns an error message, see error messages for troubleshooting.
Token Plan
Model Playground
  • Music generation
Statistics and Monitoring
Support