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?
相关推荐
_小许_3 小时前
AI IDE 与 Agent Harness:一次说清 Cursor、Codex 该怎么选
ide·人工智能·ai编程·cursor·codex
前端菜菜DayDayUp4 小时前
[特殊字符] Cursor 接入蓝湖 MCP 高效还原设计稿全流程指南
cursor·ai工具·蓝湖
技术小甜甜3 天前
【Cursor】Skill 被标黄色警告,怎么改成合格的 SKILL.md
开发语言·javascript·ai编程·cursor·1024程序员节·ai agent·skills
灵感__idea4 天前
Claude Code 编程实战:外行人第一次可以独挑大梁
ai编程·claude·cursor
comedate7 天前
Cursor 和 GitHub Copilot 怎么选?2026 年 AI 编程助手对比
ide·ai编程·cursor·github copilot
死磕音视频7 天前
Cursor 入门:用 AI 编辑器读懂项目并完成第一次修改
ai编程·代码编辑器·cursor·编程入门
用户539418729078 天前
Cursor 一次改出几百行 diff、逐行看根本看不过来?我固定了一套 review 顺序,专盯这几处,夹带的私货一抓一个准
ai编程·cursor
badhope10 天前
Cursor转Codex大半个月实测:迁移成本、代码质量与那些没人说的隐性坑点
ai编程·cursor
用户5394187290711 天前
别只在 prompt 里让 AI 别碰文件:我给仓库装了四道提交闸门,越界直接拒绝提交
ai编程·cursor