Xiaomi MiMo V2.5 系列 OpenAI 兼容对话补全接口完整文档。支持多轮对话、深度思考、工具调用、联网搜索、语音合成、图像/视频输入等全功能。
MiMo Chat Completions API 是小米大语言模型提供的 OpenAI 兼容对话补全接口,支持 RESTful HTTP 协议,所有请求与响应均使用 JSON 格式。流式响应采用 SSE(Server-Sent Events)。
| 项目 | 值 |
|---|---|
| Base URL | https://api.xiaomimimo.com/v1/chat/completions |
| 协议 | HTTPS (POST) |
| 认证方式 | api-key Header 或 Authorization Bearer |
| 内容类型 | application/json |
| SDK 兼容 | OpenAI Python / Node.js SDK(修改 base_url 即可) |
| 文档日期 | 2026-07-15 |
| 更新时间 | 2026-06-29(官方) |
支持 system/user/assistant/developer/tool 多角色消息
思维链推理,返回 reasoning_content
Function Calling + Web Search 工具
自动联网检索并返回引用注释
支持图像、音频、视频输入
TTS / Voice Design / Voice Clone
流式输出,降低首字延迟
获取 API Key 后即可开始调用。支持 OpenAI SDK 兼容格式,也可直接使用 HTTP 请求。
bashcurl --location --request POST 'https://api.xiaomimimo.com/v1/chat/completions' \
--header "api-key: $MIMO_API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"model": "mimo-v2.5-pro",
"messages": [
{
"role": "system",
"content": "You are MiMo, an AI assistant developed by Xiaomi."
},
{
"role": "user",
"content": "你好,请介绍一下自己"
}
],
"max_completion_tokens": 1024,
"temperature": 1.0,
"top_p": 0.95,
"stream": false,
"thinking": {
"type": "disabled"
}
}'
pythonfrom openai import OpenAI
client = OpenAI(
api_key="$MIMO_API_KEY",
base_url="https://api.xiaomimimo.com/v1"
)
response = client.chat.completions.create(
model="mimo-v2.5-pro",
messages=[
{"role": "system", "content": "You are MiMo, an AI assistant developed by Xiaomi."},
{"role": "user", "content": "你好,请介绍一下自己"}
],
max_completion_tokens=1024,
temperature=1.0,
thinking={"type": "disabled"}
)
print(response.choices[0].message.content)
| 模型 ID | 类型 | 默认 max_tokens | 深度思考 | 工具调用 | 语音合成 | 联网搜索 |
|---|---|---|---|---|---|---|
mimo-v2.5-pro | 旗舰文本 | 131072 | ✅ 支持 | ✅ 支持 | ❌ | ✅ 支持 |
mimo-v2.5 | 标准文本 | 32768 | ✅ 支持 | ✅ 支持 | ❌ | ✅ 支持 |
mimo-v2.5-tts | 语音合成 | 8192 | ❌ | ❌ | ✅ 预置音色 | ❌ |
mimo-v2.5-tts-voicedesign | 音色设计 | 8192 | ❌ | ❌ | ✅ 音色设计 | ❌ |
mimo-v2.5-tts-voiceclone | 声音克隆 | 8192 | ❌ | ❌ | ✅ 声音克隆 | ❌ |
1.0;TTS 系列默认 0.6
接口支持以下两种认证方式,选择其中一种添加到请求头中:
httpapi-key: $MIMO_API_KEY
Content-Type: application/json
httpAuthorization: Bearer $MIMO_API_KEY
Content-Type: application/json
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | 必选 | 模型 ID。可选值:mimo-v2.5-pro, mimo-v2.5, mimo-v2.5-tts, mimo-v2.5-tts-voicedesign, mimo-v2.5-tts-voiceclone |
messages | array | 必选 | 对话消息列表。支持 role: system / user / assistant / developer / tool |
messages[].role | string | 必选 | 角色:system / user / assistant / developer / tool |
messages[].content | string | array | 必选 | 消息内容。支持纯文本或多模态 content parts 数组 |
messages[].name | string | 可选 | 参与者名称,用于区分相同角色的不同参与者 |
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
max_completion_tokens | integer | null | 可选 | 生成 token 上限(含推理 token)。pro 默认 131072;标准版 32768;TTS 系列 8192。范围 [1, 131072] |
temperature | number | 可选 | 采样温度 [0, 1.5]。pro/标准默认 1.0;TTS 默认 0.6。思考模式下不可自定义 |
top_p | number | 可选 | 核采样概率 [0.01, 1.0],默认 0.95。建议仅与 temperature 二选一。思考模式下不可自定义 |
frequency_penalty | number | null | 可选 | 频率惩罚 [-2.0, 2.0],默认 0 |
presence_penalty | number | null | 可选 | 存在惩罚 [-2.0, 2.0],默认 0 |
stop | string | array | null | 可选 | 停止序列(最多 4 个)。TTS 系列不支持 |
stream | boolean | null | 可选 | 是否 SSE 流式传输,默认 false |
response_format | object | 可选 | 指定输出格式。TTS 系列不支持 |
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
thinking | object | 可选 | 思维链控制。TTS 系列不支持 |
thinking.type | string | 可选 | "enabled"(默认)或 "disabled" |
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
tools | array | 可选 | 工具列表。支持 function 和 web_search 两种类型。TTS 系列不支持 |
tools[].type | string | 必选 | 工具类型:"function" 或 "web_search" |
tools[].function.name | string | 必选 | 函数名(a-z, A-Z, 0-9, _, -),最大 64 字符 |
tools[].function.description | string | 可选 | 功能描述 |
tools[].function.parameters | object | 可选 | JSON Schema 格式的参数定义 |
tools[].function.strict | boolean | 可选 | 是否严格遵循 schema,默认 false |
tool_choice | string | 可选 | 仅支持 "auto"。传入其他值会被后端移除。TTS 系列不支持 |
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
audio | object | 可选 | 音频输出参数。仅 TTS 系列模型支持 |
audio.format | string | 可选 | 输出格式:wav(默认) / mp3 / pcm / pcm16。stream:true 时默认 pcm |
audio.voice | string | 可选 | 预置音色 ID 或 base64 音频样本。TTS 预置:mimo_default, 冰糖, 茉莉, 苏打, 白桦, Mia, Chloe, Milo, Dean |
audio.optimize_text_preview | boolean | 可选 | 智能润色播报文本,默认 false。仅 voicedesign 模型支持 |
role: "assistant" 的消息指定合成文本。使用 voicedesign + optimize_text_preview=true 时可省略 assistant 消息。
当 stream: false 时,API 返回完整的 chat.completion 对象。
| 字段名 | 类型 | 描述 |
|---|---|---|
id | string | 响应的唯一标识符 |
object | string | 固定值 "chat.completion" |
created | integer | Unix 时间戳(秒) |
model | string | 实际使用的模型 ID |
| 字段名 | 类型 | 描述 |
|---|---|---|
choices[].index | integer | 选项索引 |
choices[].finish_reason | string | 停止原因:stop / length / tool_calls / content_filter / repetition_truncation |
choices[].message.content | string | 回复内容 |
choices[].message.reasoning_content | string | 思维链推理内容(思考模式) |
choices[].message.role | string | 固定为 "assistant" |
choices[].message.tool_calls | array | 工具调用列表(如有) |
choices[].message.tool_calls[].id | string | 工具调用 ID |
choices[].message.tool_calls[].type | string | 固定为 "function" |
choices[].message.tool_calls[].function.name | string | 被调用的函数名 |
choices[].message.tool_calls[].function.arguments | string | JSON 格式的调用参数 |
choices[].message.annotations | array | 联网搜索引用注释(如有) |
choices[].message.audio | object | 音频响应数据(TTS 请求时) |
choices[].message.audio.id | string | 音频唯一标识 |
choices[].message.audio.data | string | Base64 编码的音频数据 |
choices[].final_text_preview | string | 优化后的播报文本(optimize_text_preview 时返回) |
| 字段名 | 类型 | 描述 |
|---|---|---|
usage.prompt_tokens | integer | 提示词 token 数 |
usage.completion_tokens | integer | 输出 token 数 |
usage.total_tokens | integer | 总 token 数 |
usage.completion_tokens_details.reasoning_tokens | integer | 推理 token 数 |
usage.prompt_tokens_details.cached_tokens | integer | 缓存命中的 token 数 |
usage.prompt_tokens_details.audio_tokens | integer | 音频输入 token 数 |
usage.prompt_tokens_details.image_tokens | integer | 图像输入 token 数 |
usage.prompt_tokens_details.video_tokens | integer | 视频输入 token 数 |
usage.web_search_usage.tool_usage | integer | 联网搜索 API 调用次数 |
usage.web_search_usage.page_usage | integer | 联网搜索返回网页数 |
json{
"id": "8b51f9e0515949cb8207fbd35ea6ea5c",
"object": "chat.completion",
"created": 1776848906,
"model": "mimo-v2.5-pro",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! I'm MiMo, Xiaomi's AI assistant created by the Xiaomi LLM-Core team...",
"role": "assistant",
"tool_calls": null
}
}
],
"usage": {
"completion_tokens": 72,
"prompt_tokens": 57,
"total_tokens": 129,
"completion_tokens_details": {
"reasoning_tokens": 0
},
"prompt_tokens_details": null
}
}
当 stream: true 时,API 通过 SSE 以 chat.completion.chunk 格式增量返回数据。
data: {...} 行发送,结束标记为 data: [DONE]。
| 字段名 | 类型 | 描述 |
|---|---|---|
object | string | 固定值 "chat.completion.chunk" |
choices[].delta | object | 增量数据(替代 message) |
choices[].delta.content | string | 本 chunk 的文本增量 |
choices[].delta.reasoning_content | string | 本 chunk 的推理增量 |
choices[].delta.role | string | 首个 chunk 中的角色(通常为 "assistant") |
choices[].delta.tool_calls | array | 增量工具调用(含 index 定位) |
choices[].delta.tool_calls[].index | integer | 工具调用在列表中的索引(从 0 开始) |
choices[].delta.audio | object | null | 音频增量数据 |
choices[].finish_reason | string | null | 最后一个 chunk 的停止原因 |
其余字段(id, created, model, usage, annotations 等)与非流式相同,通常仅在最后一个 chunk 中返回 usage。
MiMo V2.5 Pro 和标准版支持思维链(Chain-of-Thought)推理,让模型在回答前进行深度推理。适用于数学、逻辑、编程、复杂分析等场景。
| 参数名 | 类型 | 描述 |
|---|---|---|
thinking.type | string | "enabled"(默认)启用 / "disabled" 关闭 |
reasoning_content 字段包含模型的推理过程,content 为最终回答temperature 强制为 1.0,top_p 强制为 0.95,自定义无效tool_calls 和 reasoning_contentMiMo 支持 Function Calling,允许模型调用外部函数获取信息或执行操作。同时内置 Web Search 联网搜索工具。
| 特性 | 描述 |
|---|---|
| 工具类型 | function(函数工具)+ web_search(联网搜索) |
| tool_choice | 仅支持 "auto"。传入其他值会被后端移除 |
| strict 模式 | 支持 strict: true,严格遵循 JSON Schema(子集) |
| 思考模式兼容 | V2.5 Pro/标准版支持思考模式下的工具调用 |
json{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取指定城市的当前天气信息",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string", "description": "城市名称" }
},
"required": ["location"]
},
"strict": false
}
}
MiMo 内置 Web Search 工具,模型可自动联网检索最新信息并在回答中引用来源。
在 tools 数组中添加 web search 类型的工具:
json{
"tools": [
{ "type": "web_search" }
]
}
| 字段名 | 类型 | 描述 |
|---|---|---|
annotations[].title | string | 引用页面标题 |
annotations[].url | string | 引用网址 |
annotations[].site_name | string | 网站名称 |
annotations[].summary | string | 内容摘要 |
annotations[].publish_time | string | 发布时间 |
annotations[].logo_url | string | 网站 Logo 地址 |
annotations[].type | string | 类型 |
error_message | string | 联网搜索错误信息(如有) |
MiMo 提供三种 TTS 能力,通过不同的模型和 audio 参数组合实现。
| 能力 | 模型 | audio.voice | 特点 |
|---|---|---|---|
| 预置音色 TTS | mimo-v2.5-tts | 可选,预置音色名 | 9 种预置音色,默认 mimo_default |
| 音色设计 | mimo-v2.5-tts-voicedesign | 不支持 | 通过文字描述设计音色 |
| 声音克隆 | mimo-v2.5-tts-voiceclone | 必填,base64 音频 | 上传 3~10 秒音频样本克隆声音 |
| 音色 ID | 说明 |
|---|---|
mimo_default | 默认音色 |
冰糖 | 甜美女声 |
茉莉 | 温柔女声 |
苏打 | 清爽男声 |
白桦 | 沉稳男声 |
Mia | 英文女声 |
Chloe | 英文女声 |
Milo | 英文男声 |
Dean | 英文男声 |
| format 值 | 说明 |
|---|---|
wav | WAV 格式(默认) |
mp3 | MP3 格式 |
pcm / pcm16 | PCM16 格式(stream 模式下默认) |
pythonfrom openai import OpenAI
client = OpenAI(api_key="$MIMO_API_KEY", base_url="https://api.xiaomimimo.com/v1")
response = client.chat.completions.create(
model="mimo-v2.5-pro",
messages=[
{"role": "system", "content": "You are MiMo, an AI assistant developed by Xiaomi."},
{"role": "user", "content": "你好,请介绍一下自己"}
],
max_completion_tokens=1024,
temperature=1.0,
thinking={"type": "disabled"}
)
print(response.choices[0].message.content)
print(f"输入: {response.usage.prompt_tokens}, 输出: {response.usage.completion_tokens}")
bashcurl --location --request POST 'https://api.xiaomimimo.com/v1/chat/completions' \
--header "api-key: $MIMO_API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{"model":"mimo-v2.5-pro","messages":[{"role":"system","content":"You are MiMo."},{"role":"user","content":"你好"}],"max_completion_tokens":1024,"thinking":{"type":"disabled"}}'
pythonfrom openai import OpenAI
client = OpenAI(api_key="$MIMO_API_KEY", base_url="https://api.xiaomimimo.com/v1")
response = client.chat.completions.create(
model="mimo-v2.5-pro",
messages=[
{"role": "system", "content": "你是一个专业的编程助手。"},
{"role": "user", "content": "解释 JavaScript 的事件循环机制"}
],
stream=True
)
full_reply = ""
for chunk in response:
content = chunk.choices[0].delta.content
if content:
full_reply += content
print(content, end="", flush=True)
# 继续对话
messages.append({"role": "assistant", "content": full_reply})
messages.append({"role": "user", "content": "能给一个 async/await 的代码示例吗?"})
javascriptconst response = await fetch('https://api.xiaomimimo.com/v1/chat/completions', {
method: 'POST',
headers: {
'api-key': MIMO_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'mimo-v2.5-pro',
messages: [
{ role: 'system', content: '你是一个专业的编程助手。' },
{ role: 'user', content: '解释 JavaScript 的事件循环机制' }
],
stream: true
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split('\n');
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith('data: ') || line === 'data: [DONE]') continue;
const chunk = JSON.parse(line.slice(6));
const content = chunk.choices[0]?.delta?.content;
if (content) process.stdout.write(content);
}
}
pythonfrom openai import OpenAI
client = OpenAI(api_key="$MIMO_API_KEY", base_url="https://api.xiaomimimo.com/v1")
response = client.chat.completions.create(
model="mimo-v2.5-pro",
messages=[{"role": "user", "content": "9.11 和 9.8 哪个更大?"}],
extra_body={"thinking": {"type": "enabled"}}
)
msg = response.choices[0].message
print(f"[思考过程]\n{msg.reasoning_content}")
print(f"\n[最终回答]\n{msg.content}")
pythonfrom openai import OpenAI
client = OpenAI(api_key="$MIMO_API_KEY", base_url="https://api.xiaomimimo.com/v1")
response = client.chat.completions.create(
model="mimo-v2.5-pro",
messages=[{"role": "user", "content": "杭州今天天气怎么样?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取指定城市的当前天气信息",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "城市名称"}
},
"required": ["location"]
}
}
}]
)
tool_calls = response.choices[0].message.tool_calls
print("工具调用:", tool_calls)
pythonfrom openai import OpenAI
client = OpenAI(api_key="$MIMO_API_KEY", base_url="https://api.xiaomimimo.com/v1")
response = client.chat.completions.create(
model="mimo-v2.5-pro",
messages=[{"role": "user", "content": "今天有什么科技新闻?"}],
tools=[{"type": "web_search"}]
)
msg = response.choices[0].message
print("回答:", msg.content)
if msg.annotations:
print("\n引用来源:")
for ann in msg.annotations:
print(f" - [{ann.title}]({ann.url})")
pythonfrom openai import OpenAI
import base64
client = OpenAI(api_key="$MIMO_API_KEY", base_url="https://api.xiaomimimo.com/v1")
response = client.chat.completions.create(
model="mimo-v2.5-tts",
messages=[
{"role": "user", "content": "用甜美的声音为大家念一首诗"},
{"role": "assistant", "content": "床前明月光,疑是地上霜。举头望明月,低头思故乡。"}
],
audio={
"format": "wav",
"voice": "茉莉"
}
)
audio_data = response.choices[0].message.audio.data
audio_bytes = base64.b64decode(audio_data)
with output("output.wav", "wb") as f:
f.write(audio_bytes)
print("音频已保存到 output.wav")
| 错误码 | HTTP 状态 | 描述 |
|---|---|---|
invalid_api_key | 401 | API Key 无效或未提供 |
rate_limit_exceeded | 429 | 请求频率超限,请稍后重试 |
invalid_request | 400 | 请求参数错误(如缺少必填字段、模型不存在等) |
context_length_exceeded | 400 | 输入内容超出模型上下文长度限制 |
content_filter | 400 | 内容触发安全过滤策略 |
server_error | 500 | 服务器内部错误 |
model_not_found | 404 | 请求的模型不存在或已下线 |
stop — 自然结束 · length — 达到最大 token · tool_calls — 模型调用了工具content_filter — 内容被过滤 · repetition_truncation — 检测到复读截断