> ## Documentation Index
> Fetch the complete documentation index at: https://platform.minimax.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Connect MiniMax models in OpenCode.

<div style={{background:"#fffbeb",borderLeft:"4px solid #d97706",padding:"12px 16px",borderRadius:"6px",margin:"16px 0"}}>[**OpenCode**](https://github.com/sst/opencode) is an open-source terminal AI coding agent by SST, with multi-provider support and LSP integration.</div>

<Tabs sync={false}>
  <Tab title="Option 1: One-click setup wizard">
    Run:

    ```bash theme={null}
    npx -y mmx-cli@latest agent setup
    ```

    Select **OpenCode**. If it is missing, keep OpenCode selected in the second multi-select. The wizard installs the official npm package, verifies its version, and sets a MiniMax default model.

    Run `opencode` when setup finishes.
  </Tab>

  <Tab title="Option 2: Manual setup">
    <Steps>
      <Step title="Install OpenCode">
        ```bash theme={null}
        curl -fsSL https://opencode.ai/install | bash
        # or: npm i -g opencode-ai
        ```
      </Step>

      <Step title="Authenticate">
        Run `opencode auth login`, then when prompted, search and pick **MiniMax Token Plan (minimax.io)** (the provider name in OpenCode), and enter your [Subscription Key](https://platform.minimax.io/console/plan).
      </Step>

      <Step title="Launch">
        Run `opencode` and select `MiniMax-M3.1-Flash-Preview` from the model list. If your version does not list it, add the following to `~/.config/opencode/opencode.json` and run it again:

        ```json theme={null}
        {
          "$schema": "https://opencode.ai/config.json",
          "provider": {
            "minimax-coding-plan": {
              "models": {
                "MiniMax-M3.1-Flash-Preview": {
                  "name": "MiniMax-M3.1-Flash-Preview",
                  "limit": { "context": 524288 }
                }
              }
            }
          }
        }
        ```

        This example sets a **512K (524288 tokens)** client context window to balance cost and usability; the model itself supports up to 1M. See the [512K guidance](/docs/m-plan/codex#context-window-512k).
      </Step>
    </Steps>
  </Tab>
</Tabs>
