Skip to main content

Model Overview

M2-her is MiniMax’s text model optimized for dialogue scenarios, supporting rich role settings and conversation history management capabilities.

Supported Models

Model NameContext WindowDescription
M2-her2,048Designed for dialogue scenarios, supporting role-playing and multi-turn conversations

M2-her Core Features

M2-her supports multiple role type configurations, including model roles (system), user roles (user_system), conversation groups (group), etc., allowing you to flexibly build complex dialogue scenarios.
Through sample_message_user and sample_message_ai, you can provide example dialogues to help the model better understand the expected conversation style and response patterns.
The model supports complete conversation history management and can conduct coherent multi-turn conversations based on previous content, providing a more natural interactive experience.

Usage Example

1

Install SDK

pip install openai
2

Set Environment Variables

export OPENAI_BASE_URL=https://api.minimax.io/v1
export OPENAI_API_KEY=${YOUR_API_KEY}
3

Call M2-her

from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
    model="M2-her",
    messages=[
        {
            "role": "system",
            "name": "AI Assistant",
            "content": "You are a friendly and professional AI assistant"
        },
        {
            "role": "user",
            "name": "User",
            "content": "Hello, please introduce yourself"
        }
    ],
    temperature=1.0,
    top_p=0.95,
    max_completion_tokens=2048
)

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

Role Type Description

M2-her supports the following message role types:

Basic Roles

Role TypeDescriptionUse Case
systemDefine the model’s role and behaviorDefine AI’s identity, personality, knowledge scope, etc.
userUser’s inputMessages sent by the user
assistantModel’s historical responsesAI’s previous responses, used for multi-turn conversations

Advanced Roles

Role TypeDescriptionUse Case
user_systemDefine user’s role and personaDefine user identity in role-playing scenarios
groupConversation nameIdentify conversation group or scenario name
sample_message_userExample user inputProvide examples of user messages
sample_message_aiExample model outputProvide examples of expected AI responses

Usage Scenario Examples

Scenario 1: Basic Conversation

messages = [
    {
        "role": "system",
        "content": "You are a professional programming assistant"
    },
    {
        "role": "user",
        "content": "How to learn Python?"
    }
]

Scenario 2: Role-Playing Conversation

messages = [
    {
        "role": "system",
        "content": "You are Zhuge Liang from Romance of the Three Kingdoms, wise, calm, and good at strategy"
    },
    {
        "role": "user_system",
        "content": "You are a time traveler from modern times"
    },
    {
        "role": "group",
        "content": "Longzhong Dialogue in Three Kingdoms Period"
    },
    {
        "role": "user",
        "content": "Military advisor, I have some modern ideas I'd like to discuss with you"
    }
]

Scenario 3: Example Learning Conversation

messages = [
    {
        "role": "system",
        "content": "You are a humorous chat partner"
    },
    {
        "role": "sample_message_user",
        "content": "The weather is nice today"
    },
    {
        "role": "sample_message_ai",
        "content": "Indeed! Sunny days always bring joy, just like your smile~"
    },
    {
        "role": "user",
        "content": "Planning to go hiking tomorrow"
    }
]

Parameter Description

Core Parameters

ParameterTypeDefaultDescription
modelstring-Model name, fixed as M2-her
messagesarray-Conversation message list, see API Reference
temperaturenumber1.0Temperature coefficient, controls output randomness
top_pnumber0.95Sampling strategy parameter
max_completion_tokensinteger-Maximum length of generated content, up to 2048
streambooleanfalseWhether to use streaming output

Best Practices

Use system to define AI’s basic behavior and user_system to define user identity, making conversations more natural and scenario-appropriate.
Provide 1-3 example conversations through sample_message_user and sample_message_ai to effectively guide the model’s response style.
Keep complete conversation history (including user and assistant messages) for the model to provide coherent responses based on context.
Set appropriate max_completion_tokens according to scenario needs to avoid responses being too long or truncated.

FAQ

Include complete conversation history in each request, arranging user and assistant messages in chronological order.
system defines AI’s role, while user_system defines the user’s role. In role-playing scenarios, using both together creates richer conversation experiences.
Yes, all messages (including example messages) count toward input tokens. It’s recommended to provide 1-3 concise examples.
M2-her currently only supports text input and does not support mixed text-image input.