Text to Speech
Generates audio from input text using text-to-speech (TTS) models. The response is a JSON object containing base64-encoded audio in the audios array (not a raw binary stream).
Only model and input are required. All other parameters are model-specific — for example sarvam/bulbul:v2 supports target_language_code, speaker, pitch, pace, loudness, speech_sample_rate, enable_preprocessing, output_audio_codec, temperature, and enable_cached_responses.
Tip: Supported parameters and their accepted values differ from one model to another. Call GET /api/v1/models and inspect each model's
supported_parametersandsupported_params_detailsto see exactly which fields it accepts and the allowed values, ranges, or enums.
FastRouter API Key. Get yours at https://fastrouter.ai
Format: Authorization: Bearer YOUR_API_KEY
TTS model in provider/model format.
sarvam/bulbul:v2The text to convert to speech.
The quick brown fox.Model-specific (e.g. Sarvam). BCP-47 language code of the output speech (e.g. en-IN, hi-IN).
en-INModel-specific (e.g. Sarvam). The speaker voice to use.
anushkaModel-specific (e.g. Sarvam). Adjusts the pitch of the generated speech.
Model-specific (e.g. Sarvam). Adjusts the speed of the speech (e.g. 0.5x to 2.0x).
1Model-specific (e.g. Sarvam). Adjusts the loudness of the generated speech.
Model-specific (e.g. Sarvam). Output audio sample rate in Hz.
22050Model-specific (e.g. Sarvam). Enables text normalization / preprocessing before synthesis.
Model-specific (e.g. Sarvam). The audio codec/format of the response.
Model-specific. Sampling temperature for generation.
Model-specific (e.g. Sarvam). Allows returning a cached response for identical requests.
The generated speech. Returns a JSON object containing the base64-encoded audio (not a raw binary stream).
Array of base64-encoded audio clips (WAV). Usually one entry.
The model used to generate the audio.
sarvam/bulbul:v2The upstream provider that served the request.
sarvamBad Request - The request is malformed. This could be due to missing parameters, invalid formats, or routing errors.
Note: the 400 body shape is not uniform. Validation errors return the structured object below, but routing/model errors may instead return a plain string: { "error": "<message>" }. A few endpoints (e.g. some file operations) may return a plain-text body rather than JSON.
Invalid Credentials - Your API key is invalid, missing, or disabled. Check your credentials.
Note: the 401 error body uses code, message, param, and type (there is no status field), and type is invalid_request_error.
Insufficient Credits - Your account or API key has run out of credits. Add more credits and retry the request.
Rate Limited - You have exceeded your request limits (TPM/RPM). Slow down or increase your limits.
Internal Server Error
POST /api/v1/audio/speech HTTP/1.1
Host: api.fastrouter.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 59
{
"model": "sarvam/bulbul:v2",
"input": "The quick brown fox."
}{
"audios": [
"UklGRs..."
],
"model": "sarvam/bulbul:v2",
"provider": "sarvam",
"usage": {
"prompt_tokens": 5,
"total_tokens": 5,
"cost": 0.000075,
"chat_id": "fr_29a0c9b3-f31f-4282-8078-58482380c7a5"
}
}Last updated
