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?
相关推荐
ServBay7 小时前
Cursor披露恶意扩展,怎么守住本地 API Key
后端·ai编程·cursor
灵感__idea7 天前
“小猫补光灯”:App Store 付费榜第一的产品故事
ai编程·claude·cursor
ServBay11 天前
从代码到上线,Cursor Live Apps 能替独立开发者做什么
后端·ai编程·cursor
梯度下降者14 天前
3天时间,我使用 Cursor 开发了一个提示词生成器
ai编程·next.js·cursor·产品开发·提示词生成器
七牛开发者15 天前
AI Agent 的安全风险,正在从 Prompt 扩展到运行环境
ai·agent·security·权限管理·cursor
小七-七牛开发者15 天前
AI Agent 的安全风险,正在从 Prompt 扩展到运行环境
ai·agent·security·权限管理·cursor
灵感__idea16 天前
Claude Code:能干活只是初级目标,再提10倍
ai编程·claude·cursor
尘世中一位迷途小书童17 天前
别再堆万字 Prompt:用 Agent Skills 给团队写一个「前端 Review」Skill
前端·ai编程·cursor
用户5394187290718 天前
强弱模型路由跑起来就成了黑盒?我给每趟路由记了笔账,命中率、白升级一目了然,分级表越调越准
ai编程·cursor
_小许_21 天前
AI IDE 与 Agent Harness:一次说清 Cursor、Codex 该怎么选
ide·人工智能·ai编程·cursor·codex