File size: 5,049 Bytes
d69e848
 
09b5534
 
 
d69e848
09b5534
ab0cf4f
d69e848
 
 
09b5534
 
7270816
ab0cf4f
 
 
09b5534
f238f35
51159ea
 
f238f35
 
 
 
 
 
 
 
 
 
 
 
 
 
7270816
f238f35
 
 
 
 
 
 
51159ea
 
7270816
f238f35
7270816
f238f35
7270816
 
f238f35
7270816
 
 
f238f35
7270816
 
 
 
 
 
 
 
 
09b5534
7270816
 
 
 
 
 
 
09b5534
7270816
09b5534
51159ea
f238f35
09b5534
f238f35
51159ea
 
09b5534
f238f35
 
 
7270816
51159ea
f238f35
7270816
 
 
 
 
 
 
 
 
51159ea
 
7270816
 
 
f238f35
51159ea
f238f35
51159ea
f238f35
 
51159ea
 
7270816
f238f35
7270816
 
f238f35
 
7270816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51159ea
f238f35
 
7270816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f238f35
 
 
 
 
 
 
 
 
7270816
f238f35
7270816
f238f35
 
09b5534
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
title: Docker Model Runner
emoji: 🐳
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
suggested_hardware: cpu-basic
pinned: false
---

# Docker Model Runner

**Anthropic API Compatible** with **Interleaved Thinking** support.

## Hardware
- **CPU Basic**: 2 vCPU Β· 16 GB RAM

## Quick Start

```bash
pip install anthropic
export ANTHROPIC_BASE_URL=https://likhonsheikhdev-docker-model-runner.hf.space
export ANTHROPIC_API_KEY=any-key
```

```python
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="MiniMax-M2",
    max_tokens=1000,
    system="You are a helpful assistant.",
    messages=[{"role": "user", "content": "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")
```

## Interleaved Thinking

Enable thinking to get reasoning steps interleaved with responses:

```python
import anthropic

client = anthropic.Anthropic(
    base_url="https://likhonsheikhdev-docker-model-runner.hf.space"
)

message = client.messages.create(
    model="MiniMax-M2",
    max_tokens=1024,
    thinking={
        "type": "enabled",
        "budget_tokens": 200
    },
    messages=[{"role": "user", "content": "Explain quantum computing"}]
)

# Response contains interleaved thinking and text blocks
for block in message.content:
    if block.type == "thinking":
        print(f"πŸ’­ Thinking: {block.thinking}")
    elif block.type == "text":
        print(f"πŸ“ Response: {block.text}")
```

## Streaming with Thinking

```python
import anthropic

client = anthropic.Anthropic(
    base_url="https://likhonsheikhdev-docker-model-runner.hf.space"
)

with client.messages.stream(
    model="MiniMax-M2",
    max_tokens=1024,
    thinking={"type": "enabled", "budget_tokens": 100},
    messages=[{"role": "user", "content": "Hello!"}]
) as stream:
    for event in stream:
        if hasattr(event, 'type'):
            if event.type == 'content_block_start':
                print(f"\n[{event.content_block.type}]", end=" ")
            elif event.type == 'content_block_delta':
                if hasattr(event.delta, 'thinking'):
                    print(event.delta.thinking, end="")
                elif hasattr(event.delta, 'text'):
                    print(event.delta.text, end="")
```

## Multi-Turn with Thinking History

**Important**: In multi-turn conversations, append the complete model response (including thinking blocks) to maintain reasoning chain continuity.

```python
import anthropic

client = anthropic.Anthropic(
    base_url="https://likhonsheikhdev-docker-model-runner.hf.space"
)

messages = [{"role": "user", "content": "What is 2+2?"}]

# First turn
response = client.messages.create(
    model="MiniMax-M2",
    max_tokens=1024,
    thinking={"type": "enabled", "budget_tokens": 100},
    messages=messages
)

# Append full response (including thinking) to history
messages.append({
    "role": "assistant",
    "content": response.content  # Includes both thinking and text blocks
})

# Second turn
messages.append({"role": "user", "content": "Now multiply that by 3"})

response2 = client.messages.create(
    model="MiniMax-M2",
    max_tokens=1024,
    thinking={"type": "enabled", "budget_tokens": 100},
    messages=messages
)
```

## Supported Models

| Model | Description |
|-------|-------------|
| MiniMax-M2 | Agentic capabilities, Advanced reasoning |
| MiniMax-M2-Stable | High concurrency and commercial use |

## API Compatibility

### Parameters

| Parameter | Status |
|-----------|--------|
| model | βœ… Fully supported |
| messages | βœ… Partial (text, tool calls) |
| max_tokens | βœ… Fully supported |
| stream | βœ… Fully supported |
| system | βœ… Fully supported |
| temperature | βœ… Range (0.0, 1.0] |
| thinking | βœ… Fully supported |
| thinking.budget_tokens | βœ… Fully supported |
| tools | βœ… Fully supported |
| tool_choice | βœ… Fully supported |
| top_p | βœ… Fully supported |
| metadata | βœ… Fully supported |
| top_k | βšͺ Ignored |
| stop_sequences | βšͺ Ignored |

### Message Types

| Type | Status |
|------|--------|
| text | βœ… Supported |
| thinking | βœ… Supported |
| tool_use | βœ… Supported |
| tool_result | βœ… Supported |
| image | ❌ Not supported |
| document | ❌ Not supported |

## Endpoints

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/v1/messages` | POST | Anthropic Messages API |
| `/v1/chat/completions` | POST | OpenAI Chat API |
| `/v1/models` | GET | List models |
| `/health` | GET | Health check |
| `/info` | GET | API info |

## cURL Example

```bash
curl -X POST https://likhonsheikhdev-docker-model-runner.hf.space/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: any-key" \
  -d '{
    "model": "MiniMax-M2",
    "max_tokens": 1024,
    "thinking": {"type": "enabled", "budget_tokens": 100},
    "messages": [
      {"role": "user", "content": "Explain AI briefly"}
    ]
  }'
```