Overview
While SDKs and frameworks provide convenience, sometimes you need direct control over API calls. This tutorial shows how to call the Camb.ai TTS API directly using HTTP requests.When to Use Direct API
- Building integrations in languages without an SDK
- Need fine-grained control over request/response handling
- Debugging or testing API behavior
- Building custom streaming implementations
Authentication
All API requests require your API key in thex-api-key header:
Basic TTS Request
Python with aiohttp
cURL
Python with requests (Synchronous)
Streaming Response
For real-time applications, stream audio chunks as they’re generated:Request Parameters
Required Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | Text to convert to speech (min 3 characters) |
voice_id | integer | Voice ID to use |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
language | string | "en-us" | BCP-47 language code |
speech_model | string | "mars-flash" | Model: mars-flash, mars-pro, mars-instruct |
output_configuration | object | {} | Output format settings |
enhance_named_entities | boolean | false | Better pronunciation for names/places |
Output Configuration
pcm_s16le- Raw PCM, 16-bit signed little-endian (recommended for streaming)wav- WAV file formatmp3- MP3 compressed audio