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?
相关推荐
泽泽爱旅行2 小时前
Python 开发常用语法
cursor
还有几根头发呀2 天前
Cursor 接入 DeepSeek‑V4‑Pro 完整指南(2026 实测)
ai编程·cursor·deepseek‑v4‑pro
YuTaoShao3 天前
Cursor 的上下文工程新思路:把一切变成文件
ai·agent·cursor·上下文工程
八号当铺3 天前
从 Prompt 到 AI 工程化:理解 Rules、Skills 与 Agent
前端·ai编程·cursor
CV-deeplearning4 天前
太方便了!一个 App 统管 15+ AI 编程工具的 Skills,再也不用来回折腾了
copilot·cursor·claudecode·ai编程工具·skillsmanager
小村儿5 天前
马斯克AI战略封神!解散xAI,租算力,收购Cursor
openai·cursor·grok
Flynt6 天前
谷歌75%代码由AI生成?我扒了扒Claude Code的实现原理和真实效果
ai编程·claude·cursor
卷Java8 天前
Cursor实测一周 vs Copilot一周 vs Windsurf一周,真实数据对比
cursor·windsurf
宅小年8 天前
我用了两年 Cursor,总结了 8 个省 Token 的实战技巧
ai编程·cursor