Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
A comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/interleaved-thinking/docs/m2-1.md
1# Compatible Anthropic API23> Call MiniMax models using the Anthropic SDK45To meet developers' needs for the Anthropic API ecosystem, our API now supports the Anthropic API format. With simple configuration, you can integrate MiniMax capabilities into the Anthropic API ecosystem.67## Quick Start89### 1. Install Anthropic SDK1011<CodeGroup>12```bash Python theme={null}13pip install anthropic14```1516```bash Node.js theme={null}17npm install @anthropic-ai/sdk18```19</CodeGroup>2021### 2. Configure Environment Variables2223For international users, use `https://api.minimax.io/anthropic`; for users in China, use `https://api.minimaxi.com/anthropic`2425```bash theme={null}26export ANTHROPIC_BASE_URL=https://api.minimax.io/anthropic27export ANTHROPIC_API_KEY=${YOUR_API_KEY}28```2930### 3. Call API3132```python Python theme={null}33import anthropic3435client = anthropic.Anthropic()3637message = client.messages.create(38model="MiniMax-M2.1",39max_tokens=1000,40system="You are a helpful assistant.",41messages=[42{43"role": "user",44"content": [45{46"type": "text",47"text": "Hi, how are you?"48}49]50}51]52)5354for block in message.content:55if block.type == "thinking":56print(f"Thinking:\n{block.thinking}\n")57elif block.type == "text":58print(f"Text:\n{block.text}\n")59```6061### 4. Important Note6263In multi-turn function call conversations, the complete model response (i.e., the assistant message) must be append to the conversation history to maintain the continuity of the reasoning chain.6465* Append the full `response.content` list to the message history (includes all content blocks: thinking/text/tool\_use)6667## Supported Models6869When using the Anthropic SDK, the `MiniMax-M2.1` `MiniMax-M2.1-lightning` `MiniMax-M2` model is supported:7071| Model Name | Description |72| :--------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |73| MiniMax-M2.1 | Powerful Multi-Language Programming Capabilities with Comprehensively Enhanced Programming Experience (output speed approximately 60 tps) |74| MiniMax-M2.1-lightning | Faster and More Agile (output speed approximately 100 tps) |75| MiniMax-M2 | Agentic capabilities, Advanced reasoning |7677<Note>78The Anthropic API compatibility interface currently only supports the79`MiniMax-M2.1` `MiniMax-M2.1-lightning` `MiniMax-M2` model. For other models, please use the standard MiniMax API80interface.81</Note>8283## Compatibility8485### Supported Parameters8687When using the Anthropic SDK, we support the following input parameters:8889| Parameter | Support Status | Description |90| :------------------- | :-------------- | :------------------------------------------------------------------ |91| `model` | Fully supported | supports `MiniMax-M2.1` `MiniMax-M2.1-lightning` `MiniMax-M2` model |92| `messages` | Partial support | Supports text and tool calls, no image/document input |93| `max_tokens` | Fully supported | Maximum number of tokens to generate |94| `stream` | Fully supported | Streaming response |95| `system` | Fully supported | System prompt |96| `temperature` | Fully supported | Range (0.0, 1.0], controls output randomness, recommended value: 1 |97| `tool_choice` | Fully supported | Tool selection strategy |98| `tools` | Fully supported | Tool definitions |99| `top_p` | Fully supported | Nucleus sampling parameter |100| `metadata` | Fully Supported | Metadata |101| `thinking` | Fully Supported | Reasoning Content |102| `top_k` | Ignored | This parameter will be ignored |103| `stop_sequences` | Ignored | This parameter will be ignored |104| `service_tier` | Ignored | This parameter will be ignored |105| `mcp_servers` | Ignored | This parameter will be ignored |106| `context_management` | Ignored | This parameter will be ignored |107| `container` | Ignored | This parameter will be ignored |108109### Messages Field Support110111| Field Type | Support Status | Description |112| :------------------- | :-------------- | :------------------------------- |113| `type="text"` | Fully supported | Text messages |114| `type="tool_use"` | Fully supported | Tool calls |115| `type="tool_result"` | Fully supported | Tool call results |116| `type="thinking"` | Fully supported | Reasoning Content |117| `type="image"` | Not supported | Image input not supported yet |118| `type="document"` | Not supported | Document input not supported yet |119120## Examples121122### Streaming Response123124```python Python theme={null}125import anthropic126127client = anthropic.Anthropic()128129print("Starting stream response...\n")130print("=" * 60)131print("Thinking Process:")132print("=" * 60)133134stream = client.messages.create(135model="MiniMax-M2.1",136max_tokens=1000,137system="You are a helpful assistant.",138messages=[139{"role": "user", "content": [{"type": "text", "text": "Hi, how are you?"}]}140],141stream=True,142)143144reasoning_buffer = ""145text_buffer = ""146147for chunk in stream:148if chunk.type == "content_block_start":149if hasattr(chunk, "content_block") and chunk.content_block:150if chunk.content_block.type == "text":151print("\n" + "=" * 60)152print("Response Content:")153print("=" * 60)154155elif chunk.type == "content_block_delta":156if hasattr(chunk, "delta") and chunk.delta:157if chunk.delta.type == "thinking_delta":158# Stream output thinking process159new_thinking = chunk.delta.thinking160if new_thinking:161print(new_thinking, end="", flush=True)162reasoning_buffer += new_thinking163elif chunk.delta.type == "text_delta":164# Stream output text content165new_text = chunk.delta.text166if new_text:167print(new_text, end="", flush=True)168text_buffer += new_text169170print("\n")171```172173### Tool Use & Interleaved Thinking174175Learn how to use M2.1 Tool Use and Interleaved Thinking capabilities with Anthropic SDK, please refer to the following documentation.176177<Columns cols={1}>178<Card title="M2.1 Tool Use & Interleaved Thinking" icon="book-open" href="/guides/text-m2-function-call#anthropic-sdk" arrow="true" cta="Click here">179Learn how to leverage MiniMax-M2.1 tool calling and interleaved thinking capabilities to enhance performance in complex tasks.180</Card>181</Columns>182183## Important Notes184185<Warning>1861. The Anthropic API compatibility interface currently only supports the `MiniMax-M2.1` `MiniMax-M2` model1871882. The `temperature` parameter range is (0.0, 1.0], values outside this range will return an error1891903. Some Anthropic parameters (such as `thinking`, `top_k`, `stop_sequences`, `service_tier`, `mcp_servers`, `context_management`, `container`) will be ignored1911924. Image and document type inputs are not currently supported193</Warning>194195## Related Links196197* [Anthropic SDK Documentation](https://docs.anthropic.com/en/api/client-sdks)198* [MiniMax Text Generation API](/api-reference/text-intro)199* [M2.1 Tool Use & Interleaved Thinking](/guides/text-m2-function-call)200201## Recommended Reading202203<Columns cols={2}>204<Card title="Text Generation" icon="book-open" href="/guides/text-generation" arrow="true" cta="Click here">205Supports text generation via compatible Anthropic API and OpenAI API.206</Card>207208<Card title="Compatible OpenAI API" icon="book-open" href="/api-reference/text-openai-api" arrow="true" cta="Click here">209Use OpenAI SDK with MiniMax models210</Card>211212<Card title="M2.1 for AI Coding Tools" icon="book-open" href="/guides/text-ai-coding-tools" arrow="true" cta="Click here">213MiniMax-M2.1 excels at code understanding, dialogue, and reasoning.214</Card>215216<Card title="M2.1 Tool Use & Interleaved Thinking" icon="book-open" href="/guides/text-m2-function-call" arrow="true" cta="Click here">217AI models can call external functions to extend their capabilities.218</Card>219</Columns>220221222---223224> To find navigation and other pages in this documentation, fetch the llms.txt file at: https://platform.minimax.io/docs/llms.txt