Installation
Authentication
Get your API key from Camb.ai Studio and set it as an environment variable. The client reads it viaos.getenv("CAMB_API_KEY") so your key never has to appear in source code.
The SDK ships two clients. Use CambAI for scripts, data pipelines, and anything thread-managed. Use AsyncCambAI for web servers (FastAPI, Sanic) and high-concurrency applications where blocking would hurt throughput.
Quick Start
The quickest way to get started is streaming TTS audio directly to a file.tts() returns a byte iterator that save_stream_to_file writes in one call:
AsyncCambAI and save_async_stream_to_file. The interface is identical to the sync client:
Models
Camb.ai offers MARS models tuned for different quality and latency requirements. Pass the model name asspeech_model in any TTS call. If you omit it, the API uses a default model.
- MARS Flash
- MARS Pro
- MARS Instruct
TTS Options
Thetext_to_speech.tts(...) method accepts the core request fields plus optional controls for model behavior and output format.
Example with
mars-instruct delivery guidance:
Voices
List Voices
Calllist_voices() to retrieve all voices available on your account, including pre-built library voices and any custom voices you have created. The id field is what you pass as voice_id in TTS calls.
Create a Custom Voice
To clone a voice, upload a short reference audio sample alongside a name and gender. Settingenhance_audio=True applies preprocessing that improves cloning quality on recordings with background noise.
Language Support
Camb.ai supports up to 312 languages depending on the MARS model â see Language Support for the full per-model locale list. You can pass locale strings directly, but using theLanguages enum is recommended because it provides autocomplete in your editor and prevents typos in language codes.
languages sub-client. Source languages are what you can transcribe or translate from; target languages are what you can translate or dub into.
Dubbing
The dubbing pipeline takes a publicly accessible video URL, translates the audio track into your target language, and synthesizes speech using a clone of the original speakerâs voice. Dubbing is asynchronous: you submit the job, poll for completion, and then fetch the result.target_language with the target_languages list:
Get Transcript
Once a dubbing job completes, you can retrieve the full transcript for any target language using therun_id returned by get_dubbing_status.
Translation
The translation API accepts a list of text strings and returns them translated into the target language in the same order. Like dubbing, translation is asynchronous. You submit a job and poll until the status reachesSUCCESS.
create_translation accepts a list of strings under texts. All strings are translated in a single job and returned in order.Transcription
Submit an audio or video file for transcription and retrieve the result once processing completes. You can pass a remote URL viamedia_url or upload a local file via media_file. The result supports optional word-level timestamps.
media_file:
Audio Separation
Audio separation splits a mixed audio track into its vocal and background components. After the job completes, the result contains separate download URLs for each stem so you can use them independently.Text-to-Voice
Text-to-Voice creates a brand-new synthetic voice from a written description of the desired vocal characteristics. The API generates several audio samples so you can audition variations before deciding which voice ID to use in production.The result contains multiple sample audio URLs. Preview them and use the
voice_id of your preferred sample with client.text_to_speech.tts.Text-to-Audio
Text-to-Audio generates sound effects or ambient soundscapes from a descriptive text prompt. The job is asynchronous, and the result is a streamable audio file you can save withsave_stream_to_file once processing completes.
Stories
The Stories API takes a document file, structures its content into a narrative, and returns a fully narrated audio output. You can provide a custom narrator voice ID; if omitted, the API selects a default voice appropriate for the source language.Translated TTS
Translated TTS combines translation and speech synthesis into a single asynchronous job. The text is translated into the target language and then spoken using the voice you specify, without needing to run translation and TTS as separate steps.Dictionaries
Dictionaries contain custom term mappings that the API applies automatically when running dubbing or translation jobs. They are particularly useful for brand names, product terminology, and proper nouns that need consistent handling across languages.List Dictionaries
Callget_dictionaries() to retrieve all dictionaries on your account along with their metadata:
Create from File
Upload a CSV file to create a new dictionary. The file should contain source and target term pairs in a format the API expects:Manage Terms
Useadd_term_to_dictionary to insert individual term translations and delete_dictionary_term to remove them by ID. Each term takes a source, a target, and the language the target is in:
Custom Provider
If you are running MARS on your own infrastructure through Baseten, you can initialize the client with a provider configuration instead of a Camb.ai API key. See Custom Cloud Providers for deployment instructions.Baseten
Deploy the MARS model to your Baseten account, then point the client at your deployment URL. Baseten calls require a base64-encoded reference audio sample to be passed with every request:Baseten deployments require
reference_audio (base64-encoded WAV) and reference_language in additional_body_parameters.Next Steps
Voice Agents
Build real-time voice agents with Pipecat
LiveKit Integration
Create voice agents with LiveKit
API Reference
Explore the full TTS API
Voice Library
Browse available voices