MiniMax OpenAI-Compatible API: Python, Node.js, and Streaming

Last verified: July 18, 2026. MiniMax exposes an OpenAI-compatible Chat Completions interface, so an application that already uses the OpenAI SDK can point a client at MiniMax with a different base URL, API key, and model ID. For MiniMax M3, the core values are https://api.minimax.io/v1, MiniMax-M3, and the /chat/completions route used by the SDK.

Independence and test notice: MiniMax-AI.chat is an independent website and is not affiliated with or endorsed by MiniMax. We checked these examples against MiniMax’s official OpenAI SDK guide and Chat Completions schema and reviewed the JavaScript and Python syntax. We did not send a live API request because no testing credential was available. Run the verification request in your own MiniMax account before deploying.

Use this page for compatibility, not the whole API

This is a focused implementation guide for the OpenAI-compatible text route. The broader MiniMax API guide maps text, speech, video, image, music, files, credentials, and billing. Read the MiniMax M3 model guide for model capabilities and context, and the MiniMax pricing guide before choosing token limits or a service tier.

SettingValue for this guideCommon mistake
Base URLhttps://api.minimax.io/v1Keeping the OpenAI host or adding /chat/completions to the SDK base URL
Model IDMiniMax-M3Changing capitalization or using a marketing page title as the ID
SDK methodchat.completions.createMixing Chat Completions fields with Responses API fields
AuthenticationMiniMax key sent as a Bearer credentialExposing the key in browser code, a mobile bundle, logs, or Git

MiniMax’s official OpenAI SDK guide is the authority for the compatibility layer. The official Chat Completions reference is the authority for the request and response schema. Recheck both when upgrading an SDK or model.

Prerequisites and credential safety

  • A MiniMax Open Platform account with a key that is valid for the intended billing arrangement.
  • A server, command-line environment, or trusted back end. Do not call MiniMax directly from public browser JavaScript with a secret key.
  • Node.js with npm for the JavaScript example, or Python with pip for the Python example.
  • A spend ceiling, request timeout, retry policy, and log-redaction rule before production traffic.

The official API overview distinguishes pay-as-you-go API keys from Token Plan subscription keys. Do not silently substitute one for the other. Create or copy the credential from the billing path you intend to use, store it in a secret manager or server environment variable, and rotate it if it appears in a screenshot, repository, build artifact, support ticket, or log.

# macOS or Linux shell; replace the placeholder in your local shell only
export MINIMAX_API_KEY="replace-with-your-secret"

# Never commit the real value to source control.

Node.js quick start

Install the OpenAI package:

npm install openai

Save the following as minimax-chat.mjs. This first request explicitly disables M3 thinking so the printed content is a direct answer. A later section explains the default behavior and separated reasoning format.

import OpenAI from "openai";

const apiKey = process.env.MINIMAX_API_KEY;
if (!apiKey) {
  throw new Error("MINIMAX_API_KEY is not set");
}

const client = new OpenAI({
  apiKey,
  baseURL: "https://api.minimax.io/v1",
});

const response = await client.chat.completions.create({
  model: "MiniMax-M3",
  messages: [
    {
      role: "system",
      content: "Answer concisely. State uncertainty instead of guessing.",
    },
    {
      role: "user",
      content: "Give three checks for reviewing an API migration.",
    },
  ],
  thinking: { type: "disabled" },
  max_completion_tokens: 800,
  temperature: 0.3,
});

const answer = response.choices[0]?.message?.content;
if (!answer) {
  throw new Error("MiniMax returned no text choice");
}

console.log(answer);
console.log({ responseId: response.id, usage: response.usage });

Run it with node minimax-chat.mjs. The MiniMax-only thinking field is sent as an extra request field by this plain JavaScript example. If TypeScript definitions in your installed OpenAI package reject that extension, add a narrow local request type or use the standard fields only; do not suppress type checking across the project.

Python quick start

python -m pip install openai

MiniMax-specific request fields belong in extra_body when using the Python OpenAI SDK:

import os
from openai import OpenAI

api_key = os.environ.get("MINIMAX_API_KEY")
if not api_key:
    raise RuntimeError("MINIMAX_API_KEY is not set")

client = OpenAI(
    api_key=api_key,
    base_url="https://api.minimax.io/v1",
)

response = client.chat.completions.create(
    model="MiniMax-M3",
    messages=[
        {
            "role": "system",
            "content": "Answer concisely. State uncertainty instead of guessing.",
        },
        {
            "role": "user",
            "content": "Give three checks for reviewing an API migration.",
        },
    ],
    max_completion_tokens=800,
    temperature=0.3,
    extra_body={"thinking": {"type": "disabled"}},
)

answer = response.choices[0].message.content
if not answer:
    raise RuntimeError("MiniMax returned no text choice")

print(answer)
print({"response_id": response.id, "usage": response.usage})

Streaming in Node.js

Streaming reduces the delay before a user sees output; it does not reduce the total generated tokens by itself. A stream can end early, fail between chunks, or finish without usage data unless usage is requested. Build the final text on the server, persist it only after a successful completion, and show a clear partial-result state after interruption.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.MINIMAX_API_KEY,
  baseURL: "https://api.minimax.io/v1",
});

const stream = await client.chat.completions.create({
  model: "MiniMax-M3",
  messages: [{ role: "user", content: "Explain idempotency in five bullets." }],
  thinking: { type: "disabled" },
  max_completion_tokens: 900,
  stream: true,
  stream_options: { include_usage: true },
});

let assembled = "";
let usage;

for await (const chunk of stream) {
  const part = chunk.choices[0]?.delta?.content ?? "";

  // Handles either incremental chunks or a cumulative text field.
  const addition = part.startsWith(assembled)
    ? part.slice(assembled.length)
    : part;

  process.stdout.write(addition);
  assembled = part.startsWith(assembled) ? part : assembled + part;

  if (chunk.usage) usage = chunk.usage;
}

process.stdout.write("\n");
console.log({ characters: assembled.length, usage });

Streaming in Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MINIMAX_API_KEY"],
    base_url="https://api.minimax.io/v1",
)

stream = client.chat.completions.create(
    model="MiniMax-M3",
    messages=[
        {"role": "user", "content": "Explain idempotency in five bullets."}
    ],
    max_completion_tokens=900,
    stream=True,
    stream_options={"include_usage": True},
    extra_body={"thinking": {"type": "disabled"}},
)

assembled = ""
usage = None

for chunk in stream:
    if chunk.choices:
        part = chunk.choices[0].delta.content or ""
    else:
        part = ""
    addition = part[len(assembled):] if part.startswith(assembled) else part
    print(addition, end="", flush=True)
    assembled = part if part.startswith(assembled) else assembled + part
    if chunk.usage:
        usage = chunk.usage

print()
print({"characters": len(assembled), "usage": usage})

Some usage-only chunks can have no choice, so the example checks the list before reading a delta. In production, wrap the loop in exception handling, emit an application-level completion event, and do not retry after showing output unless your interface clearly marks the replacement response. An automatic retry can create duplicated or conflicting text.

M3 thinking: two controls with different jobs

MiniMax M3 thinking is enabled by default in Chat Completions when the thinking field is omitted. Set {"type":"adaptive"} to keep it enabled explicitly, or {"type":"disabled"} to request a direct answer. MiniMax documents that thinking cannot be disabled for the listed M2.x models even if the disabled value is accepted.

reasoning_split does not turn thinking on or off. It only changes the response format. With the split enabled, MiniMax exposes thinking through reasoning fields; without it, the native Chat Completions response can place thinking inside <think>...</think> tags in content. Keep these concerns separate:

GoalRequest choiceHandling rule
Direct answer without M3 thinkingthinking: {"type":"disabled"}Still validate the answer; disabled thinking is not a factuality guarantee
M3 thinking in native contentOmit thinking and leave reasoning_split falseDo not render raw reasoning tags as normal answer text
M3 thinking in separate fieldsreasoning_split: truePreserve required reasoning fields in a multi-turn tool history, but do not expose them in user-facing logs

For tool calls, MiniMax instructs developers to append the complete assistant message, including tool_calls, to conversation history. When separated reasoning is used, preserve its reasoning details as well. The full safe loop belongs in our MiniMax function-calling guide; this page intentionally stops at the compatibility boundary.

Supported parameters and compatibility gaps

ParameterM3 behavior documented by MiniMaxImplementation advice
messagesRequired conversation history; supports text and documented media/tool content formsValidate roles and cap input size before sending
max_completion_tokensGeneration limit; preferred over legacy max_tokensBegin with a task-sized ceiling and measure stop reasons
temperatureRange 0–2; default 1Use a lower value for constrained extraction, but test rather than assuming determinism
top_pRange 0–1; M3 default 0.95Change one sampling control at a time during evaluation
streamReturns chunks when trueAssemble, validate, and mark completion server-side
stream_options.include_usageRequests usage data in a streamDo not assume every interrupted stream has final usage
service_tierstandard or priorityConfirm eligibility and cost before selecting priority
toolsFunction tool definitionsUse an allowlist, validate arguments, and execute tools in your code
reasoning_splitSeparates reasoning output; does not control whether thinking runsPreserve required history fields during tool loops

Compatibility does not mean every OpenAI field has equivalent behavior. MiniMax says presence_penalty, frequency_penalty, logit_bias, and some other OpenAI parameters are ignored. The n field supports only 1. The deprecated function_call field is unsupported; use tools. Remove ignored fields during migration so configuration does not imply a control that the provider does not apply.

Multimodal input without duplicating the M3 guide

MiniMax documents image and video content parts for M3 through the OpenAI-compatible Chat Completions route, while audio input is unsupported there. Media requests add file-format, payload-size, token-use, URL-access, and privacy considerations. Do not paste a media example into a text endpoint and assume it is portable. Use the model page linked above for capability context and a dedicated multimodal implementation guide for upload and size rules.

Migration checklist from another OpenAI-compatible provider

  1. Change the base URL and secret source; do not change both in a shared global client if other providers still use it.
  2. Set the exact model ID MiniMax-M3.
  3. Remove unsupported or ignored parameters and set n to one.
  4. Choose M3 thinking behavior explicitly and decide how reasoning fields are stored and hidden.
  5. Replace legacy function_call with tools if the application uses functions.
  6. Test plain text, long input, stop due to length, streaming interruption, rate limits, invalid authentication, safety rejection, and provider outage.
  7. Record quality, latency, prompt tokens, completion tokens, cache tokens where present, and total cost on a fixed evaluation set.
  8. Canary the provider change for a small traffic share and keep a reversible configuration switch.

If your application uses an Anthropic-style message loop, compare the MiniMax Anthropic-compatible API guide. If you need item-based response objects, read the separate MiniMax Responses API guide. MiniMax-hosted Server Tools are a separate beta capability documented for Anthropic Messages only, not for this OpenAI-compatible route. Reusing an SDK shape is helpful; it does not make the API families interchangeable.

Troubleshooting

SymptomFirst checks
Authentication errorConfirm the MiniMax key source, environment variable, billing path, and absence of spaces or quote characters copied into the value
Model errorCheck exact capitalization: MiniMax-M3; verify the account can access that model
404 or wrong hostUse https://api.minimax.io/v1 as the SDK base URL, without appending the endpoint path
Unexpected <think> textThinking is enabled by default; disable it or deliberately parse the documented separated format
Parameter appears ineffectiveRemove fields MiniMax lists as ignored; confirm ranges and spelling for supported fields
Only one choice is returnedThis interface supports n=1
Stream duplicates textCheck whether the received field is incremental or cumulative and use one assembly strategy consistently
Tool conversation degrades after a callPreserve the complete assistant message, tool call, tool result, and separated reasoning details when used

Capture the HTTP status, response body after redaction, response ID when supplied, model ID, endpoint, timestamp, and a minimal reproducible request. Never log the Authorization header or unredacted user material. Use our MiniMax API errors and retry guide for status-aware backoff and debugging.

Production acceptance test

  • Security: the key exists only on trusted infrastructure and is redacted from logs.
  • Correctness: a fixed prompt set has expected assertions, not subjective spot checks.
  • Streaming: cancellation, disconnect, timeout, and partial output have defined UI states.
  • Cost: usage fields are captured and reconciled against the account bill on a sample.
  • Resilience: retries apply only to retryable failures, use backoff and jitter, and respect a total attempt budget.
  • Safety: input handling, output review, tool permissions, and abuse controls match the use case.
  • Change control: base URL, model, token ceiling, thinking mode, and tier are versioned configuration rather than scattered literals.

FAQ

Can I change only the base URL in an existing OpenAI integration?

Usually not. You must also supply a MiniMax credential and model ID, then audit parameters, thinking output, tool history, stream assembly, limits, errors, and quality. The transport shape is compatible; provider behavior is not identical.

Does reasoning_split=true enable M3 thinking?

No. It changes where reasoning appears. M3 thinking is enabled by default when thinking is omitted; the thinking object controls adaptive or disabled behavior.

Should I use Chat Completions or Responses?

Use Chat Completions when your application already has a stable message-based OpenAI SDK integration and the documented fields meet the design. Evaluate Responses separately when its item model or server-tool workflow fits better. Do not mix their request objects.

Does OpenAI compatibility make MiniMax an OpenAI service?

No. MiniMax operates the endpoint and models described here. “OpenAI-compatible” refers to an API and SDK format, not ownership, identical outputs, shared accounts, or shared billing.


Implementation conclusion: isolate the MiniMax client, use the exact base URL and model ID, choose thinking behavior deliberately, remove ignored fields, assemble streams defensively, and test against your own acceptance set before moving traffic.