A runnable Python guide to calling MiniMax M3 through CometAPI's OpenAI-compatible API, with streaming and reasoning controls.
MiniMax M3 can be called through CometAPI by using the OpenAI Python SDK, setting the base URL to https://api.cometapi.com/v1, and selecting the model ID minimax-m3. This repository provides a minimal working example rather than duplicating the full product article.
Source guide: How to Use MiniMax M3 API with CometAPI
Last verified: August 24, 2026
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["COMETAPI_KEY"],
base_url="https://api.cometapi.com/v1",
)
response = client.chat.completions.create(
model="minimax-m3",
messages=[
{"role": "user", "content": "Explain sparse attention in three bullets."}
],
)
print(response.choices[0].message.content)- Python 3.10+
- A CometAPI API key
- The
openaiPython package
git clone https://github.com/FifoCodeDev/minimax-m3-api-python-quickstart.git
cd minimax-m3-api-python-quickstart
python -m venv .venvActivate the virtual environment and install the dependency:
pip install -r requirements.txtCopy .env.example to .env, add your own key, and load it into the environment. Never commit a real API key.
PowerShell example:
$env:COMETAPI_KEY="YOUR_COMETAPI_KEY"
python examples/quickstart.pyStreaming is useful for coding, research, and long answers because users can read output while the model continues generating.
stream = client.chat.completions.create(
model="minimax-m3",
messages=[
{
"role": "user",
"content": "Create a phased plan for migrating a monolith to services.",
}
],
stream=True,
max_completion_tokens=3000,
)
for chunk in stream:
delta = chunk.choices[0].delta
if delta.content:
print(delta.content, end="", flush=True)Run the included example:
python examples/streaming.pyMiniMax M3 exposes thinking controls through an extra request body. Use adaptive thinking for difficult analysis and disable it for direct extraction or classification tasks where latency matters more.
response = client.chat.completions.create(
model="minimax-m3",
messages=[
{
"role": "user",
"content": "Find the likely root cause of this distributed transaction failure.",
}
],
extra_body={"thinking": {"type": "adaptive"}},
)For a faster direct answer:
response = client.chat.completions.create(
model="minimax-m3",
messages=[
{"role": "user", "content": "Extract the invoice number: INV-2026-0824."}
],
extra_body={"thinking": {"type": "disabled"}},
)| Setting | Value |
|---|---|
| CometAPI base URL | https://api.cometapi.com/v1 |
| Model ID | minimax-m3 |
| Endpoint | /v1/chat/completions |
| Python SDK | openai |
| Streaming | Supported |
| Reasoning control | adaptive or disabled |
Check the live MiniMax M3 model page before production deployment because availability, parameters, and pricing can change.
MiniMax M3 is positioned for long-context coding, tool-using agents, technical analysis, and multimodal workflows. A large context window is a capacity limit, not a reason to send every available file. Retrieve, filter, and compress context before submitting large repositories or document collections.
Use your own evaluation set and compare:
- Successful-task rate
- End-to-end latency
- Total input and output tokens
- Retry frequency
- Human correction time
Use minimax-m3.
Yes. Initialize OpenAI with your CometAPI key and use https://api.cometapi.com/v1 as the base URL.
Yes. Set stream=True and iterate over the returned chunks.
Pass extra_body={"thinking": {"type": "adaptive"}}. Test provider-specific fields against the current route before production rollout.
Read the full MiniMax M3 API tutorial, which includes specifications, multimodal requests, tool calling, pricing context, and model comparisons.
- CometAPI: How to Use MiniMax M3 API
- CometAPI MiniMax M3 model page
- MiniMax OpenAI-compatible API reference
- MiniMax M3 release article
This repository is an original, code-focused adaptation of CometAPI research content. The maintainer helps distribute CometAPI technical content. Product-specific claims should be checked against the linked live documentation before use.