MiMo 语音合成(TTS)
curl --request POST \
--globoff \
--url 'https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"audio": {},
"stream": true,
"audio.format": "<string>",
"audio.voice": "<string>",
"audio.optimize_text_preview": true
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"audio": {},
"stream": True,
"audio.format": "<string>",
"audio.voice": "<string>",
"audio.optimize_text_preview": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
audio: {},
stream: true,
'audio.format': '<string>',
'audio.voice': '<string>',
'audio.optimize_text_preview': true
})
};
fetch('https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
]
],
'audio' => [
],
'stream' => true,
'audio.format' => '<string>',
'audio.voice' => '<string>',
'audio.optimize_text_preview' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"audio\": {},\n \"stream\": true,\n \"audio.format\": \"<string>\",\n \"audio.voice\": \"<string>\",\n \"audio.optimize_text_preview\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"audio\": {},\n \"stream\": true,\n \"audio.format\": \"<string>\",\n \"audio.voice\": \"<string>\",\n \"audio.optimize_text_preview\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"audio\": {},\n \"stream\": true,\n \"audio.format\": \"<string>\",\n \"audio.voice\": \"<string>\",\n \"audio.optimize_text_preview\": true\n}"
response = http.request(request)
puts response.read_body语音合成
MiMo 语音合成(TTS)
小米 MiMo-V2.5-TTS 系列语音合成:预置音色、音色设计、音色复刻与流式输出
POST
{llmApiOrigin}
/
mimo
/
v1
/
chat
/
completions
MiMo 语音合成(TTS)
curl --request POST \
--globoff \
--url 'https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"audio": {},
"stream": true,
"audio.format": "<string>",
"audio.voice": "<string>",
"audio.optimize_text_preview": true
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"audio": {},
"stream": True,
"audio.format": "<string>",
"audio.voice": "<string>",
"audio.optimize_text_preview": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{}],
audio: {},
stream: true,
'audio.format': '<string>',
'audio.voice': '<string>',
'audio.optimize_text_preview': true
})
};
fetch('https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
]
],
'audio' => [
],
'stream' => true,
'audio.format' => '<string>',
'audio.voice' => '<string>',
'audio.optimize_text_preview' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"audio\": {},\n \"stream\": true,\n \"audio.format\": \"<string>\",\n \"audio.voice\": \"<string>\",\n \"audio.optimize_text_preview\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"audio\": {},\n \"stream\": true,\n \"audio.format\": \"<string>\",\n \"audio.voice\": \"<string>\",\n \"audio.optimize_text_preview\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/mimo/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"audio\": {},\n \"stream\": true,\n \"audio.format\": \"<string>\",\n \"audio.voice\": \"<string>\",\n \"audio.optimize_text_preview\": true\n}"
response = http.request(request)
puts response.read_body简介
MiMo 语音合成入口对接小米 MiMo-V2.5-TTS 系列,使用 Chat Completions 形态:待合成的文本放在assistant 消息里,user 消息用于描述语气、风格或音色设计,音频以 Base64 放在响应的 message.audio.data 中。
POST /mimo/v1/chat/completions
与其他接口不同,MiMo 的错误响应不会被包装成 OpenAI 错误结构,而是原样返回上游状态码与响应体,便于原生客户端兼容。
认证
Content-Type 必须为 application/json。
支持模型
| 模型 | 能力 | 说明 |
|---|---|---|
mimo-v2.5-tts | 预置音色 | 使用内置音色合成,支持唱歌模式;不支持音色设计与复刻 |
mimo-v2.5-tts-voicedesign | 音色设计 | 用一段文字描述生成音色,无需预置或样本;不支持预置音色与复刻 |
mimo-v2.5-tts-voiceclone | 音色复刻 | 传入音频样本还原目标音色;不支持预置音色与设计 |
请求参数
audio 字段
输出格式:
wav、mp3、pcm、pcm16(pcm 与 pcm16 等价)。
流式调用请使用 pcm16,否则分片无法拼接成完整音频。stream: true 时默认 pcm。预置音色 ID 或音频样本的 base64。
mimo-v2.5-tts 可选,默认 mimo_default;mimo-v2.5-tts-voiceclone 必填;mimo-v2.5-tts-voicedesign 不支持。预置音色
mimo-v2.5-tts 的 audio.voice 可选值:
| 音色 ID | 语言 | 性别 |
|---|---|---|
mimo_default | 默认(视部署集群而定:国内为冰糖,其他为 Mia) | — |
冰糖 | 中文 | 女 |
茉莉 | 中文 | 女 |
苏打 | 中文 | 男 |
白桦 | 中文 | 男 |
Mia | 英文 | 女 |
Chloe | 英文 | 女 |
Milo | 英文 | 男 |
Dean | 英文 | 男 |
调用规则
- 待合成文本写在
assistant消息;user消息用于风格指令(自然语言或音频标签),其内容不会被朗读。 - 使用
mimo-v2.5-tts-voicedesign时,user消息必填,其内容即音色描述。 - 使用
mimo-v2.5-tts-voiceclone时,audio.voice传data:{MIME_TYPE};base64,$BASE64_AUDIO,样本仅支持mp3/wav,Base64 后不超过 10 MB。 - 风格控制支持自然语言(放在
user)与音频标签(放在assistant,如(慵懒)、(唱歌)、[叹气])。
示例
预置音色(非流式)
curl -X POST "https://api.shengmoai.com/mimo/v1/chat/completions" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "mimo-v2.5-tts",
"messages": [
{
"role": "user",
"content": "语气明快、略带上扬,像刚拿到好消息一样"
},
{
"role": "assistant",
"content": "我拿到结果了,真的通过了!"
}
],
"audio": {
"format": "wav",
"voice": "冰糖"
}
}'
预置音色(流式)
curl -N -X POST "https://api.shengmoai.com/mimo/v1/chat/completions" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "mimo-v2.5-tts",
"messages": [
{ "role": "assistant", "content": "夜深了,城市还在呼吸。" }
],
"audio": {
"format": "pcm16",
"voice": "Mia"
},
"stream": true
}'
text/event-stream,每个分片的音频在 choices[0].delta.audio.data 中(Base64 编码的 24 kHz PCM16LE 单声道),按到达顺序拼接即可。
音色设计
curl -X POST "https://api.shengmoai.com/mimo/v1/chat/completions" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "mimo-v2.5-tts-voicedesign",
"messages": [
{
"role": "user",
"content": "二十多岁的年轻女声,音色清亮,语速偏快,带一点笑意"
},
{
"role": "assistant",
"content": "欢迎收听今天的节目。"
}
],
"audio": {
"format": "wav"
}
}'
音色复刻
curl -X POST "https://api.shengmoai.com/mimo/v1/chat/completions" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "mimo-v2.5-tts-voiceclone",
"messages": [
{ "role": "user", "content": "" },
{ "role": "assistant", "content": "这句话会用样本中的音色读出来。" }
],
"audio": {
"format": "wav",
"voice": "data:audio/mpeg;base64,<BASE64_AUDIO>"
}
}'
响应
非流式
{
"id": "chatcmpl-xxxxxxxx",
"object": "chat.completion",
"model": "mimo-v2.5-tts",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "",
"audio": {
"data": "<BASE64_AUDIO>",
"format": "wav"
}
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 213,
"completion_tokens": 97,
"total_tokens": 310
}
}
choices[0].message.audio.data,Base64 解码后按 format 保存为音频文件。
流式
Content-Type: text/event-stream,每个 data: 事件包含一个 JSON 分片,音频位于 choices[0].delta.audio.data。最后一个事件后跟 data: [DONE]。usage 通常出现在最后一个包含用量的分片中。
用量与计费
usage为 MiMo 原始用量(prompt_tokens/completion_tokens/total_tokens);- 计费按平台对 MiMo 模型的配置执行,可在控制台的调用日志中查看每次请求的用量与扣费。
错误处理
MiMo 入口的错误响应原样透传,不包装成 OpenAIerror 结构:
{
"error": {
"code": "...",
"message": "..."
}
}
| 场景 | 处理方式 |
|---|---|
未在 assistant 消息中提供待合成文本 | 检查 messages,文本必须放在 assistant |
voicedesign 缺少 user 音色描述 | 补充 user 消息,或设置 optimize_text_preview: true |
voiceclone 样本格式 / 大小不符 | 仅支持 mp3 / wav,Base64 后 ≤ 10 MB |
| 流式音频无法拼接 | 将 audio.format 改为 pcm16 |
| 令牌无效 / 额度不足 | 401 / 403 / 429,与其他接口一致 |
相关页面
实时语音(Realtime)
WebSocket 实时语音对话,适合双向低延迟场景
模型列表
查询当前账号可用的全部模型
