API 參考聊天
OpenAI 相容 API
使用 OpenAI 相容端點,透過標準 Chat Completions 格式與 MiMo 模型互動。
端點
POST https://api.mimo-v2.com/v1/chat/completions認證
使用以下任一請求頭進行身份驗證:
| 請求頭 | 格式 |
|---|---|
api-key | <your-api-key> |
Authorization | Bearer <your-api-key> |
您可以在 Mimo 控制檯的 設定 → API 金鑰 中生成 API 金鑰。
請求引數
| 引數 | 型別 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 模型 ID。可選值:mimo-v2-pro、mimo-v2-omni、mimo-v2-flash |
messages | array | 是 | 訊息物件陣列,包含 role 和 content |
max_completion_tokens | integer | 否 | 最大生成 token 數(預設值因模型而異) |
temperature | number | 否 | 取樣溫度,0-2(預設:1.0) |
top_p | number | 否 | 核取樣閾值,0-1(預設:0.95) |
stream | boolean | 否 | 啟用流式輸出(預設:false) |
stop | string/array | 否 | 停止序列 |
frequency_penalty | number | 否 | 頻率懲罰,-2 到 2(預設:0) |
presence_penalty | number | 否 | 存在懲罰,-2 到 2(預設:0) |
tools | array | 否 | 工具/函式定義列表 |
tool_choice | string/object | 否 | 工具選擇策略:auto、none 或指定工具 |
訊息物件
| 欄位 | 型別 | 說明 |
|---|---|---|
role | string | 可選值:system、user、assistant、tool |
content | string/array | 訊息內容(文字或多模態內容陣列) |
reasoning_content | string | (可選)模型的思考/推理內容 |
tool_calls | array | (可選)助手發起的工具呼叫 |
請求示例
curl https://api.mimo-v2.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "api-key: YOUR_API_KEY" \
-d '{
"model": "mimo-v2-pro",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你好,你是誰?"}
],
"max_completion_tokens": 1024,
"temperature": 0.7
}'響應格式
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1711234567,
"model": "mimo-v2-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I am MiMo...",
"reasoning_content": "The user asked me to introduce myself..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 50,
"completion_tokens": 100,
"total_tokens": 150
}
}響應欄位
| 欄位 | 說明 |
|---|---|
id | 補全的唯一識別符號 |
object | 固定為 chat.completion |
created | 響應建立的 Unix 時間戳 |
model | 用於補全的模型 |
choices | 補全選項陣列 |
choices[].message.content | 生成的文字響應 |
choices[].message.reasoning_content | 模型的內部推理(可用時) |
choices[].finish_reason | 模型停止原因:stop、length 或 tool_calls |
usage | Token 使用統計 |
流式響應
當 stream 設為 true 時,API 返回 Server-Sent Events(SSE)。每個事件包含一個部分響應塊。
流式請求示例
curl https://api.mimo-v2.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "api-key: YOUR_API_KEY" \
-d '{
"model": "mimo-v2-pro",
"messages": [
{"role": "user", "content": "你好!"}
],
"stream": true
}'流式事件格式
每個 SSE 事件以 data: 為字首,包含一個 JSON 塊。流以 data: [DONE] 事件結束。
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"你"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"好"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]在流式模式下,reasoning_content 可能出現在主 content 之前的早期 delta 塊中。
MiMo API 文件