Speech generation
A speech request turns a complete text into an audio file in one call, in the voice and the format you choose. This page shows the request, the fields that change the result, and the errors you're most likely to meet.
To start playback before the whole file is ready, see Stream speech. For how voices, tags, and instructions shape the result, see Voices.
Make a request and use the response
Send the text and a voice in one POST request. The response carries the audio, base64-encoded, in audio_data: decode it and save it to a file.
import base64
import os
from pathlib import Path
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
response = client.audio.speech.complete(
model="voxtral-mini-tts-3-0",
input="Your order shipped this morning and should arrive on Thursday.",
voice_id="gb_jane_neutral",
response_format="mp3",
)
audio = base64.b64decode(response.audio_data)
output = Path("order_update.mp3")
output.write_bytes(audio)
print(f"Saved {output.resolve()} ({len(audio)} bytes)")The examples save order_update.mp3 in the current directory. Open it in any audio player to listen.
Request fields
The following table lists the fields that most often change the result. For the full list, see the API reference.
| Field | What it does |
|---|---|
model | The speech model, for example voxtral-mini-tts-3-0. |
input | The text to speak. It can carry inline emotion and pace tags. |
voice_id | The voice to use: a preset slug such as gb_jane_neutral, or the ID of a voice saved in your workspace. See Voices. |
ref_audio | A short recording, base64-encoded, to clone a voice for this request only, instead of voice_id. See Voice cloning. |
response_format | The audio format of the result. See Response formats. |
expressiveness | See Expressiveness. |
instruction | Style instructions are not available at launch. See Style instructions. |
phoneme_hints | The pronunciation of specific words, as lists of phonemes. See Custom pronunciation. |
stream | Set to true to receive the audio in chunks as it's generated. See Stream speech. |
Response formats
Set response_format to mp3 (the default), wav, pcm, flac, or opus. To choose between them, see Audio formats.
Expressiveness
expressiveness sets how strongly the generated speech follows what you ask for: the voice, the text, and any emotion tags or style instruction. It accepts values from 1.0 to 5.0.
Controls how expressive the speech is. Higher values trade voice similarity and stability for stronger delivery. Start with the default, raise it if the emotion doesn't come through, and lower it if the speech sounds forced.
Common issues
These are the problems you're most likely to meet with a speech request. For the full list, see Troubleshooting.
| Symptom | Cause | Fix |
|---|---|---|
404 error of type invalid_voice: Voice 'x' not found. | The voice slug or ID doesn't exist in the catalog or in your workspace. | List the voices and copy the exact slug or ID. See Voices. |
400 error: Either ref_audio or voice must be provided. | The request has no voice. | Add voice_id. |
| A name, a brand, or an acronym is mispronounced | The voice guesses the reading from the spelling. | Give the word its phonemes. See Custom pronunciation. |