Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

minimax-code-sdk

Python SDK for driving the local MiniMax Code agent (mcode).

It mirrors the TypeScript SDK @minimax-ai/code-sdk: every Turn runs mcode exec --output-format=stream-json and continues the Session with --session.

Requirements

  • Python 3.10+
  • The mcode CLI (0.6.3 or newer): npm install -g @minimax-ai/code

Install

pip install --pre minimax-code-sdk   # or: uv add --prerelease=allow minimax-code-sdk

The SDK is in beta, so installers need --pre (or an exact version such as minimax-code-sdk==0.1.0b1) until 0.1.0 is released. Import it as minimax_code.

The CLI is found from MCodeOptions(bin=...), then the MCODE_BIN environment variable, then PATH.

Quick start

import asyncio
from minimax_code import MCode, ThreadOptions


async def main() -> None:
    client = MCode()
    thread = client.start_thread(ThreadOptions(cwd=".", permission="smart"))

    turn = await thread.run("Summarize this repository in one sentence.")
    print(turn.final_response, turn.usage)

    # Same Session, next Turn.
    turn = await thread.run("Now list its top-level directories.")

    # Persist thread.id and continue later.
    later = client.resume_thread(thread.id)
    print((await later.run("What did I ask first?")).final_response)


asyncio.run(main())

Streaming

streamed = await thread.run_streamed("Fix the failing test.")
async for event in streamed:
    if event["type"] == "item.updated" and event["item"]["type"] == "agent_message":
        print(event["item"].get("contentDelta", ""), end="")
    elif event["type"] == "turn.failed":
        print("failed:", event.get("error"))

Events are the CLI's stream-json events, passed through unchanged (unknown types included). turn.failed is an ordinary event; iteration raises only for process or protocol failures.

Cancellation

  • streamed.cancel() sends SIGINT; the stream ends with the CLI's final events.
  • Leaving the async for early, or cancelling the task running thread.run(), stops the CLI (SIGINT, then SIGKILL after a grace period).
  • RunOptions(timeout_ms=...) is enforced by the CLI.

Blocking API

from minimax_code import SyncMCode

with SyncMCode() as client:
    thread = client.start_thread()
    print(thread.run("hello").final_response)
    for event in thread.run_streamed("again"):
        print(event["type"])

Options

Object Fields
MCodeOptions bin, data_dir (MINIMAX_DATA_DIR), env (replaces os.environ), config_path
ThreadOptions cwd, model (provider/model), effort, permission (smart/full/off), mode, prompt_mode, system_prompt, append_system_prompt
RunOptions files, timeout_ms, max_steps

Errors

All errors subclass MCodeError (with exit_code, stderr, session_id, result, items): MCodeNotFoundError, MCodeVersionError, MCodeInvocationError, MCodeRunError (status, category), MCodeAbortError, MCodeProtocolError, ThreadBusyError.

Limitations

Each Turn is a separate process, so interactive permission prompts (permission="ask") and custom in-process tools are not supported yet. A long-lived ACP transport is planned.

Development

uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check . && uv run mypy

End-to-end tests against a real CLI and model are opt-in: MCODE_SDK_E2E=1 MCODE_BIN=/path/to/mcode uv run pytest -m e2e.

Release notes are in CHANGELOG.md; maintainers publish with RELEASING.md.

License

MIT

Metadata

Release files for minimax-code-sdk 0.1.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minimax-code-sdk 0.1.0b1
File Size Uploaded Provenance Actions
minimax_code_sdk-0.1.0b1.tar.gz 61.7 kB With provenance Details for minimax_code_sdk-0.1.0b1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minimax-code-sdk 0.1.0b1
File Interpreter ABI Platform Actions
minimax_code_sdk-0.1.0b1-py3-none-any.whl Python 3 none any Details for minimax_code_sdk-0.1.0b1-py3-none-any.whl

Total release size: 80.2 kB

Release files / minimax_code_sdk-0.1.0b1.tar.gz

Download URL minimax_code_sdk-0.1.0b1.tar.gz
Size 61.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c6e079740286c110728c6d9f0c5d45163a15ded5c15995cb48932ef7a2e4b7d3
BLAKE2b-256 checksum
How to use checksums
295c83855c823bbf0eae5e6887bcceec0b312983d2d8a74c5fab76d790c3144d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / minimax_code_sdk-0.1.0b1-py3-none-any.whl

Download URL minimax_code_sdk-0.1.0b1-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22c089316a9c09d93ec8e3b05e9e88d16c0374a1a5deedb3357c92714f1a5770
BLAKE2b-256 checksum
How to use checksums
57b87ddead08e068632171d92c6af9443fb4e49105653f5292db430748cb8da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for minimax-code-sdk 0.1.0b1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for minimax_code_sdk-0.1.0b1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page