Synthesize text into spoken speech audio across African languages and English. Audio is generated using CosyVoice3 models with support for authentic native speaker regional accents.
Authentication
All requests require Bearer token authentication in the HTTP header:
Authorization: Bearer <YOUR_API_KEY>Endpoint Overview
POST /v1/tts
Converts input text into spoken binary WAV audio.
[!NOTE] The platform also supports
POST /v1/speechand OpenAI-compatiblePOST /v1/audio/speechas route aliases for backward compatibility.
Request Fields (application/json)
Streaming Audio
You can receive speech progressively using any of the following methods:
- In the Request Body: Pass
"stream": truein your JSON payload. - Via Query Parameter: Append
?stream=true(e.g.,POST /v1/tts?stream=true). - Dedicated Streaming Route: Send your request to
POST /v1/tts/stream. - Via Accept Header: Set
Accept: audio/wav.
Response Structure
1. Unary Mode (stream: false)
Returns a complete binary WAV file with Content-Type: audio/wav. You can stream or save the binary body directly into an .audio.wav file.
Response Headers
Content-Type:audio/wavX-Duration-Sec: Estimated duration of the synthesized audio in seconds.X-Sampling-Rate: Audio sampling rate (e.g.,24000Hz).X-Language: Canonical language slug used for synthesis.X-Credits-Consumed: Mansa credits charged for the request.X-Credits-Remaining: Remaining credit balance in your account.
2. Streaming Mode (stream: true)
Returns audio chunks with Content-Type: audio/wav as progressive binary data streams over HTTP.
Example Requests
Unary Synthesis (cURL)
curl -X POST https://api.mansa.ai/v1/tts \
-H "Authorization: Bearer mansa_live_..." \
-H "Content-Type: application/json" \
-d '{
"text": "Good morning. Welcome to our platform.",
"language": "english",
"voice": "ghanaian_female"
}' \
--output speech.wavProgressive Streaming (cURL)
curl -X POST https://api.mansa.ai/v1/tts \
-H "Authorization: Bearer mansa_live_..." \
-H "Content-Type: application/json" \
-d '{
"text": "Good morning. Streaming speech synthesis allows immediate playback.",
"language": "english",
"voice": "nigerian_male",
"stream": true
}' \
--output streaming_speech.wavVoice Catalog
Every supported language accepts binary "male" and "female" options. When omitted, the voice defaults to nigerian_female.
1. Regional English Accents
When language is set to english, you can specify regional African English accents:
nigerian_male&nigerian_female(West Africa)ghanaian_male&ghanaian_female(West Africa)east_african_male&east_african_female(East Africa)north_african_male&north_african_female(North Africa)south_african_male&south_african_female(Southern Africa)
2. Native Speaker English Accents
Each of the 37 African languages also provides native speaker accent voices named {language}_{gender}_speaker (speaking English with that language's authentic native speaker inflection):
Supported Languages
You can send either the full English name (e.g. Swahili) or the lowercase slug (swahili). Common aliases (e.g. kiswahili, fulani) are also accepted.
Errors & HTTP Status Codes
When an error occurs prior to audio generation, responses use the standardized Mansa JSON error format (HttpErrorDto):
{
"type": "about:blank",
"title": "VALIDATION_ERROR",
"isError": true,
"detail": "Text exceeds the maximum allowed length of 8000 characters",
"invalidParams": [],
"context": ""
}Billing & Credits
- Rate: Speech synthesis is billed based on input text character length at $0.10 per 1K characters ($100 per 1M characters).
- Solvency Check: A preflight check ensures your account has sufficient credits before synthesis begins.
- Stream Settlement: If a progressive streaming connection is severed mid-stream by the client, credits are charged only for the audio bytes transmitted prior to disconnection.
For volume packages and credit purchases, see Pricing.