Text to generate a speech from













Audio Speech Endpoints
API for speech generation.












Examples
Real world code examples
Speech
POST /v1/audio/speech#
Speech
200 (application/json)
200 (text/event-stream)
Speech audio data.
Playground
Test the endpoints live
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.audio.speech.complete({
input: "<value>",
});
console.log(result);
}
run();
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.audio.speech.complete({
input: "<value>",
});
console.log(result);
}
run();
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
curl https://api.mistral.ai/v1/audio/speech \
-X POST \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"input": "Example input."
}'curl https://api.mistral.ai/v1/audio/speech \
-X POST \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"input": "Example input."
}'200 (application/json)
200 (text/event-stream)
{
"audio_data": "base64-encoded-audio-data"
}{
"audio_data": "base64-encoded-audio-data"
}nullnull