minimaxi ai - 文本对话

1 配置 .env

platform.minimaxi.com/docs/guides...

2 安装 anthropic SDK

pip install anthropic

3 运行案例

ini 复制代码
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="MiniMax-M2.7",
    max_tokens=1000,
    system="You are a helpful assistant.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Hi, how are you?"
                }
            ]
        }
    ]
)

print(message)

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")

输出:

python 复制代码
Message(id='0651c342a7dfaf9ecf667f023edfe6e3', container=None, content=[ThinkingBlock(signature='129115bc31295514df49663325062d70ed51db7ef78e8f4f3202b28f5ef3dfe6', thinking='The user is asking a simple greeting question about how I am. I should respond in a friendly, conversational way.\n', type='thinking'), TextBlock(citations=None, text="\nHi! I'm doing well, thanks for asking. I'm ready to help you with whatever you need---whether that's coding, answering questions, brainstorming ideas, or just having a chat.\n\nHow are you doing? Is there something I can help you with today?", type='text')], model='MiniMax-M2.7', role='assistant', stop_details=None, stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(cache_creation=None, cache_creation_input_tokens=0, cache_read_input_tokens=0, inference_geo=None, input_tokens=28, output_tokens=76, server_tool_use=None, service_tier=None), base_resp={'status_code': 0, 'status_msg': 'success'})
Thinking:
The user is asking a simple greeting question about how I am. I should respond in a friendly, conversational way.


Text:

Hi! I'm doing well, thanks for asking. I'm ready to help you with whatever you need---whether that's coding, answering questions, brainstorming ideas, or just having a chat.

How are you doing? Is there something I can help you with today?
相关推荐
JMchen1234 天前
Cursor高阶玩法:.cursorrules编写与Spec-Driven开发实战,把AI调教成专属结对编程搭档
人工智能·vscode·kotlin·cursor·结对编程·spec-driven·.cursorrules
JMchen1235 天前
2026年六款主流AI编程工具深度实测:Cursor、Copilot、Claude Code等对比与选型思考
android·kotlin·copilot·ai编程·开发工具·cursor·claude code
货拉拉技术5 天前
让 AI 真正读懂你的代码:一套可复用的 Cursor 辅助编码实践
cursor
Blockbuater_drug6 天前
MCP Server 接入实战: 9种平台配置差异与凭证安全
claude·cursor·mcp·openclaw·hermes agent·dsh·agent 配置
golang学习记6 天前
Cursor Origin:Cursor要造一个AI时代的Github
人工智能·github·cursor
ERD Online15 天前
Cursor 连上 MCP:读一张 ER 图,提交一版建议
数据库·后端·开源·cursor·mcp
Patrick_Wilson15 天前
Superpowers 与 Codex Harness:冲突分析与治理提示词
agent·ai编程·cursor
wangruofeng15 天前
OpenAI 断供 Cursor:这不是商业决定,是战争行为
openai·ai编程·cursor
陈大鱼头16 天前
突发!OpenAI 要封杀 Cursor
openai·cursor·vibecoding
VIP_CQCRE16 天前
Cursor 接入 Ace Data Cloud MCP:把 AI 编程编辑器升级成全能创作工作站
ai·cursor·mcp·ace data cloud