All Products
Search
Document Center

Alibaba Cloud Model Studio:MiniMax

Last Updated:Sep 02, 2026

Panggil model MiniMax di Alibaba Cloud Model Studio.

PentingDokumen ini hanya berlaku untuk wilayah Tiongkok daratan. Untuk menggunakan model ini, dapatkan Kunci API dari wilayah Tiongkok daratan.

Mulai

Prasyarat: Buat Kunci API dan tetapkan sebagai Variabel lingkungan. Jika Anda memanggil model menggunakan SDK, instal SDK OpenAI atau DashScope.

Kompatibel dengan OpenAI

Python

Kode contoh

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Wilayah Tiongkok (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja Bailian Anda. URL bervariasi tergantung wilayah.
    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 = ""  # Rantai-pikiran lengkap
answer_content = ""     # Respons lengkap
is_answering = False    # Apakah respons telah dimulai

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

for chunk in completion:
    if chunk.choices:
        delta = chunk.choices[0].delta
        # Kumpulkan hanya konten rantai-pikiran
        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
        # Mulai respons saat konten tiba
        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

Respons

====================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?

Node.js

Kode contoh

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

// Inisialisasi klien OpenAI
const openai = new OpenAI({
    // Jika Anda belum menetapkan variabel lingkungan, ganti ini dengan Kunci API Alibaba Cloud Model Studio Anda: apiKey: "sk-xxx"
    apiKey: process.env.DASHSCOPE_API_KEY,
    // Wilayah Tiongkok (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja Bailian Anda. URL bervariasi tergantung wilayah.
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // Rantai-pikiran lengkap
let answerContent = ''; // Respons lengkap
let isAnswering = false; // Apakah respons telah dimulai

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

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

    console.log('\n' + '='.repeat(20) + 'Chain of thought' + '='.repeat(20) + '\n');

    for await (const chunk of stream) {
        if (chunk.choices?.length) {
            const delta = chunk.choices[0].delta;
            // Kumpulkan hanya konten rantai-pikiran
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // Mulai respons saat konten tiba
            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();

Respons

====================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?

HTTP

Kode contoh

curl

# Wilayah Tiongkok (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja Bailian Anda. URL bervariasi tergantung wilayah.
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-M2.5",
    "messages": [
        {
            "role": "user",
            "content": "Who are you?"
        }
    ]
}'

Respons

{
    "choices": [
        {
            "message": {
                "content": "Hello! I am MiniMax-M2.5, an AI assistant developed by MiniMax. I can help you answer questions, provide information, hold conversations, and complete various text-related tasks. How can I help you?",
                "reasoning_content": "The user asked \"Who are you?\".\n\nI should reply and introduce myself.",
                "role": "assistant"
            },
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null
        }
    ],
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 40,
        "completion_tokens": 72,
        "total_tokens": 112,
        "completion_tokens_details": {
            "reasoning_tokens": 26
        },
        "prompt_tokens_details": {
            "cached_tokens": 0
        }
    },
    "created": 1771944590,
    "system_fingerprint": null,
    "model": "MiniMax-M2.5",
    "id": "chatcmpl-b1277a9c-52da-9de7-988a-d5c063d83xxx"
}

DashScope

Python

Kode contoh

import os
from dashscope import Generation

# Inisialisasi parameter permintaan
messages = [{"role": "user", "content": "Who are you?"}]

completion = Generation.call(
    # Jika Anda belum menetapkan variabel lingkungan, ganti ini dengan Kunci API Alibaba Cloud Model Studio Anda: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model="MiniMax-M2.5",
    messages=messages,
    result_format="message",  # Tetapkan format hasil ke message
    stream=True,              # Aktifkan keluaran streaming
    incremental_output=True,  # Aktifkan keluaran inkremental
)

reasoning_content = ""  # Rantai-pikiran lengkap
answer_content = ""     # Respons lengkap
is_answering = False    # Apakah respons telah dimulai

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

for chunk in completion:
    message = chunk.output.choices[0].message

    # Kumpulkan hanya konten rantai-pikiran
    if message.reasoning_content:
        if not is_answering:
            print(message.reasoning_content, end="", flush=True)
        reasoning_content += message.reasoning_content

    # Mulai respons saat konten tiba
    if message.content:
        if not is_answering:
            print("\n" + "=" * 20 + "Full response" + "=" * 20 + "\n")
            is_answering = True
        print(message.content, end="", flush=True)
        answer_content += message.content

# Setelah loop selesai, reasoning_content dan answer_content berisi konten lengkap
# Anda dapat memprosesnya lebih lanjut sesuai kebutuhan
# print(f"\n\nFull chain of thought:\n{reasoning_content}")
# print(f"\nFull response:\n{answer_content}")

Respons

====================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?

Java

Kode contoh

// Versi SDK DashScope >= 2.19.4
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import io.reactivex.Flowable;
import java.lang.System;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);
    private static StringBuilder reasoningContent = new StringBuilder();
    private static StringBuilder finalContent = new StringBuilder();
    private static boolean isFirstPrint = true;

    private static void handleGenerationResult(GenerationResult message) {
        String reasoning = message.getOutput().getChoices().get(0).getMessage().getReasoningContent();
        String content = message.getOutput().getChoices().get(0).getMessage().getContent();

        if (reasoning != null && !reasoning.isEmpty()) {
            reasoningContent.append(reasoning);
            if (isFirstPrint) {
                System.out.println("====================Chain of thought====================");
                isFirstPrint = false;
            }
            System.out.print(reasoning);
        }

        if (content != null && !content.isEmpty()) {
            finalContent.append(content);
            if (!isFirstPrint) {
                System.out.println("\n====================Full response====================");
                isFirstPrint = true;
            }
            System.out.print(content);
        }
    }
    private static GenerationParam buildGenerationParam(Message userMsg) {
        return GenerationParam.builder()
                // Jika Anda belum menetapkan variabel lingkungan, ganti baris ini dengan: .apiKey("sk-xxx")
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("MiniMax-M2.5")
                .incrementalOutput(true)
                .resultFormat("message")
                .messages(Arrays.asList(userMsg))
                .build();
    }
    public static void streamCallWithMessage(Generation gen, Message userMsg)
            throws NoApiKeyException, ApiException, InputRequiredException {
        GenerationParam param = buildGenerationParam(userMsg);
        Flowable<GenerationResult> result = gen.streamCall(param);
        result.blockingForEach(message -> handleGenerationResult(message));
    }

    public static void main(String[] args) {
        try {
            Generation gen = new Generation();
            Message userMsg = Message.builder().role(Role.USER.getValue()).content("Who are you?").build();
            streamCallWithMessage(gen, userMsg);
            // Cetak hasil akhir
            // if (reasoningContent.length() > 0) {
            //     System.out.println("\n====================Full response====================");
            //     System.out.println(finalContent.toString());
            // }
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            logger.error("An exception occurred: {}", e.getMessage());
        }
        System.exit(0);
    }
}

Respons

====================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?

HTTP

Kode contoh

curl

# Wilayah Tiongkok (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja Bailian Anda. URL bervariasi tergantung wilayah.
curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "MiniMax-M2.5",
    "input":{
        "messages":[
            {
                "role": "user",
                "content": "Who are you?"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'

Respons

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "content": "Hello! I am MiniMax-M2.5, an AI assistant developed by MiniMax. I can help you answer questions, provide information, hold conversations, and complete various text-related tasks. How can I help you?",
                    "reasoning_content": "The user asked \"Who are you?\".\n\nI should reply and introduce myself. I should state that I am MiniMax-M2.5, an AI assistant developed by MiniMax.",
                    "role": "assistant"
                }
            }
        ]
    },
    "usage": {
        "input_tokens": 41,
        "output_tokens": 79,
        "output_tokens_details": {
            "reasoning_tokens": 39
        },
        "prompt_tokens_details": {
            "cached_tokens": 0
        },
        "total_tokens": 120
    },
    "request_id": "1bbd770e-564a-4601-83fc-3bf639423xxx"
}

Fitur lainnya

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.

Nilai parameter default

Model

temperature

top_p

presence_penalty

MiniMax-M2.5

1.0

0.95

0.0

Model dan penagihan

MiniMax-M2.5 unggul dalam pemrograman, tugas perkantoran, Ringkasan teks, dan berbagai pekerjaan lainnya, dengan kecepatan output yang tinggi. Model ini direkomendasikan untuk penggunaan umum.

Untuk informasi mengenai jendela konteks model dan harga, lihat Model yang direkomendasikan.

Penagihan didasarkan pada jumlah token input dan output.

Kode error

Jika pemanggilan model gagal dan mengembalikan pesan error, lihat pesan error untuk pemecahan masalah.