Who this is for
This guide is for developers who want to connect MiniMax models to an application and already use the Anthropic SDK or the OpenAI SDK. By the end you should be able to send a non-streaming text request, find the thinking and the final answer in the response, and adjust thinking depth.
What MiniMax M4 is
MiniMax M4 is a natively multimodal model with 2.74T parameters in total. It activates 66B parameters per token and has a 1M-token context window[1]. You can use it through the MiniMax API, M Plan and MiniMax Code. Model weights are to follow later[1].
In API requests, the model ID is MiniMax-M4[1]. MiniMax-M3.1-Flash and MiniMax-M3 remain available. Both have a 1,000,000-token context window[1].
Setting the base URL and key
MiniMax accepts both Anthropic-style and OpenAI-style request formats. The Anthropic-compatible base URL is recommended, and it is https://api.minimax.io/anthropic. The OpenAI-compatible base URL is https://api.minimax.io/v1[1]. Get your API key from the subscription page in the MiniMax platform console[1].
Calling the Anthropic-compatible API
The Anthropic-compatible API supports thinking blocks and interleaved thinking, and it is the default path[1]. Start with a non-streaming curl request that sets output_config.effort to max[1]:
curl https://api.minimax.io/anthropic/v1/messages \
-H "Authorization: Bearer <MINIMAX_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-M4",
"output_config": {"effort": "max"},
"max_tokens": 4096,
"messages": [
{"role": "user", "content": "Hi, how are you?"}
]
}'The Python version needs the Anthropic SDK installed first. The response comes back as a list of content blocks. Each block is typed as thinking or text, so you can print them separately[1]:
# Please install the Anthropic SDK first: `pip install anthropic`
import anthropic
client = anthropic.Anthropic(
base_url="https://api.minimax.io/anthropic",
api_key="<MINIMAX_API_KEY>",
)
message = client.messages.create(
model="MiniMax-M4",
output_config={"effort": "max"},
max_tokens=4096,
messages=[
{"role": "user", "content": "Hi, how are you?"}
],
)
for block in message.content:
if block.type == "thinking":
print(f"Thinking:\n{block.thinking}\n")
elif block.type == "text":
print(f"Text:\n{block.text}\n")Calling the OpenAI-compatible API
If your project already uses the OpenAI SDK, changing base_url and model to the MiniMax values lets most of your existing client code keep working[1]. The example below sets the thinking depth with reasoning_effort[1]:
# Please install the OpenAI SDK first: `pip install openai`
from openai import OpenAI
client = OpenAI(
base_url="https://api.minimax.io/v1",
api_key="<MINIMAX_API_KEY>",
)
response = client.chat.completions.create(
model="MiniMax-M4",
reasoning_effort="max",
messages=[
{"role": "user", "content": "Hi, how are you?"},
],
)
print(response.choices[0].message.content)On the OpenAI-compatible protocol, thinking always comes back in the reasoning_content field. The content field holds only the final answer, so a front end can display it without parsing <think> tags[1].
On the Anthropic-compatible API, thinking arrives as a separate thinking content block, and the answer arrives in a text block. Thinking is on by default either way, so pick out the blocks or fields you need before you display anything[1].
Adjusting thinking depth
MiniMax M4 breaks a complex problem into steps before it answers. Thinking improves accuracy on agentic reasoning, tool use, coding and maths. Thinking is on by default and needs no setup[1].
For MiniMax-M4 and MiniMax-M3.1-Flash, effort accepts low, medium, high, xhigh and max. If you omit it, the default is max[1]. MiniMax-M3 does not support tuning thinking depth[1]. Higher levels think more thoroughly and produce more output tokens, but latency also rises[1].
Each protocol uses its own field name. The Anthropic-compatible API uses output_config.effort, the OpenAI-compatible API uses reasoning_effort, and the OpenAI Responses API uses reasoning.effort[1]. The output limit field differs as well. The Anthropic-compatible API uses max_tokens, the OpenAI-compatible API accepts max_tokens or max_completion_tokens, and the Responses API uses max_output_tokens[1].
A practical rule: to get answers quickly, lower effort, which reduces latency and output tokens. For coding or maths that needs multi-step reasoning, keep the default max, accepting longer waits and more output[1].
Common problems
- Thinking cannot be turned off. Sending
thinking: {"type": "disabled"}oreffort: "none"returns HTTP 400[1]. The error message readsmodel "MiniMax-M4" requires adaptive thinking[1]. - To cut thinking latency and token use, lower the
effortlevel instead of trying to disable thinking[1]. - To set the default level explicitly on the Anthropic-compatible API, set
output_config.efforttomax[1].
Next steps
If your project already uses the Anthropic SDK, the Anthropic-compatible API is the recommended route, since it supports thinking blocks and interleaved thinking[1].
For the full list of parameters and response fields, see the Anthropic-compatible and OpenAI-compatible API references in the MiniMax documentation[1].
Sources
- 1Model InvocationMiniMax
Cite this page: Calling the MiniMax M4 API for text generation. TellWorld, https://www.tellworld.net/practice/practice-minimax-m4-api. Updated 2026-12-04