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?
相关推荐
Flynt4 天前
我扒了Fantastic-admin 6.0的源码,聊聊"AI时代版本答案"这个称号
vue.js·ai编程·cursor
陈大鱼头6 天前
什么?Cursor 也做了一个 GitHub ?
cursor
大草原的小灰灰6 天前
Cursor极速上手指南
ai编程·cursor
FEF前端团队6 天前
Cursor 使用指南 01#:优化你的提示词
ai编程·cursor
苏灿烤鱼7 天前
Cursor 官方插件仓,许可证未声明
typescript·agent·cursor
仙逆GPT9 天前
ChatGPT、Codex实战:从Claude Code / Cursor迁移到Codex怎么做?/import最容易漏掉哪些配置?
cursor·codex·chatgptplus·claudecode·codex教程
Lumi_Peak11 天前
我把10万字项目文档丢给 Cursor,它居然真没崩
ai编程·cursor
云卷云舒___________12 天前
Grok4.6上线Cursor、GPT5.6-Cyber发布、谷歌搁置Gemini3.5Pro | 8月11日 AI日报
openai·谷歌·cursor·ai日报·grok46·gpt56cyber·daybreak
Cerrda12 天前
把团队 Mock 工作流做成可安装 Skill:faker-mock-setup 上架 skills.sh 实践
ai编程·cursor
把所有砖敲烂12 天前
AI 工具选型:豆包、WorkBuddy、Codex 与 Hermes 实践
openai·cursor