minimax-m4 即 MiniMax M4:上下文 1M token,支持图片输入;思考始终开启,可用 reasoning_effort 在 low 到 max 之间调节强度;支持工具调用和 JSON 输出,整个上下文窗口按同一单价计费。
鉴权
- Base URL
- Authorization
Authorization: Bearer YOUR_API_KEY- Content-Type
application/json- 模型名 (model)
minimax-m4
接入协议
为什么选这个协议
适合已有 OpenAI SDK、Chat Completions 代码或统一网关接入的用户。
接口地址
POST/v1/chat/completions
Authorization: Bearer YOUR_API_KEYContent-Type: application/json请求 / 响应 JSON
请求
{
"stop": [
"\n\n\n"
],
"model": "minimax-m4",
"top_p": 0.95,
"stream": false,
"messages": [
{
"role": "user",
"content": "你好,世界"
}
],
"max_tokens": 4096,
"temperature": 1,
"reasoning_effort": "medium"
}响应
{
"id": "chatcmpl_example",
"model": "minimax-m4",
"usage": {
"total_tokens": 24,
"prompt_tokens": 8,
"completion_tokens": 16
},
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello from Mix API"
},
"finish_reason": "stop"
}
],
"created": 1710000000
}请求字段 / 响应字段
请求字段
| 字段 | 类型 | 必填 | 默认 | 可选值 / 范围 | 说明 | 示例 |
|---|---|---|---|---|---|---|
| messages | array | Y | - | - | Chat Completions 消息数组;用户消息可以带 image_url 图片(公开 URL 或 base64)。 | [{"role":"user","content":"你好,世界"}] |
| temperature | number | N | - | - | 控制随机性。 | 1 |
| top_p | number | N | - | - | 核采样概率阈值。 | 0.95 |
| max_tokens | integer | N | - | - | 限制本次响应的最大长度,推理 token 也计入其中。 | 4096 |
| stop | array | N | - | - | 遇到这些字符串时停止生成。 | ["\n\n\n"] |
| stream | boolean | N | false | - | 是否以 SSE 流式返回。 | false |
| stream_options | object | N | - | - | 流式响应附加选项,例如 include_usage。 | {"include_usage":true} |
| reasoning_effort | enum | N | - | low, medium, high, xhigh, max | MiniMax M4 始终思考(不能关闭),这里设置思考投入的强度。推理 token 按输出计费。 | medium |
| response_format | object | N | - | - | 要求模型返回 JSON object 等结构化格式;在提示里说明要的字段。 | {"type":"json_object"} |
| tools | array | N | - | - | 函数调用(function calling)定义。 | [] |
| tool_choice | enum | N | - | none, auto | 控制工具调用策略。 | auto |
响应字段
| 字段 | 类型 | 必填 | 默认 | 可选值 / 范围 | 说明 | 示例 |
|---|---|---|---|---|---|---|
| id | string | N | - | - | - | chatcmpl_example |
| object | string | N | - | - | - | chat.completion |
| created | integer | N | - | - | - | 1710000000 |
| model | string | N | - | - | - | minimax-m4 |
| choices | array | N | - | - | - | [{"index":0,"message":{"role":"assistant","content":"Hello from Mix API"},"finish_reason":"stop"}] |
| choices[] | object | N | - | - | - | {"index":0,"message":{"role":"assistant","content":"Hello from Mix API"},"finish_reason":"stop"} |
| choices[].index | integer | N | - | - | - | 0 |
| choices[].message | object | N | - | - | - | {"role":"assistant","content":"Hello from Mix API"} |
| choices[].message.role | string | N | - | - | - | assistant |
| choices[].message.content | string | N | - | - | - | Hello from Mix API |
| choices[].finish_reason | string | N | - | - | - | stop |
| usage | object | N | - | - | - | {"total_tokens":24,"prompt_tokens":8,"completion_tokens":16} |
| usage.prompt_tokens | integer | N | - | - | - | 8 |
| usage.completion_tokens | integer | N | - | - | - | 16 |
| usage.total_tokens | integer | N | - | - | - | 24 |
代码示例
cURLrequest.sh
curl -X POST "https://api.dreamto.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "minimax-m4",
"messages": [
{
"role": "user",
"content": "你好,世界"
}
],
"temperature": 1,
"top_p": 0.95,
"max_tokens": 4096,
"stop": [
"\n\n\n"
],
"stream": false,
"reasoning_effort": "medium"
}'