MiniMax Text-to-Speech API

Call MiniMax text-to-speech (speech-2.8-hd / speech-2.8-turbo) through LMU AI: use the OpenAI /v1/audio/speech protocol with the OpenAI SDK, plus MiniMax extension parameters such as language boost, pronunciation dictionary, emotion and timbre mixing. Use the native /v1/t2a_v2 endpoint when you need subtitles or audio URLs.

The MiniMax text-to-speech models speech-2.8-hd and speech-2.8-turbo can be called through two endpoints:

  • POST /v1/audio/speech: the OpenAI speech protocol, so you can use the OpenAI SDK directly. MiniMax-specific features (language boost, pronunciation dictionary, emotion, timbre mixing and more) go in the request body as extension parameters, and the gateway forwards them to MiniMax as-is.
  • POST /v1/t2a_v2: the MiniMax native endpoint. The request body is forwarded and the response returned as-is. Use it when you need subtitles, audio URLs or the MiniMax native streaming format.

Use an API key in a MiniMax speech group

Use an API key in the MiniMax(Openai协议) or 国产旗舰大模型甄选(Openai协议)-自由切换 group. Keys in other groups cannot reach these two models.


1. Endpoint overview

ItemValue
Base URLhttps://api.lmuai.ai
OpenAI protocol endpointPOST /v1/audio/speech
MiniMax native endpointPOST /v1/t2a_v2
AuthenticationAuthorization: Bearer <your sk- API key>
Request formatContent-Type: application/json
Modelsspeech-2.8-hd, speech-2.8-turbo
BillingBy character count, each Chinese character counted as 2; unit prices in the Model Gallery

2. Quick start

curl

curl https://api.lmuai.ai/v1/audio/speech \
  -H "Authorization: Bearer $LMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-2.8-hd",
    "input": "Hello, welcome to LMU AI.",
    "voice": "male-qn-qingse",
    "response_format": "mp3"
  }' \
  --output out.mp3

On success the response body is the audio file itself (Content-Type: audio/mpeg), not JSON.

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(api_key="sk-your-key", base_url="https://api.lmuai.ai/v1")

resp = client.audio.speech.create(
    model="speech-2.8-hd",
    voice="male-qn-qingse",
    input="Hello, welcome to LMU AI.",
    response_format="mp3",
)
resp.write_to_file("out.mp3")

3. Standard parameters

ParameterRequiredDescription
modelYesspeech-2.8-hd or speech-2.8-turbo
inputYesThe text to synthesize; must not be empty
voiceNoA MiniMax voice ID (voice_id), such as male-qn-qingse or female-shaonv. If omitted or set to an OpenAI voice name (alloy and so on), the default voice male-qn-qingse is used
response_formatNomp3 (default), wav, pcm, flac; any other value returns 400
speedNoSpeaking rate. MiniMax supports 0.5 to 2.0; values outside the range are clamped to the nearest bound (for example, 3.0 is synthesized as 2.0)
stream_formatNoSet to "sse" to stream the output; see section 5

A wrong voice ID returns 400 with error code minimax_2054 (voice id not exist). For the list of system voices, see the MiniMax official documentation.


4. MiniMax extension parameters

The MiniMax native parameters below can be written at the top level of a /v1/audio/speech request body, and the gateway forwards them to MiniMax as-is. MiniMax validates the values: an invalid value returns 400 with an error code like minimax_2013, and the message names the parameter at fault.

4.1 Top-level parameters

ParameterTypeDescription
language_booststringImproves recognition and pronunciation for a given language, such as "Russian" or "Chinese"; "auto" detects the language automatically
text_normalization_modestringHow text is normalized (how numbers, symbols and so on are read): "basic" or "quality"
pronunciation_dictobjectCustom pronunciations, such as {"tone": ["处理/(chu3)(li3)"]}
voice_modifyobjectVoice effects: pitch, intensity and timbre, each from -100 to 100
timbre_weightsarrayMixes several voices by weight, such as [{"voice_id": "male-qn-qingse", "weight": 60}, {"voice_id": "female-shaonv", "weight": 40}]. When mixing, set voice to an OpenAI voice name (such as alloy) or leave it empty

4.2 Nested parameters voice_setting / audio_setting

You can also pass MiniMax voice_setting (such as emotion, vol for volume, pitch) and audio_setting (such as sample_rate, bitrate, channel for channel count). The gateway merges them into the objects of the same name that it builds, and your keys override the defaults.

Three keys are determined by the OpenAI standard parameters and are ignored if written in the nested objects:

Nested keyTaken from
voice_setting.voice_idvoice
voice_setting.speedspeed
audio_setting.formatresponse_format

Without audio_setting, the defaults are a 32000 sample rate, mono, and a 128000 bitrate for mp3.

4.3 Parameters not supported on /v1/audio/speech

stream, stream_options, output_format, subtitle_enable and subtitle_type are ignored on /v1/audio/speech: this endpoint returns only the audio itself and cannot carry subtitles or audio URLs. For those features, use the native /v1/t2a_v2 endpoint.

4.4 Examples

curl: Russian language boost, happy emotion, 16 kHz WAV:

curl https://api.lmuai.ai/v1/audio/speech \
  -H "Authorization: Bearer $LMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-2.8-hd",
    "input": "Привет! Сегодня хорошая погода.",
    "voice": "male-qn-qingse",
    "response_format": "wav",
    "language_boost": "Russian",
    "voice_setting": {"emotion": "happy"},
    "audio_setting": {"sample_rate": 16000}
  }' \
  --output out.wav

Python (OpenAI SDK): put the extension parameters in extra_body:

from openai import OpenAI

client = OpenAI(api_key="sk-your-key", base_url="https://api.lmuai.ai/v1")

resp = client.audio.speech.create(
    model="speech-2.8-hd",
    voice="male-qn-qingse",
    input="这个问题我来处理。",
    response_format="mp3",
    extra_body={
        "pronunciation_dict": {"tone": ["处理/(chu3)(li3)"]},
        "voice_setting": {"emotion": "happy"},
    },
)
resp.write_to_file("out.mp3")

When an extension parameter value is invalid, the SDK raises openai.BadRequestError (HTTP 400).


5. Streaming output

Add "stream_format": "sse" to the request body. The response becomes text/event-stream and delivers the audio in chunks in the OpenAI speech streaming format:

data: {"audio":"<base64 audio chunk>","type":"speech.audio.delta"}

data: {"audio":"<base64 audio chunk>","type":"speech.audio.delta"}

data: {"type":"speech.audio.done"}

Base64-decode the audio of each speech.audio.delta and concatenate them in order to get the full audio; speech.audio.done marks the end. If the connection closes before speech.audio.done, the audio is incomplete.

curl -N https://api.lmuai.ai/v1/audio/speech \
  -H "Authorization: Bearer $LMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-2.8-turbo",
    "input": "Hello, welcome to LMU AI.",
    "voice": "male-qn-qingse",
    "stream_format": "sse"
  }'

6. Native endpoint /v1/t2a_v2

The request body of POST /v1/t2a_v2 matches the MiniMax official t2a_v2 API. The gateway forwards it as-is and returns the response as-is. For parameter details, see the MiniMax official documentation.

Key points:

  • model and text are required, and each field may appear only once.
  • voice_setting.voice_id is required; without it MiniMax returns 400 minimax_2013 (invalid params, empty field). When mixing voices with timbre_weights, set voice_id to an empty string "".
  • Only MiniMax speech models are supported; calling it with any other model returns 400.

6.1 Non-streaming

curl https://api.lmuai.ai/v1/t2a_v2 \
  -H "Authorization: Bearer $LMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-2.8-hd",
    "text": "Hello, welcome to LMU AI.",
    "voice_setting": {"voice_id": "male-qn-qingse", "speed": 1.0},
    "audio_setting": {"format": "mp3", "sample_rate": 32000}
  }'

The response is JSON, and the audio is in data.audio, hex-encoded:

FieldDescription
data.audioHex-encoded audio; with "output_format": "url" it is an audio download URL instead
data.statusSynthesis status; 2 when complete
data.subtitle_fileSubtitle file URL, returned when "subtitle_enable": true is set
extra_infoAudio information, including audio_length, audio_sample_rate, audio_size, bitrate, audio_format, audio_channel, word_count and usage_characters (billed characters)
trace_idRequest trace ID; include it when reporting a problem
base_resp{"status_code": 0, "status_msg": "success"} on success

Saving the audio in Python:

import requests

resp = requests.post(
    "https://api.lmuai.ai/v1/t2a_v2",
    headers={"Authorization": "Bearer sk-your-key"},
    json={
        "model": "speech-2.8-hd",
        "text": "Hello, welcome to LMU AI.",
        "voice_setting": {"voice_id": "male-qn-qingse"},
        "audio_setting": {"format": "mp3"},
    },
    timeout=120,
)
resp.raise_for_status()
with open("out.mp3", "wb") as f:
    f.write(bytes.fromhex(resp.json()["data"]["audio"]))

6.2 Streaming

With "stream": true, the response is MiniMax native SSE: each frame is data: followed by a JSON object. Frames with data.status 1 carry hex-encoded audio chunks; the last frame has data.status 2 and carries extra_info.

By default MiniMax sends the full audio again in the last frame. To receive only the chunks, add "stream_options": {"exclude_aggregated_audio": true}:

curl -N https://api.lmuai.ai/v1/t2a_v2 \
  -H "Authorization: Bearer $LMU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-2.8-turbo",
    "text": "Hello, welcome to LMU AI.",
    "stream": true,
    "stream_options": {"exclude_aggregated_audio": true},
    "voice_setting": {"voice_id": "male-qn-qingse"},
    "audio_setting": {"format": "mp3"}
  }'

6.3 Error format

The MiniMax official API returns HTTP 200 on errors and puts the error in base_resp. Through the gateway, errors come back with the corresponding HTTP error status and a uniform body like the one below, where code is minimax_ followed by the MiniMax error code:

{"error": {"code": "minimax_2013", "message": "invalid params, empty field", "type": "invalid_request_error"}}

7. Common errors

Both endpoints share the following errors:

HTTP statuscode / messageCause and fix
400minimax_2013Invalid parameter; the message names it, for example voice_setting emotion or text_normalization_mode must be basic or quality
400minimax_2054The voice ID does not exist; check that voice (or voice_setting.voice_id) is a MiniMax voice_id
400response_format "opus" is not supported .../v1/audio/speech supports only mp3, wav, pcm and flac
400input is requiredinput is empty on /v1/audio/speech
400model is requiredThe request body has no model

8. Billing

  • Billed by the number of characters in the input text, with each Chinese character counted as 2, based on the usage_characters returned by MiniMax.
  • Both endpoints are billed the same way; failed requests are not billed.
  • See the Model Gallery for unit prices.

Last updated:

Still have questions? Ask in the LMU AI Community (in Chinese) and sign in with your console account.

On this page