MiniMax M4 API: what it is and how to call it
What MiniMax M4 is built to do, how its 1M-token context and adaptive thinking work, and how to call minimax-m4 on DreamTo with tools, JSON, images and prices.

On this page
MiniMax released M4 on 3 December 2026 and calls it "the most intelligent model we have ever trained". It is a natively multimodal mixture-of-experts model with a 1M-token context window, aimed at coding and at long agent runs that call tools hundreds or thousands of times. On DreamTo it is available as minimax-m4 through the OpenAI Chat Completions protocol.
This guide starts with what MiniMax says M4 is and what it was built for, then moves to what that means for real workloads, and then to the practical part: a first request in curl, Python and JavaScript, thinking and effort levels, the tool-use loop, JSON output, image input, long-context cost planning and prices. Everything about the model comes from MiniMax's own launch post and API documentation; the parts about calling it come from DreamTo. Prices are quoted as of December 2026, and the live numbers are on the prices page.
What MiniMax M4 is#
According to the launch post, M4 has 2.74 trillion parameters in total, of which about 66 billion are active for each token. That is the mixture-of-experts idea: the model is very large, but each token only passes through a small slice of it, so the cost of a response tracks the active 66 billion rather than the full 2.74 trillion. It is natively multimodal, meaning image understanding is part of the model rather than a separate add-on, and it has a 1M-token context window.
MiniMax positions M4 at the top of its own range and says that, across most tasks it looked at, it stands at the intelligence frontier of Chinese and open-source models, including coding, domain knowledge, chip design, finance, design and computer use. It is just as direct about the limit of that claim, which is covered in the limitations section below.
| Property | Value |
|---|---|
| Model ID on DreamTo | minimax-m4 |
| Parameters | 2.74T total, 66B active per token (MiniMax) |
| Context window | 1M tokens |
| Input | Text and images |
| Thinking | Always on, adaptive; depth set with reasoning_effort |
| Structured output | JSON output (response_format) |
| Tools | Function calling with tools and tool_choice |
| Endpoint | POST /v1/chat/completions |
The model page is at /minimax-m4, and you can try prompts without writing code in the playground.
How it stays fast with a 1M-token window#
A long context is only useful if it is affordable to serve. The launch post spends much of its space on this, and the ideas are easy to state without the maths.
Every token a model has read leaves behind a cache of intermediate values, the KV cache, which the model consults while it writes each new token. With a very long prompt that cache grows until it no longer fits in the memory of the accelerator. MiniMax's answer has two parts. The first is MSA2 (MiniMax Sparse Attention 2), used in all 68 attention layers. It lets each new token look at selected blocks of the history rather than all of it, and it shares keys and values to shrink the cache. MiniMax says this cuts the per-token KV cache to a quarter of the previous version and raises prefill throughput by 4.48 times and decode throughput by 8 times. The second is MFlashKV, which moves most of the cache to SSD storage and keeps only the frequently used blocks in fast memory, loading the rest ahead of time so the model does not wait for it.
You do not configure any of this. What it explains is the pricing: M4 is billed at one flat per-token rate across the whole 1M window rather than a surcharge for long prompts. MiniMax also says it ran M4 on domestic Chinese chips, naming Huawei's Ascend 950DT and T-Head's Zhenwu M890, and describes memory capacity as the main constraint that shaped the design.
How it was trained#
MiniMax describes a reinforcement learning (RL) heavy post-training stage. The RL run used compute equal to 20% of pre-training compute, and MiniMax says it plans to raise that share to 50% in future versions. Instead of training one generalist directly, the team trained 28 domain specialist models and merged them into a single model, using an algorithm called CISPO for stable training at scale. MiniMax says RL raised the ceiling well beyond a supervised fine-tuning baseline, particularly in specialised domains and long-horizon tasks, and that domain experts took part in building some of the specialists.
One more detail from the post: early versions of M4 were used to help train M4. About 15% of post-training R&D compute went to early M4 versions building RL data, running infrastructure work and monitoring training runs, and MiniMax says that share keeps growing. Treat this as MiniMax's description of its process, not as something you can observe from the API.
What MiniMax built it to do#
Across the launch post and the API documentation, the stated focus is consistent: long-horizon coding and agentic work, meaning tasks where the model plans, calls tools, reads the results, fixes its own mistakes and keeps going for many steps. The 1M context window serves that goal, because an agent that reads files, logs and command output fills a window quickly.
MiniMax's showcases are the best evidence of what it means by long-horizon. These are MiniMax's own examples and have not been independently checked:
- A browser from scratch. In a 24-hour window and over 4,000 tool calls, M4 produced a graphical web browser of roughly 120,000 lines of Rust with no existing engine underneath, including a 32,000-line JavaScript engine with no dependencies. MiniMax reports it scores 100 out of 100 on the Acid3 browser test and runs React 18 and Redux applications.
- Code to everything. Animations, 3D models, games and websites generated through code and tools such as Blender, CAD software, Three.js and WebGL.
- Short films written as code. Videos of 30 to 64 seconds rendered frame by frame by programs, including scenes with 100,000 particles forming a portrait.
- Games in Unreal Engine 5. A first-person shooter and a racing game with an 8 km course and AI opponents.
- 3D and CAD modelling. A robot dog assembled from over 3,000 parts, and a cathedral modelled with 4,800 lines of Blender script.
- Interactive websites. A 68-story tower built from 19,000 lines of code, and a walkable campus built from about 4.5 million Gaussian splats.
The only benchmark number in the launch post's text is Posttrain Bench v1.2, where MiniMax reports 38.2 and describes M4 as steadily approaching proprietary frontier models. The other benchmark tables on the page are images, so this article does not repeat them.
What this means for real workloads#
Showcases are chosen to impress, so read them for the shape of the work rather than the headline. Four kinds of workload follow from them.
Coding agents. The browser example is a single task made of thousands of small steps: write a module, compile, read the error, fix it, run the test. That is the loop an editor agent runs, and it is why M4 is a natural fit behind tools such as Cursor, Cline, Codex or OpenCode. Use DreamTo models in Cursor, Cline, Codex and OpenCode covers connecting them to DreamTo.
Long-horizon tool use. The practical lesson from 4,000 tool calls is that the conversation grows large, so the cost of repeated context matters more than the price of any single answer. The sections on the tool loop and on cost planning below deal with that.
Long documents and codebases. With 1M tokens you can put a contract bundle, a quarterly report set or a mid-sized repository into one request and ask questions that span it. Ask for answers that cite the section they come from, and check the citations; a long window does not remove the need to verify.
Image understanding. Because the model is natively multimodal, screenshots, charts and diagrams can sit in the same request as text. A good use is design or UI review: send the screenshot with a written expectation and ask the model to list what it sees, what differs and what it cannot verify.
Make your first request#
Create an API key in the DreamTo console; authentication covers how keys work. The key goes in the Authorization: Bearer header, and the base URL is https://api.dreamto.ai.
export DREAMTO_API_KEY="your-key-here"curl "https://api.dreamto.ai/v1/chat/completions" \ -H "Authorization: Bearer $DREAMTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "minimax-m4", "messages": [ {"role": "system", "content": "You are a rigorous assistant."}, {"role": "user", "content": "Explain what a race condition is in three sentences."} ], "max_tokens": 4096 }'The reply is a chat.completion object. The answer is in choices[0].message.content, the model's reasoning in choices[0].message.reasoning_content, the stop reason in choices[0].finish_reason, and token counts in usage.
Python#
The Chat Completions docs say the OpenAI SDKs connect by changing base_url. For the SDKs the base URL ends in /v1.
import osfrom openai import OpenAIclient = OpenAI( base_url="https://api.dreamto.ai/v1", api_key=os.environ["DREAMTO_API_KEY"],)completion = client.chat.completions.create( model="minimax-m4", messages=[ {"role": "system", "content": "You are a rigorous assistant."}, {"role": "user", "content": "Explain what a race condition is in three sentences."}, ], max_tokens=4096,)print(completion.choices[0].message.content)print(completion.usage)JavaScript#
import OpenAI from "openai";const client = new OpenAI({ baseURL: "https://api.dreamto.ai/v1", apiKey: process.env.DREAMTO_API_KEY,});const completion = await client.chat.completions.create({ model: "minimax-m4", messages: [ { role: "system", content: "You are a rigorous assistant." }, { role: "user", content: "Explain what a race condition is in three sentences." }, ], max_tokens: 4096,});console.log(completion.choices[0].message.content);Request parameters#
Only model and messages are required.
| Parameter | Type | What it does |
|---|---|---|
model | string | minimax-m4 |
messages | array | The conversation, as role and content objects |
temperature | number | Randomness (see the note below) |
top_p | number | Nucleus sampling threshold (see the note below) |
max_tokens | integer | Caps the length of this response, reasoning included |
stop | array | Strings that stop generation |
stream | boolean | SSE streaming; default false |
stream_options | object | For example {"include_usage": true} |
reasoning_effort | enum | low, medium, high, xhigh or max |
response_format | object | For example {"type": "json_object"} |
tools | array | Function calling definitions |
tool_choice | enum | none or auto |
MiniMax's documentation says M4 fixes temperature at 1 and top_p at 0.95 and ignores other values, so do not build a workflow that relies on tuning them. An unsupported parameter is answered with a 400. When that happens, fix the request as error.message says and retry.
Thinking and effort levels#
M4 thinks before every answer and decides how long to think from the task. You cannot switch thinking off: MiniMax's documentation says a request with thinking disabled is rejected with a 400 because the model requires adaptive thinking, and a request with thinking set to {"type": "disabled"} is rejected on DreamTo too. What you can set is how much effort it spends, with reasoning_effort:
completion = client.chat.completions.create( model="minimax-m4", messages=[{"role": "user", "content": "Find the bug: for i in range(len(xs)): xs.pop(i)"}], max_tokens=8192, reasoning_effort="high",)print(completion.choices[0].message.content)print(completion.usage.completion_tokens_details.reasoning_tokens)The five levels are low, medium, high, xhigh and max. MiniMax documents max as the default when you leave the field out, and says higher levels think more, write more output tokens and take longer. Reasoning tokens are billed as output and count toward max_tokens. If the limit is too tight, the response can end with finish_reason set to length before any answer text, so leave room.
Because the default is the most expensive level, set the effort deliberately instead of accepting it:
| Effort | Reach for it when |
|---|---|
low | Routine replies, classification, extraction, short edits, anything a person would answer without much thought |
medium | Everyday coding questions, summaries of long text, tool steps with clear instructions |
high | Debugging, multi-file changes, planning a task before executing it |
xhigh or max | The hard cases: a step that keeps failing at lower effort, subtle bugs, research-style questions, the first planning step of a long agent run |
A practical approach is to start at low or medium, compare reasoning_tokens in usage against how often the answers are right, and raise the effort only for the steps that fail. In an agent you can even vary it per step: plan at high, execute simple tool calls at low.
The reasoning text arrives in reasoning_content, separate from content. Treat it as working notes for debugging, not as output to show users or to parse.
Streaming#
Add "stream": true and the reply arrives as server-sent events, ending with data: [DONE]. With stream_options set to {"include_usage": true}, one extra chunk before [DONE] carries the usage for the whole request and an empty choices array.
stream = client.chat.completions.create( model="minimax-m4", messages=[{"role": "user", "content": "Write a four-line poem about autumn."}], stream=True, stream_options={"include_usage": True},)for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True)The loop checks chunk.choices before reading the delta because the usage chunk has no choices. The error docs add one more case: if a streaming request fails after streaming has started, the error appears inside the stream and the HTTP status stays 200. Streaming matters more with M4 than with a non-thinking model, since the model may reason for a while before the first answer token arrives.
The tool-use loop#
Agentic work is what M4 was built for, so the loop deserves care. Pass function definitions in tools. A definition has type set to function and a function object with a name, a description and parameters written as JSON Schema.
When the model calls a tool, finish_reason is tool_calls and choices[0].message.tool_calls lists each call with its id, function.name and function.arguments, a JSON string. Validate the arguments before you run anything, run the function, and return the result as a message with the tool role and the matching tool_call_id.
The detail that is easy to miss is what you append to the history. MiniMax's documentation says to append the complete assistant message, including tool_calls and the thinking returned in reasoning_content, so the reasoning chain stays continuous across turns. On the Anthropic-style API the same rule reads as preserving thinking blocks unchanged. With the Python SDK, the simplest way to keep everything is to append the message object as returned:
import jsonimport osfrom openai import OpenAIclient = OpenAI( base_url="https://api.dreamto.ai/v1", api_key=os.environ["DREAMTO_API_KEY"],)tools = [ { "type": "function", "function": { "name": "get_weather", "description": "Get the current weather for a city.", "parameters": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], }, }, }]def get_weather(city: str) -> dict: return {"city": city, "temperature_c": 11, "condition": "light rain"}messages = [{"role": "user", "content": "What is the weather in Paris?"}]for _ in range(10): # cap the number of rounds response = client.chat.completions.create( model="minimax-m4", messages=messages, tools=tools, tool_choice="auto", reasoning_effort="medium", max_tokens=8192, ) message = response.choices[0].message # Keep the whole message: tool_calls and reasoning_content included. messages.append(message.model_dump(exclude_none=True)) if response.choices[0].finish_reason != "tool_calls": print(message.content) break for call in message.tool_calls: args = json.loads(call.function.arguments) result = get_weather(**args) messages.append( { "role": "tool", "tool_call_id": call.id, "content": json.dumps(result), } )Three habits help in long runs. Cap the number of rounds so a confused loop cannot run up a bill. Return errors from your tools as text the model can read, so it can correct itself. And remember that tool_choice takes auto or none on DreamTo: a value of required is accepted but not enforced, and MiniMax's own Anthropic-style page lists only auto as working. To make a tool call more likely, say so in the prompt and check finish_reason.
JSON output#
For JSON, set response_format to {"type": "json_object"} and describe the object in the prompt:
curl "https://api.dreamto.ai/v1/chat/completions" \ -H "Authorization: Bearer $DREAMTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "minimax-m4", "messages": [ {"role": "system", "content": "Reply with a JSON object with the keys title and tags."}, {"role": "user", "content": "Summarise: a REST API for ordering coffee, with Python examples."} ], "response_format": {"type": "json_object"}, "max_tokens": 2048 }'json_object asks for valid JSON; it does not enforce your schema, so name the keys in the prompt and validate the result in code before it reaches a database or a downstream service. Leave enough max_tokens for the reasoning as well, or the JSON can be cut off.
Image input#
An image goes into a user message as an image_url content part next to a text part. image_url.url takes a public image URL or base64 data such as data:image/png;base64,....
curl "https://api.dreamto.ai/v1/chat/completions" \ -H "Authorization: Bearer $DREAMTO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "minimax-m4", "messages": [ { "role": "user", "content": [ {"type": "text", "text": "Screenshot of the settings page. Check the Save button in the lower right. List what you can see and what you cannot verify."}, {"type": "image_url", "image_url": {"url": "https://example.com/screenshots/settings.png"}} ] } ], "max_tokens": 4096 }'A URL has to be reachable from the model's side; if fetching it fails, the request fails, so send base64 for private or slow hosts. MiniMax documents JPEG, PNG, GIF and WEBP images of up to 10 MB each, and up to 200 images in one request counted across the whole conversation. On DreamTo, send images as a URL or base64. MiniMax's documentation also mentions video input on its own API; DreamTo does not offer it for M4, and audio input is not supported either.
Planning cost with a long context#
Billing is per token, and the flat price across the window is the helpful part. The expensive habit is re-sending a large prefix on every turn of an agent loop. Two things keep that in check.
First, cached input. Cached input is counted automatically: the part of a prompt that repeats an earlier prefix shows up in usage.prompt_tokens_details.cached_tokens and is billed at the cache-read rate, which is 16 times cheaper than fresh input. Keep the system prompt, tool definitions and shared documents identical and at the start of each request, and put the part that changes at the end.
Second, sending only what the step needs. A 1M-token window is a ceiling, not a target. A full 1M-token prompt costs about $0.80 as fresh input and about $0.05 when it is served from cache, per request, before any output.
A worked example#
Take one step of a coding agent in the middle of a session. The conversation so far is 300,000 tokens; the prefix up to the last turn, 240,000 tokens, is served from cache, and the new tool results and messages add 60,000 fresh tokens. The model writes 20,000 tokens, reasoning included. Using the December 2026 prices:
| Part | Tokens | Rate per 1M | Cost |
|---|---|---|---|
| Fresh input | 60,000 | $0.80 | $0.048 |
| Cache read | 240,000 | $0.05 | $0.012 |
| Output (reasoning included) | 20,000 | $3.10 | $0.062 |
| Total | about $0.12 |
Without caching, the same step would bill all 300,000 input tokens at $0.80, which is $0.24 for input alone, about $0.30 with the output. Notice also that output is the largest line even at 20,000 tokens: reasoning is billed as output, so effort level is a cost lever as well as a speed lever. Multiply by the number of steps in a run before you decide that an agent is cheap enough.
Prices#
As of December 2026, minimax-m4 is billed per token at MiniMax's list price, in US dollars per 1M tokens. The price is the same at every context length up to 1M tokens.
| Item | Price |
|---|---|
| Input | $0.80 / 1M tokens |
| Cache read | $0.05 / 1M tokens |
| Output (reasoning included) | $3.10 / 1M tokens |
The prices page has the current figures, and the model list shows the alternatives. One API key for every model explains how the compatible endpoints fit together.
Limits to keep in mind when you build:
- Conversations are not stored. Send the full history with each request.
- Errors. They share one structure with
error.code,error.http_status,error.messageanderror.request_id. Branch on the HTTP status: 401 for a missing or invalid key, 402 for insufficient balance, 429 for rate limits (back off and retry), and 502, 503 or 504 when the model is temporarily unavailable or timed out. - Not everything MiniMax offers is here. MiniMax's own Anthropic-format endpoint, its M Plan subscription and its MiniMax Code app are separate MiniMax products. On DreamTo,
minimax-m4is called through Chat Completions.
Limitations to know about#
MiniMax is unusually frank in its launch post, and the same statements are worth carrying into your own planning.
- It is not the strongest model available. MiniMax says a substantial gap remains compared with the very best overseas models and that it still sees many areas for significant improvement, adding that it believes it is still at the starting line. Test M4 on your own tasks instead of assuming the headline.
- Cybersecurity capabilities are deliberately reduced. MiniMax says that during development M4 showed strong security abilities, including finding previously unknown high-severity vulnerabilities in production open-source code. It attenuated certain cybersecurity capabilities in the public general-purpose version, and plans a separate Cyber edition for compliant security research institutions. Expect more refusals or weaker results on offensive security work.
- The open weights are not out yet. MiniMax says it will release them after internal and third-party safety evaluations, with a target of the next few weeks, and has given no date or license terms. Do not plan around self-hosting until they ship.
- Showcases are self-reported. The browser, games and films come from MiniMax and have not been independently verified here. Your own evaluation set is the reliable measure.
- Thinking is always on. Short, simple requests still go through a reasoning step. Use
loweffort and a sensiblemax_tokens, and expect some latency before the first token.
FAQ#
What is MiniMax M4?#
MiniMax M4 is a natively multimodal mixture-of-experts model released by MiniMax on 3 December 2026. MiniMax reports 2.74 trillion total parameters, 66 billion active per token and a 1M-token context window, and built it for coding and long multi-step agent work. On DreamTo its model ID is minimax-m4.
What is the model ID for MiniMax M4?#
The model ID is minimax-m4, sent in the model field of a POST /v1/chat/completions request to https://api.dreamto.ai. The model page and playground use the same slug.
Can I turn thinking off?#
No. M4 always thinks, and a request with thinking set to {"type": "disabled"} is rejected. Use reasoning_effort with low to keep reasoning short. MiniMax documents max as the default, so set the level yourself.
Which reasoning effort should I use?#
Start with low or medium for routine work and raise to high, xhigh or max only for the steps that fail or need planning. Higher effort writes more reasoning tokens, which are billed as output, and takes longer.
How large is the context window?#
1M tokens, at the same per-token price across the whole window. Reasoning tokens count toward max_tokens, so set it with room for both the reasoning and the answer. Repeated prefixes are billed at the cache-read rate.
Does MiniMax M4 accept images?#
Yes. Send an image_url content part with a public URL or base64 data next to a text part in a user message. MiniMax documents JPEG, PNG, GIF and WEBP up to 10 MB each.
How do I keep reasoning intact in a tool-use loop?#
Append the complete assistant message to the history, including tool_calls and reasoning_content, before adding the tool result messages. MiniMax's documentation recommends this so the reasoning chain stays continuous.
How much does it cost?#
As of December 2026: $0.80 per 1M input tokens, $0.05 per 1M cache-read tokens and $3.10 per 1M output tokens, reasoning included. Check the prices page for current figures.
Are the open weights available?#
Not yet. MiniMax says it will release them after safety evaluations, with a target of the next few weeks, but has not published a date or license. Until then, use M4 through an API.
Can I use the OpenAI SDK with it?#
Yes. Set base_url to https://api.dreamto.ai/v1, use your DreamTo key as the api_key, and set model to minimax-m4. reasoning_effort is a named argument in recent OpenAI SDKs; in older ones, pass it through extra_body.


