MiniMax-M4 API Reference

Call MiniMax-M4 through an OpenAI-compatible endpoint: authentication, chat completions, streaming, images, video, tools and billing.

Quick start

  1. Create an API key in your dashboard. Keys are shown once; store them like passwords.
  2. Make sure you have credits. New accounts get 300; buy more any time.
  3. Send a request to the chat completions endpoint.
curl https://YOUR_DOMAIN/api/v1/chat/completions \
  -H "Authorization: Bearer $M4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M4",
    "reasoning_effort": "medium",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Give me three names for a hiking app."}
    ]
  }'

Base URL and authentication

| | | | ----------- | ----------------------------------------------------- | | Base URL | https://YOUR_DOMAIN/api/v1 | | Auth header | Authorization: Bearer <key> (or X-Api-Key: <key>) | | Model | MiniMax-M4 |

Any OpenAI SDK works. Set base_url / baseURL to the base URL above and pass your key.

from openai import OpenAI

client = OpenAI(base_url="https://YOUR_DOMAIN/api/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
    model="MiniMax-M4",
    reasoning_effort="high",
    messages=[{"role": "user", "content": "Explain CAP theorem with an example."}],
)
print(resp.choices[0].message.content)
print(resp.choices[0].message.reasoning_content)  # the model's thinking

POST /chat/completions

| Parameter | Type | Notes | | ----------------------- | ------------- | -------------------------------------------------------------------------------------------------------------- | | model | string | Always MiniMax-M4. | | messages | array | Standard chat messages. User content may mix text, image_url and video_url parts. | | reasoning_effort | string | low, medium, high, xhigh or max (default max). MiniMax-M4 always thinks; this sets how much. | | max_completion_tokens | integer | Output budget, thinking included. Capped at 128,000. max_tokens is accepted as an alias. | | stream | boolean | Server-sent events, OpenAI chunk format. Usage arrives in the final chunk. | | tools, tool_choice | array, string | Function calling in OpenAI format. Append the assistant message (with its tool calls) before each tool result. |

Temperature and top_p are fixed by MiniMax (1 and 0.95) and are ignored if sent.

Response

The answer is in choices[0].message.content. The thinking is returned separately in choices[0].message.reasoning_content (streaming: delta.reasoning_content). usage reports prompt_tokens, completion_tokens and cached tokens.

Images and video

{
  "role": "user",
  "content": [
    { "type": "text", "text": "What changed between these two screenshots?" },
    {
      "type": "image_url",
      "image_url": { "url": "https://example.com/a.png", "detail": "high" }
    },
    {
      "type": "image_url",
      "image_url": { "url": "data:image/png;base64,iVBORw0..." }
    }
  ]
}
  • Images: JPEG, PNG, GIF or WebP, up to 10 MB each, by URL or base64 data URL. detail is low, default or high.
  • Video: MP4, AVI, MOV or MKV, up to 50 MB by URL or base64, up to 30 minutes. Use {"type": "video_url", "video_url": {"url": "...", "fps": 1}}; fps ranges from 0.2 to 5.
  • Up to 200 images and 20 videos per request. Audio input is not supported by the model; transcribe it first.

Streaming

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://YOUR_DOMAIN/api/v1',
  apiKey: process.env.M4_API_KEY,
});
const stream = await client.chat.completions.create({
  model: 'MiniMax-M4',
  stream: true,
  messages: [{ role: 'user', content: 'Write a haiku about latency.' }],
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}

Billing

Each call is billed from your credits by the tokens it used: 1 credit per 1,000 input tokens, 0.1 per 1,000 cached input tokens, 4 per 1,000 output tokens (thinking counts as output). The x-m4-credits response header (non-streaming) shows what a call cost.

While a request runs, the credits for its longest possible answer are held: the input plus max_completion_tokens of output, or, without a limit, as many output tokens as your balance covers (at most 128,000). The x-m4-max-completion-tokens header shows the limit that applied. When the answer ends, you pay for the tokens it used and the rest of the hold comes back. Parallel requests each hold their own share, so set max_completion_tokens to run more of them at once. A request is refused with HTTP 402 when your balance can't cover its input plus 8,000 output tokens (or your max_completion_tokens, if lower).

Errors

| HTTP | error.type | Meaning | | ---- | ----------------------- | ---------------------------------------------------- | | 400 | invalid_request_error | Missing messages or a model other than MiniMax-M4. | | 401 | authentication_error | Missing or invalid key. | | 402 | insufficient_quota | Not enough credits. | | 429 | rate_limit_error | Too many requests; retry after a short pause. | | 502 | api_error | The upstream model returned an error. |

GET /models

Lists the available model (MiniMax-M4, 1,000,000-token context). Useful for tools that probe an OpenAI-compatible endpoint.