Skip to main content

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

FieldTypeRequiredDescription
modelstringYesModel key (e.g. "elevenlabs-multilingual-v2", "fish-s2.1-pro", "qwen-3-tts").
inputobjectYesThe fields below go inside input.
input.textstringYesText to speak.
input.voicestringNoVoice id from GET /v1/voices (e.g. "nPczCjzI2devNBz1zQrb" for ElevenLabs models, "933563129e564b19a115bedd57b7406a" for fish-s2.1-pro). Default: the model's default voice.
input.speednumberNoSpeaking speed. 0.5 to 2.0. Default: 1.0.
input.ref_audio_urlstring (URL)NoReference audio URL for voice cloning.
input.emotionstringNoEmotion control: "neutral", "happy", "sad", "excited". Model-dependent.
confirmbooleanNoSet to false for cost estimate only. Default: true.

Response fields

FieldTypeDescription
idstringGeneration ID.
statusstring"completed" or "failed".
urlstringCDN URL of the generated audio (MP3).
cost.credits_usedintegerActual cost charged, in microdollars.
cost.estimated_creditsintegerEstimated cost, in microdollars.
cost.currencystringAlways "microdollars".
metadata.durationnumberAudio duration in seconds.
metadata.sample_rateintegerAudio sample rate in Hz.
metadata.voicestringVoice 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