Using the Text to Speech API
Create an API key
Create an API key in the dashboard here, which you’ll use to securely access the API.Store the key as a managed secret and pass it in the
X-API-KEY header with your requests..env
Make your first request
Create a new file named
example.py or example.js, depending on your language of choice and add the following code:Request Format
All API requests to TTSLab should include theX-API-KEY header with your API key:
Model Versions
TTSLab supports different model versions with different request formats:v3 Models
Use the simplifiedinputs format with model_id:
v1/v2 Models
Use the traditional format with additional parameters and config:stability(0.0 - 1.0): Controls voice consistencysimilarity_boost(0.0 - 1.0): Controls voice similarity to originalstyle(0.0 - 1.0): Controls speaking styleuse_speaker_boost(boolean): Enhances speaker clarity
Response Handling
The API returns a JSON object with the following structure:Response Fields:
id: Unique identifier for the history recorduser: User information (fullname, avatar)history_id: History tracking IDprompt: The text that was converted to speechmodel: Model used for generationvoice: Voice used for generationconfig: Configuration parameters usedcredits_used: Number of credits consumedstatus: Status of the generation (completed, processing, failed)shared_url: Public shareable URL for the audiocreated_at: Timestamp of creationaudio_url: Direct URL to download the generated audio file
Downloading the Audio:
To get the actual audio file, make a GET request to theaudio_url:
Next Steps
- Explore our API reference for all available endpoints
- Learn about different models and their capabilities
- Check out voice management for working with voices