跳转到主要内容

前置准备

1

账户注册/登录

API 调用前,需在 MiniMax 开放平台进行账户注册,企业团队注册请参考页面底部说明
2

获取 API Key

生成 API Key 后,建议将其存储为环境变量或保存到 .env 文件中
# 推荐使用 Anthropic API 兼容
export ANTHROPIC_BASE_URL=https://api.minimaxi.com/anthropic
export ANTHROPIC_API_KEY=${YOUR_API_KEY}
3

账户充值

通过 账户管理 > 余额,按需充值

开始调用

1

安装 Anthropic SDK(推荐)

pip install anthropic
2

调用 MiniMax-M2.1

Python
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="MiniMax-M2.1",
    max_tokens=1000,
    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")
3

示例输出

{
  "thinking": "The user is just greeting me casually. I should respond in a friendly, professional manner.",
  "text": "Hi there! I'm doing well, thanks for asking. I'm ready to help you with whatever you need today—whether it's coding, answering questions, brainstorming ideas, or just chatting. What can I do for you?"
}

探索更多


建议采用主账号+子账号的形式创建和管理。
  1. MiniMax 开放平台 注册一个账号(此账号即为主账号,注册时填写的姓名与手机号会成为本企业账号的管理员信息)
  2. 登录该主账号,在 账户管理 > 子账号,创建您所需要数量的子账户(子账号的创建数量暂时没有限制)
  3. 为您企业的人员,分配不同的子账户,进行登录使用
子账户权限说明:
  • 子账号和主账号享用相同的使用权益与速率限制,子账号和主账号的 API 消耗共享,统一结算
  • 子账号无查看和管理”支付”权限