Skip to main content
1

Install Anthropic SDK

pip install anthropic
2

Call API

Python
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?"
                }
            ]
        }
    ]
)

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")
3

Example output

{
  "thinking": "The user is just greeting me casually. I should respond in a friendly, professional manner.",
  "text": "Hi there! I'm doing well, thanks for asking. I'm ready to help you with whatever you need today—whether it's coding, answering questions, brainstorming ideas, or just chatting. What can I do for you?"
}

Next steps

Text Generation

Explore MiniMax’s latest text models

Image to Video

Create image-to-video tasks with Hailuo 2.3

Text to Video

Create text-to-video tasks with Hailuo 2.3

Synchronous Text-to-Speech

Perform real-time speech synthesis with Speech 2.6

Async Long TTS

Perform asynchronous speech synthesis with Speech 2.6

Voice Clone

Create voice cloning tasks

Music Generation

Compose music with Music 2.5+