Instructions to use MiniMaxAI/MiniMax-M2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MiniMaxAI/MiniMax-M2.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MiniMaxAI/MiniMax-M2.5", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MiniMaxAI/MiniMax-M2.5", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("MiniMaxAI/MiniMax-M2.5", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MiniMaxAI/MiniMax-M2.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MiniMaxAI/MiniMax-M2.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MiniMaxAI/MiniMax-M2.5
- SGLang
How to use MiniMaxAI/MiniMax-M2.5 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MiniMaxAI/MiniMax-M2.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MiniMaxAI/MiniMax-M2.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MiniMaxAI/MiniMax-M2.5 with Docker Model Runner:
docker model run hf.co/MiniMaxAI/MiniMax-M2.5
File size: 14,644 Bytes
f1c68b2 8c436e5 134ae7c 8c436e5 f1c68b2 8c436e5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | {#- Portable JSON-object parse for tool_call.arguments. The transformers chat-template environment ships tojson but not fromjson, so OpenAI-style JSON string arguments crash on .items(). A raw-string dump would also skip the existing argument tags. Dict arguments pass through unchanged. -#}{%- macro _json_skip(ns) -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] in ' \t\n\r' -%}
{%- set ns.i = ns.i + 1 -%}
{%- else -%}{%- break -%}{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- macro _json_string(ns) -%}
{%- set HEX = dict([('0',0),('1',1),('2',2),('3',3),('4',4),('5',5),('6',6),('7',7),('8',8),('9',9),('a',10),('b',11),('c',12),('d',13),('e',14),('f',15),('A',10),('B',11),('C',12),('D',13),('E',14),('F',15)]) -%}
{%- set ESC = dict([('"', '"'), ('\\', '\\'), ('/', '/'), ('b', '\b'), ('f', '\f'), ('n', '\n'), ('r', '\r'), ('t', '\t')]) -%}
{%- set ns.i = ns.i + 1 -%}
{%- set ns.buf = '' -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- if ns.i >= (ns.s|length) -%}{{- raise_exception("tool_call.arguments: unterminated JSON string") -}}{%- endif -%}
{%- set c = ns.s[ns.i] -%}
{%- if c == '"' -%}
{%- set ns.i = ns.i + 1 -%}
{%- break -%}
{%- elif c == '\\' -%}
{%- set ns.i = ns.i + 1 -%}
{%- if ns.i >= (ns.s|length) -%}{{- raise_exception("tool_call.arguments: unterminated JSON escape") -}}{%- endif -%}
{%- set e = ns.s[ns.i] -%}
{%- if e == 'u' -%}
{%- set ns.i = ns.i + 1 -%}
{%- if ns.i + 4 > (ns.s|length) -%}{{- raise_exception("tool_call.arguments: truncated \\u escape") -}}{%- endif -%}
{%- set h0 = ns.s[ns.i] -%}{%- set h1 = ns.s[ns.i+1] -%}{%- set h2 = ns.s[ns.i+2] -%}{%- set h3 = ns.s[ns.i+3] -%}
{%- if h0 not in HEX or h1 not in HEX or h2 not in HEX or h3 not in HEX -%}{{- raise_exception("tool_call.arguments: invalid \\u escape") -}}{%- endif -%}
{%- set n = ((HEX[h0]*16 + HEX[h1])*16 + HEX[h2])*16 + HEX[h3] -%}
{%- set ns.buf = ns.buf + ("%c"|format(n)) -%}
{%- set ns.i = ns.i + 4 -%}
{%- elif e in ESC -%}
{%- set ns.buf = ns.buf + ESC[e] -%}
{%- set ns.i = ns.i + 1 -%}
{%- else -%}
{{- raise_exception("tool_call.arguments: invalid JSON escape") -}}
{%- endif -%}
{%- else -%}
{%- set ns.buf = ns.buf + c -%}
{%- set ns.i = ns.i + 1 -%}
{%- endif -%}
{%- endfor -%}
{%- set ns.val = ns.buf -%}
{%- endmacro -%}
{%- macro _json_number(ns) -%}
{%- set start = ns.i -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] == '-' -%}{%- set ns.i = ns.i + 1 -%}{%- endif -%}
{%- set ns.saw = false -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] in '0123456789' -%}
{%- set ns.i = ns.i + 1 -%}{%- set ns.saw = true -%}
{%- else -%}{%- break -%}{%- endif -%}
{%- endfor -%}
{%- if not ns.saw -%}{{- raise_exception("tool_call.arguments: invalid JSON number") -}}{%- endif -%}
{%- set ns.is_float = false -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] == '.' -%}
{%- set ns.is_float = true -%}{%- set ns.i = ns.i + 1 -%}{%- set ns.saw = false -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] in '0123456789' -%}
{%- set ns.i = ns.i + 1 -%}{%- set ns.saw = true -%}
{%- else -%}{%- break -%}{%- endif -%}
{%- endfor -%}
{%- if not ns.saw -%}{{- raise_exception("tool_call.arguments: invalid JSON number") -}}{%- endif -%}
{%- endif -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] in 'eE' -%}
{%- set ns.is_float = true -%}{%- set ns.i = ns.i + 1 -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] in '+-' -%}{%- set ns.i = ns.i + 1 -%}{%- endif -%}
{%- set ns.saw = false -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] in '0123456789' -%}
{%- set ns.i = ns.i + 1 -%}{%- set ns.saw = true -%}
{%- else -%}{%- break -%}{%- endif -%}
{%- endfor -%}
{%- if not ns.saw -%}{{- raise_exception("tool_call.arguments: invalid JSON number") -}}{%- endif -%}
{%- endif -%}
{%- set raw = ns.s[start:ns.i] -%}
{%- if ns.is_float -%}{%- set ns.val = raw|float -%}{%- else -%}{%- set ns.val = raw|int -%}{%- endif -%}
{%- endmacro -%}
{%- macro _json_object(ns) -%}
{%- set ns.i = ns.i + 1 -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] == '}' -%}
{%- set ns.i = ns.i + 1 -%}
{%- set ns.val = dict([]) -%}
{%- else -%}
{%- set loc = namespace(pairs=[], done=false) -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i >= (ns.s|length) or ns.s[ns.i] != '"' -%}{{- raise_exception("tool_call.arguments: JSON object key must be a string") -}}{%- endif -%}
{%- set _ = _json_string(ns) -%}
{%- set key = ns.val -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i >= (ns.s|length) or ns.s[ns.i] != ':' -%}{{- raise_exception("tool_call.arguments: expected ':' in JSON object") -}}{%- endif -%}
{%- set ns.i = ns.i + 1 -%}
{%- set _ = _json_value(ns) -%}
{%- set loc.pairs = loc.pairs + [(key, ns.val)] -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] == ',' -%}
{%- set ns.i = ns.i + 1 -%}
{%- elif ns.i < (ns.s|length) and ns.s[ns.i] == '}' -%}
{%- set ns.i = ns.i + 1 -%}
{%- set loc.done = true -%}
{%- break -%}
{%- else -%}
{{- raise_exception("tool_call.arguments: expected ',' or '}' in JSON object") -}}
{%- endif -%}
{%- endfor -%}
{%- if not loc.done -%}{{- raise_exception("tool_call.arguments: unterminated JSON object") -}}{%- endif -%}
{%- set ns.val = dict(loc.pairs) -%}
{%- endif -%}
{%- endmacro -%}
{%- macro _json_array(ns) -%}
{%- set ns.i = ns.i + 1 -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] == ']' -%}
{%- set ns.i = ns.i + 1 -%}
{%- set ns.val = [] -%}
{%- else -%}
{%- set loc = namespace(arr=[], done=false) -%}
{%- for _ in range((ns.s|length) - ns.i) -%}
{%- set _ = _json_value(ns) -%}
{%- set loc.arr = loc.arr + [ns.val] -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i < (ns.s|length) and ns.s[ns.i] == ',' -%}
{%- set ns.i = ns.i + 1 -%}
{%- elif ns.i < (ns.s|length) and ns.s[ns.i] == ']' -%}
{%- set ns.i = ns.i + 1 -%}
{%- set loc.done = true -%}
{%- break -%}
{%- else -%}
{{- raise_exception("tool_call.arguments: expected ',' or ']' in JSON array") -}}
{%- endif -%}
{%- endfor -%}
{%- if not loc.done -%}{{- raise_exception("tool_call.arguments: unterminated JSON array") -}}{%- endif -%}
{%- set ns.val = loc.arr -%}
{%- endif -%}
{%- endmacro -%}
{%- macro _json_value(ns) -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i >= (ns.s|length) -%}{{- raise_exception("tool_call.arguments: unexpected end of JSON") -}}{%- endif -%}
{%- set c = ns.s[ns.i] -%}
{%- if c == '"' -%}{%- set _ = _json_string(ns) -%}
{%- elif c == '{' -%}{%- set _ = _json_object(ns) -%}
{%- elif c == '[' -%}{%- set _ = _json_array(ns) -%}
{%- elif c == '-' or c in '0123456789' -%}{%- set _ = _json_number(ns) -%}
{%- elif ns.s[ns.i:ns.i+4] == 'true' -%}{%- set ns.val = true -%}{%- set ns.i = ns.i + 4 -%}
{%- elif ns.s[ns.i:ns.i+5] == 'false' -%}{%- set ns.val = false -%}{%- set ns.i = ns.i + 5 -%}
{%- elif ns.s[ns.i:ns.i+4] == 'null' -%}{%- set ns.val = none -%}{%- set ns.i = ns.i + 4 -%}
{%- else -%}{{- raise_exception("tool_call.arguments: invalid JSON value") -}}
{%- endif -%}
{%- endmacro -%}
{%- macro load_tool_args(arguments, out) -%}
{%- if arguments is mapping -%}
{%- set out.val = arguments -%}
{%- elif arguments is string -%}
{%- if (arguments|trim) in ['', 'null'] -%}
{%- set out.val = dict([]) -%}
{%- else -%}
{%- set ns = namespace(s=arguments, i=0, val=none, buf='', saw=false, is_float=false, pairs=[], arr=[]) -%}
{%- set _ = _json_value(ns) -%}
{%- set _ = _json_skip(ns) -%}
{%- if ns.i != (ns.s|length) -%}{{- raise_exception("tool_call.arguments: trailing data after JSON value") -}}{%- endif -%}
{%- if ns.val is mapping -%}
{%- set out.val = ns.val -%}
{%- else -%}
{{- raise_exception("tool_call.arguments: JSON string must be an object") -}}
{%- endif -%}
{%- endif -%}
{%- elif arguments is none -%}
{%- set out.val = dict([]) -%}
{%- else -%}
{{- raise_exception("tool_call.arguments must be a mapping or a JSON object string") -}}
{%- endif -%}
{%- endmacro -%}
{# ----------‑‑‑ special token variables ‑‑‑---------- #}
{%- set toolcall_begin_token = '<minimax:tool_call>' -%}
{%- set toolcall_end_token = '</minimax:tool_call>' -%}
{#- Tool Rendering Functions ============================================== -#}
{%- macro render_tool_namespace(namespace_name, tool_list) -%}
{%- for tool in tool_list -%}
<tool>{{ tool.function | tojson(ensure_ascii=False) }}</tool>
{% endfor -%}
{%- endmacro -%}
{%- macro visible_text(content) -%}
{%- if content is string -%}
{{ content }}
{%- elif content is iterable and content is not mapping -%}
{%- for item in content -%}
{%- if item is mapping and item.type == 'text' -%}
{{- item.text }}
{%- elif item is string -%}
{{- item }}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{- content }}
{%- endif -%}
{%- endmacro -%}
{#- System Message Construction ============================================ -#}
{%- macro build_system_message(system_message) -%}
{%- if system_message and system_message.content -%}
{{- visible_text(system_message.content) }}
{%- else -%}
{%- if model_identity is not defined -%}
{%- set model_identity = "You are a helpful assistant. Your name is MiniMax-M2.5 and is built by MiniMax." -%}
{%- endif -%}
{{- model_identity }}
{%- endif -%}
{#- Handle current_date -#}
{%- if system_message and system_message.current_date -%}
{{- '\n' ~ 'Current date: ' + system_message.current_date }}
{%- endif -%}
{#- Handle current_location -#}
{%- if system_message and system_message.current_location -%}
{{- '\n' ~ 'Current location: ' + system_message.current_location }}
{%- endif -%}
{%- endmacro -%}
{#- Main Template Logic ================================================= -#}
{#- Extract system message (only first message if it's system) -#}
{%- set system_message = none -%}
{%- set conversation_messages = messages -%}
{%- if messages and messages[0].role == "system" -%}
{%- set system_message = messages[0] -%}
{%- set conversation_messages = messages[1:] -%}
{%- endif -%}
{#- Get the last user message turn, for interleved thinking -#}
{%- set ns = namespace(last_user_index=-1) %}
{% for m in conversation_messages %}
{%- if m.role == 'user' %}
{% set ns.last_user_index = loop.index0 -%}
{%- endif %}
{%- endfor %}
{#- Render system message -#}
{{- ']~!b[' ~ ']~b]system' ~ '\n' }}
{{- build_system_message(system_message) }}
{#- Render tools if available -#}
{%- if tools -%}
{{- '\n\n' ~ '# Tools' ~ '\n' ~ 'You may call one or more tools to assist with the user query.\nHere are the tools available in JSONSchema format:' ~ '\n' }}
{{- '\n' ~ '<tools>' ~ '\n' }}
{{- render_tool_namespace("functions", tools) }}
{{- '</tools>' ~ '\n\n' }}
{{- 'When making tool calls, use XML format to invoke tools and pass parameters:' ~ '\n' }}
{{- '\n' ~ toolcall_begin_token }}
<invoke name="tool-name-1">
<parameter name="param-key-1">param-value-1</parameter>
<parameter name="param-key-2">param-value-2</parameter>
...
</invoke>
{{- '\n' ~ toolcall_end_token }}
{%- endif -%}
{{- '[e~[\n' }}
{#- Render messages -#}
{%- set last_tool_call = namespace(name=none) -%}
{%- for message in conversation_messages -%}
{%- if message.role == 'assistant' -%}
{#- Only render reasoning_content if no user message follows -#}
{{- ']~b]ai' ~ '\n' }}
{%- set reasoning_content = '' %}
{%- set content = visible_text(message.content) %}
{%- if message.reasoning_content is string %}
{%- set reasoning_content = message.reasoning_content %}
{%- else %}
{%- if '</think>' in content %}
{%- set reasoning_content = content.split('</think>')[0].strip('\n').split('<think>')[-1].strip('\n') %}
{%- set content = content.split('</think>')[-1].strip('\n') %}
{%- endif %}
{%- endif %}
{%- if reasoning_content and loop.index0 > ns.last_user_index -%}
{{- '<think>' ~ '\n' ~ reasoning_content ~ '\n' ~ '</think>' ~ '\n\n' }}
{%- endif -%}
{%- if content -%}
{{- content }}
{%- endif -%}
{%- if message.tool_calls -%}
{{- '\n' ~ toolcall_begin_token ~ '\n' }}
{%- for tool_call in message.tool_calls -%}
{%- if tool_call.function %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '<invoke name="' + tool_call.name + '">' }}
{% set _args_out = namespace(val=none) %}{% set _ = load_tool_args(tool_call.arguments, _args_out) %}{% set _args = _args_out.val %}
{%- for k, v in _args.items() %}
{{- '<parameter name="' + k + '">' }}
{{- v | tojson(ensure_ascii=False) if v is not string else v }}
{{- '</parameter>' }}
{% endfor %}
{{- '</invoke>' ~ '\n' }}
{%- endfor -%}
{{- toolcall_end_token}}
{%- set last_tool_call.name = message.tool_calls[-1].name -%}
{%- else -%}
{%- set last_tool_call.name = none -%}
{%- endif -%}
{{- '[e~[' ~ '\n' }}
{%- elif message.role == 'tool' -%}
{%- if last_tool_call.name is none -%}
{{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
{%- endif -%}
{%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
{{- ']~b]tool' }}
{%- endif -%}
{%- if message.content is string -%}
{{- '\n<response>' }}
{{- message.content }}
{{- '</response>' }}
{%- else -%}
{%- for tr in message.content -%}
{{- '\n<response>' }}
{{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
{{- '\n</response>' }}
{%- endfor -%}
{%- endif -%}
{%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
{{- '[e~[\n' -}}
{%- endif -%}
{%- elif message.role == 'user' -%}
{{- ']~b]user' ~ '\n' }}
{{- visible_text(message.content) }}
{{- '[e~[' ~ '\n' }}
{%- endif -%}
{%- endfor -%}
{#- Generation prompt -#}
{%- if add_generation_prompt -%}
{{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
{%- endif -%}
|