Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniMax M3 API Python Quickstart with CometAPI

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

Quick answer

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)

Requirements

  • Python 3.10+
  • A CometAPI API key
  • The openai Python package

Installation

git clone https://github.com/FifoCodeDev/minimax-m3-api-python-quickstart.git
cd minimax-m3-api-python-quickstart
python -m venv .venv

Activate the virtual environment and install the dependency:

pip install -r requirements.txt

Copy .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.py

Stream a MiniMax M3 response

Streaming 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.py

Control reasoning behavior

MiniMax 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"}},
)

MiniMax M3 API reference

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.

Which tasks fit MiniMax M3?

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:

  1. Successful-task rate
  2. End-to-end latency
  3. Total input and output tokens
  4. Retry frequency
  5. Human correction time

Frequently asked questions

What is the CometAPI model ID for MiniMax M3?

Use minimax-m3.

Is CometAPI compatible with the OpenAI Python SDK?

Yes. Initialize OpenAI with your CometAPI key and use https://api.cometapi.com/v1 as the base URL.

Does MiniMax M3 support streaming?

Yes. Set stream=True and iterate over the returned chunks.

How do I enable deeper reasoning?

Pass extra_body={"thinking": {"type": "adaptive"}}. Test provider-specific fields against the current route before production rollout.

Where is the complete MiniMax M3 guide?

Read the full MiniMax M3 API tutorial, which includes specifications, multimodal requests, tool calling, pricing context, and model comparisons.

Sources

Disclosure

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.

About

Runnable Python examples for MiniMax M3 through CometAPI: streaming, reasoning controls, and OpenAI-compatible API usage.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors