API 文档AI 模型接口语音MiniMax

语音合成

通过文本、音色与音频参数合成语音。支持流式/非流式、hex 或 URL 输出。

调用 MiniMax Speech 将文本合成为音频。支持系统音色、克隆音色、语速/音量/音调、情绪、混音、字幕以及流式输出。

非流式默认返回 hex 编码音频;output_format 为 url 时返回可下载链接(有效期 24 小时)。流式输出仅支持 hex。

Base URL

  • https://api.autorouter.top — Production

Authentication

BearerAuth: http (bearer) 使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx

Endpoints

POST /v1/t2a_v2

创建语音合成请求

传入文本、音色和音频设置,返回音频数据或音频 URL。

Request Body

Content-Type: application/json

Example:

{
  "model": "speech-2.8-hd",
  "text": "今天是不是很开心呀(laughs),当然了!",
  "stream": false,
  "voice_setting": {
    "voice_id": "male-qn-qingse",
    "speed": 1,
    "vol": 1,
    "pitch": 0,
    "emotion": "happy"
  },
  "audio_setting": {
    "sample_rate": 32000,
    "bitrate": 128000,
    "format": "mp3",
    "channel": 1
  },
  "pronunciation_dict": {
    "tone": [
      "处理/(chu3)(li3)",
      "危险/dangerous"
    ]
  },
  "subtitle_enable": false
}

Properties:

NameTypeRequiredDescription
modelstringYes模型名称。可选值:speech-2.8-hd、speech-2.6-hd、speech-02-hd、speech-2.8-turbo、speech-2.6-turbo、speech-02-turbo
textstringYes待合成文本,长度小于 10000 字符。可用换行分段。停顿标记为 <#x#>,x 为秒,取值 [0.01, 99.99],最多两位小数,且必须夹在可发音文本之间。speech-2.8-hd / speech-2.8-turbo 支持语气标签,如 (laughs)、(chuckle)、(coughs)、(sighs)
streambooleanNo是否流式输出。默认 false
stream_optionsobjectNo流式选项
stream_options.exclude_aggregated_audiobooleanNo最终 chunk 是否排除拼接后的完整 hex 音频。默认 false(最终 chunk 包含完整音频)
voice_settingobjectNo音色与朗读控制
audio_settingobjectNo输出音频参数
pronunciation_dictobjectNo读音替换规则
timber_weightsobject[]No混音色权重,最多 4 个。使用该字段时需将 voice_setting.voice_id 留空
language_booststring | nullNo语种增强,如 Chinese、English、auto。默认 null
voice_modifyobjectNo音高/强度/音色微调与音效
subtitle_enablebooleanNo是否开启字幕。仅非流式有效。默认 false
output_formatstringNo非流式输出形式:hex(默认)或 url。流式仅支持 hex。URL 有效期 24 小时
aigc_watermarkbooleanNo是否在音频末尾添加节奏标识。仅非流式有效。默认 false

voice_settingobject(可选)

音色与朗读控制。支持系统音色、克隆音色与文本生成音色。

voice_idstring(可选)

合成所用音色 ID。使用 timber_weights 混音时请留空。

speednumber(可选)

语速,取值 [0.5, 2],默认 1。越大越快。

volnumber(可选)

音量,取值 (0, 10],默认 1。

pitchinteger(可选)

音高,取值 [-12, 12],默认 0(原音色音高)。

emotionstring(可选)

情绪。可选值:happy、sad、angry、fearful、disgusted、surprised、calm、fluent、whisper。

text_normalizationboolean(可选)

是否开启中英文文本规范化,可提升数字朗读效果,可能略增延迟。默认 false。

latex_readboolean(可选)

是否朗读 LaTeX 公式。仅支持中文;开启后会将 language_boost 设为 Chinese。公式需用 $$ 包裹,反斜杠需转义。默认 false。

audio_settingobject(可选)

输出音频参数。

sample_rateinteger(可选)

采样率。可选值:8000、16000、22050、24000、32000(默认)、44100。

bitrateinteger(可选)

码率,仅对 MP3 生效。可选值:32000、64000、128000(默认)、256000。

formatstring(可选)

音频格式:mp3(默认)、pcm、flac、wav。wav 仅支持非流式。

channelinteger(可选)

声道数。1 单声道(默认),2 立体声。

force_cbrboolean(可选)

恒定码率编码。仅在流式且格式为 mp3 时生效。

timber_weightsobject[](可选)

混音色权重,最多 4 个音色。使用时需将 voice_setting.voice_id 留空。

voice_idstring(必选)

参与混音的音色 ID。

weightinteger(必选)

该音色权重,取值 [1, 100]。越大越接近该音色。

voice_modifyobject(可选)

音高、强度、音色微调与音效。每次请求只能选择一种音效。

pitchinteger(可选)

音高调整,取值 [-100, 100]。接近 -100 更低沉,接近 100 更明亮。

intensityinteger(可选)

强度调整,取值 [-100, 100]。接近 -100 更强,接近 100 更柔。

timbreinteger(可选)

音色调整,取值 [-100, 100]。接近 -100 更厚实,接近 100 更清晰。

sound_effectsstring(可选)

音效,每次只能选一个:spacious_echo、auditorium_echo、lofi_telephone、robotic。

Responses

200: 合成成功

Content-Type: application/json

400: 请求失败(见 base_resp.status_code)

Content-Type: application/json

请求示例

curl -X POST "https://api.autorouter.top/v1/t2a_v2" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxx" \
  -d '{
  "model": "speech-2.8-hd",
  "text": "今天是不是很开心呀(laughs),当然了!",
  "stream": false,
  "voice_setting": {
    "voice_id": "male-qn-qingse",
    "speed": 1,
    "vol": 1,
    "pitch": 0,
    "emotion": "happy"
  },
  "audio_setting": {
    "sample_rate": 32000,
    "bitrate": 128000,
    "format": "mp3",
    "channel": 1
  }
}'

响应示例

{
  "data": {
    "audio": "<hex编码的audio>",
    "status": 2
  },
  "extra_info": {
    "audio_length": 9900,
    "audio_sample_rate": 32000,
    "audio_size": 160323,
    "bitrate": 128000,
    "word_count": 52,
    "invisible_character_ratio": 0,
    "usage_characters": 26,
    "audio_format": "mp3",
    "audio_channel": 1
  },
  "trace_id": "01b8bf9bb7433cc75c18eee6cfa8fe21",
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

响应字段说明:

NameTypeDescription
dataobject | null音频数据。失败时可能为 null,使用前需判断
data.audiostring合成音频。默认 hex;output_format: url 时为 URL
data.subtitle_filestring字幕下载链接。句级、不超过 50 字符、毫秒时间戳、JSON 格式
data.statusinteger音频流状态。1 合成中,2 合成结束
extra_infoobject音频元信息
extra_info.audio_lengthinteger音频时长(毫秒)
extra_info.audio_sample_rateinteger采样率
extra_info.audio_sizeinteger文件大小(字节)
extra_info.bitrateinteger码率
extra_info.audio_formatstring音频格式:mp3 / pcm / flac
extra_info.audio_channelinteger声道数。1 单声道,2 立体声
extra_info.invisible_character_rationumber无效字符占比。不超过 10% 仍会生成;超过 10% 报错
extra_info.usage_charactersinteger计费字符数
extra_info.word_countinteger发音字数(含汉字、数字、字母,不含标点)
trace_idstring会话 ID,用于咨询或反馈
base_resp.status_codeinteger状态码。0 成功;错误码包括 1000、1001、1002、1004、1039、1042、2013
base_resp.status_msgstring状态说明

错误处理

HTTP 400 参数错误

场景响应
输入参数不合法{"data":null,"trace_id":"...","base_resp":{"status_code":2013,"status_msg":"输入参数信息不正常"}}
无效字符占比超过 10%base_resp.status_code 非 0,data 为 null

HTTP 401 / 403 鉴权错误

  • 401 Unauthorized:API Key 无效或已过期
  • 403 Forbidden:API Key 无权访问此模型(检查 token 的模型白名单)

HTTP 402 余额不足

返回 insufficient user quota。请前往 AutoRouter 控制台充值。

使用响应前请检查 data 是否为 null,并以 base_resp.status_code == 0 判断业务成功。

目录