Documentation Navigation
Getting Started
API Reference
Resources
Voice API
Text-to-speech, voice cloning, and emotion control. 10 models and 168 voices, each priced before you spend.
POST /v1/generations/voice
Generate speech from text. Returns synchronously for short text, async for long-form.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model key (e.g. "elevenlabs-multilingual-v2", "fish-s2.1-pro", "qwen-3-tts"). |
input | object | Yes | The fields below go inside input. |
input.text | string | Yes | Text to speak. |
input.voice | string | No | Voice id from GET /v1/voices (e.g. "nPczCjzI2devNBz1zQrb" for ElevenLabs models, "933563129e564b19a115bedd57b7406a" for fish-s2.1-pro). Default: the model's default voice. |
input.speed | number | No | Speaking speed. 0.5 to 2.0. Default: 1.0. |
input.ref_audio_url | string (URL) | No | Reference audio URL for voice cloning. |
input.emotion | string | No | Emotion control: "neutral", "happy", "sad", "excited". Model-dependent. |
confirm | boolean | No | Set to false for cost estimate only. Default: true. |
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Generation ID. |
status | string | "completed" or "failed". |
url | string | CDN URL of the generated audio (MP3). |
cost.credits_used | integer | Actual cost charged, in microdollars. |
cost.estimated_credits | integer | Estimated cost, in microdollars. |
cost.currency | string | Always "microdollars". |
metadata.duration | number | Audio duration in seconds. |
metadata.sample_rate | integer | Audio sample rate in Hz. |
metadata.voice | string | Voice preset used. |
Code examples
curl
curl -X POST https://api.fairstack.ai/v1/generations/voice \
-H "Authorization: Bearer $FAIRSTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "elevenlabs-turbo-2-5",
"input": {
"text": "Welcome to FairStack. The best AI models, at fair prices.",
"voice": "nPczCjzI2devNBz1zQrb"
}
}' Python
from fairstack import FairStack
client = FairStack(api_key="fs_live_YOUR_KEY")
result = client.generate.voice(
model="elevenlabs-turbo-2-5",
prompt="Welcome to FairStack. The best AI models, at fair prices.",
voice="nPczCjzI2devNBz1zQrb"
)
print(result.url) # https://media.fairstack.ai/voice/...
print(result.cost) # $0.006156 Node.js
import { FairStack } from "fairstack";
const client = new FairStack({ apiKey: "fs_live_YOUR_KEY" });
const result = await client.generate.voice({
model: "elevenlabs-turbo-2-5",
prompt: "Welcome to FairStack. The best AI models, at fair prices.",
voice: "nPczCjzI2devNBz1zQrb",
});
console.log(result.url); // https://media.fairstack.ai/voice/...
console.log(result.cost); // { credits_used: 6156, estimated_credits: 6156, currency: "microdollars" } Response
{
"id": "gen_voice_abc",
"status": "completed",
"url": "https://media.fairstack.ai/voice/.../output.mp3",
"model": "elevenlabs-turbo-2-5",
"modality": "voice",
"cost": {
"credits_used": 6156,
"estimated_credits": 6156,
"currency": "microdollars"
},
"metadata": {
"duration": 3.2,
"sample_rate": 44100,
"voice": "nPczCjzI2devNBz1zQrb"
}
} Cost units. Every value inside cost is an integer in microdollars, as flagged by currency: "microdollars". The conversion is 1 USD = 1,000,000 microdollars. So credits_used: 30000 = $0.03, and the example above (6156) = $0.006156. The field is named credits_used for backward compatibility with existing SDKs — always read it as microdollars and convert as needed.
Cost estimation
Set confirm: false to get the exact cost without generating audio.
curl -X POST https://api.fairstack.ai/v1/generations/voice \
-H "Authorization: Bearer $FAIRSTACK_API_KEY" \
-d '{ "model": "elevenlabs-turbo-2-5", "input": { "text": "Welcome to FairStack. The best AI models, at fair prices." }, "confirm": false }'
# Response: { "estimated_cost": { "micro": 6156, "display": "$0.006156" } } Voice cloning
Provide a reference audio URL to clone any voice. Works with models that support zero-shot cloning (IndexTTS2).
{
"model": "indextts2",
"input": {
"text": "Your cloned voice reads this sentence perfectly.",
"ref_audio_url": "https://example.com/my-voice-sample.mp3"
}
} For best results, use a 10-30 second clear audio sample with minimal background noise. See the Voice Cloning Guide for details.
GET /v1/voices
List available voice presets for a given model.
curl https://api.fairstack.ai/v1/voices \
-H "Authorization: Bearer $FAIRSTACK_API_KEY" Returns an array of voice objects with name, language, gender, and preview_url.
Next steps
- Voice Guide -- 168+ voices, streaming, pronunciation dictionary
- Voice Cloning Guide -- reference audio, best practices
- Voice Models -- browse all 10 voice models