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

# 开通订阅

> 订阅 M Plan，获取订阅 Key，并测试 API 调用。

## 1. 订阅 M Plan

前往 [套餐详情](https://platform.minimax.cn/console/plan)，选择档位并完成付款。

<Tip>
  如果你只在 MiniMax Code 中使用 M Plan，完成第 1 步后登录 MiniMax Code 即可，无需配置订阅 Key。
</Tip>

## 2. 获取订阅 Key

订阅完成后，在[套餐详情](https://platform.minimax.cn/console/plan)中查看你的订阅 Key。在 Claude Code、Cursor 等 AI 工具中使用 M Plan 时，需要用到这个 Key。

注意：

* 订阅 Key 只能使用 M Plan 的额度，与按量计费的 API Key 不通用。
* 请妥善保管订阅 Key，不要泄露给他人或提交到代码仓库。建议通过环境变量或配置文件使用。

## 3. 测试 API 调用（可选）

举例使用 Anthropic SDK 快速测试 MiniMax-M3.1-Flash-Preview。

**安装 SDK**

<CodeGroup>
  ```bash Python theme={null}
  pip install anthropic
  ```

  ```bash Node.js theme={null}
  npm install @anthropic-ai/sdk
  ```
</CodeGroup>

**配置环境变量**

将 `${YOUR_API_KEY}` 替换为你的订阅 Key：

```bash theme={null}
export ANTHROPIC_BASE_URL=https://api.minimax.cn/anthropic
export ANTHROPIC_API_KEY=${YOUR_API_KEY}
```

**调用 API**

```python Python theme={null}
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="MiniMax-M3.1-Flash-Preview",
    output_config={"effort": "max"},
    max_tokens=4096,
    system="You are a helpful assistant.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Hi, how are you?"
                }
            ]
        }
    ]
)

for block in message.content:
    if block.type == "thinking":
        print(f"Thinking:\n{block.thinking}\n")
    elif block.type == "text":
        print(f"Text:\n{block.text}\n")
```
