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?
相关推荐
旋生万物4 天前
五条几何公理重构元素周期表:从量子力学到螺旋拓扑的降维(AI 编程时代的微观启示)
重构·ai编程·代码审计·cursor·ai agent·mcp协议·claudecode
武雄(小星Ai)5 天前
2026 AI编程工具横评:Trae、Cursor、Copilot、Claude Code实测对比
ai·copilot·cursor·编程工具·trae·claude code·对比评测
咖啡星人k5 天前
AI 编程工具集体变脸:Cursor 漏洞、TRAE 限额、Claude Code 数据收集风波
人工智能·安全·microsoft·cursor·trae·ai编程工具
csdn_aspnet9 天前
如何将 Cursor MCP 与 VS Code 连接
vscode·cursor·mcp·composio
思码梁田9 天前
CSS cursor 属性全解析:从“小手“开始,玩转鼠标光标
前端·css·计算机外设·cursor·pointer
武雄(小星Ai)11 天前
2026年7月 AI 编程工具横评:Claude Code vs Cursor vs GitHub Copilot 实测对比
ai·开发工具·claude·cursor·对比评测
redreamSo11 天前
32 个 AI 编程工具的配置都放哪,这个仓库整理清楚了
ai编程·claude·cursor
唠点键盘之外的13 天前
10 Spring Boot + 大模型:Java 项目接入 AI 的三种姿势
java·spring boot·aigc·cursor
仙逆GPT15 天前
Cursor Agent一直卡住?自动执行和权限确认怎么排查
ai编程·cursor·ai agent·代码审查·cursor agent
R0OT16 天前
在git bash中使用Cursor CLI
cursor