saveStreamToFile handles audio output in one call.
Installation
@camb-ai/sdk and ships as ES modules.
Authentication
Get your API key from Camb.ai Studio and read it fromprocess.env.CAMB_API_KEY so it never appears in source control.
Every API call on CambClient returns a promise. There is no synchronous client: wrap usage in async functions and use await throughout.
Quick Start
Streaming TTS returns binary data thatsaveStreamToFile writes to disk. await client.textToSpeech.tts(...) resolves to a stream object the helper understands.
Models
Camb.ai offers MARS models tuned for different quality and latency requirements. Passspeech_model using CambApi.CreateStreamTtsRequestPayload.SpeechModel. If you omit it, the API applies its default model.
The tab snippets below assume the same
client and CambApi imports as in Quick Start.
- MARS Flash
- MARS Pro
- MARS Instruct
TTS Options
Theclient.textToSpeech.tts(...) method accepts the core request fields plus optional controls for model behavior and output format.
Voices
List voices
listVoices() returns every voice available to your account, including library voices and custom clones. Use the returned id (or equivalent field from the typed response) as voice_id in TTS calls.
Create a custom voice
Upload a short reference clip with a display name and gender. Setenhance_audio when the recording may contain noise so the API can preprocess the clip before cloning.
Language support
TTS requests use string locale values throughCambApi.CreateStreamTtsRequestPayload.Language (for example Language.EnUs maps to "en-us"). See Language Support for the full per-model locale list. Dubbing, translation, transcription, and several other endpoints use the numeric CambApi.Languages enum so the wire format matches the REST API exactly.
Dubbing
The dubbing client translates the audio track of a remote video and resynthesizes speech with cloned voices. In TypeScript the entry point isendToEndDubbing, not the Python name create_dub. You submit a job, poll getEndToEndDubbingStatus until status is success, then read URLs from getDubbedRunInfo.
target_languages instead of target_language.
Get transcript
After a successful run,getDubbedRunTranscript returns transcript text keyed by field name for the requested target language.
Translation
createTranslation accepts an array of strings and returns translations in the same order. The workflow matches dubbing: create a task, poll getTranslationTaskStatus, then call getTranslationResult with the run_id from the status payload.
For streaming translation over a single string, see
client.translation.translationStream in the generated client types.Transcription
Send eithermedia_url or a local media_file. Poll until the task succeeds, then request structured text (optionally with word-level timestamps) from getTranscriptionResult.
media_file instead of media_url.
Audio separation
Audio separation splits a mixed recording into stems. Uploadmedia_file, poll getAudioSeparationStatus, then read stem metadata from getAudioSeparationRunInfo.
Text-to-voice
Text-to-voice synthesizes a new voice timbre from a written description and sample line. The pipeline is asynchronous: create the job, poll status, then inspectgetTextToVoiceResult for preview URLs and identifiers you can feed back into TTS.
Inspect the
getTextToVoiceResult payload for preview URLs and the voice_id you should pass into textToSpeech.tts for production speech.Text-to-audio
Text-to-audio generates sound effects or ambient beds from a prompt. The create call returns atask_id. After polling succeeds, getTextToAudioResult returns streaming audio that saveStreamToFile can persist.
Stories
The story endpoint ingests a text or Word document, builds narration, and returns run metadata when processing completes. Passsource_language as CambApi.Languages and stream the document as file.
Translated TTS
Translated TTS translates text and renders speech in the target language in one pipeline. The TypeScript client exposescreateTranslatedTts and getTranslatedTtsTaskStatus. When the status reports success, inspect the status object and the API reference for URLs or identifiers your integration should download.
Dictionaries
Dictionaries store glossary rows that dubbing and translation jobs can consume automatically. Upload bulk CSV files or manage individual terms through the JSON endpoints.List dictionaries
Create from file
Manage terms
Each translation row pairs a string with aCambApi.Languages value. Use numeric dictionary and term identifiers returned by previous API calls.
Folders
List or create folders withclient.folders.listFolders({}) and client.folders.createFolder({ folder_name: "..." }) when you need to organize runs in Studio.
Error handling
Failed HTTP responses throwCambApiError. Validation failures surface as CambApi.UnprocessableEntityError, which extends CambApiError and carries the parsed body.
requestOptions on any call to override timeouts or retries for that request.
Custom provider
Self-hosted MARS on Baseten reusestextToSpeech.tts, but you must construct CambClient with ttsProvider: "baseten" and supply providerParams. Baseten also requires base64 reference_audio and a reference_language entry inside additional_body_parameters on each TTS request. See Custom Cloud Providers for deployment details.
Baseten
Baseten validates
reference_audio and reference_language. You can supply only ttsProvider and providerParams if you never call the default Camb.ai API, or include apiKey when you use both hosted and Baseten routes in one process.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